summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--example0.luma20
-rw-r--r--include/luma/main.hh20
-rw-r--r--initgfx.cc4
-rw-r--r--stdlibsock/gfx/crtwin.cc20
-rw-r--r--stdlibsock/gfx/destwin.cc4
6 files changed, 52 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 87722ed..e36e63a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
CXX=clang++
-CXXFLAGS+=-Iinclude -D_ATFILE_SOURCE -D_FORTIFY_SOURCE=½2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_ISOC99_SOURCE -D_ISOC11_SOURCE -D_ISOC2X_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D__STDC_WANT_IEC_60559_BFP_EXT__ -D__STDC_WANT_IEC_60559_FUNCS_EXT__ -D__STDC_WANT_IEC_60559_TYPES_EXT__ -D__STDC_WANT_LIB_EXT2__=0x1
+CXXFLAGS+=-Iinclude -D_ATFILE_SOURCE -D_FORTIFY_SOURCE=2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_ISOC99_SOURCE -D_ISOC11_SOURCE -D_ISOC2X_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D__STDC_WANT_IEC_60559_BFP_EXT__ -D__STDC_WANT_IEC_60559_FUNCS_EXT__ -D__STDC_WANT_IEC_60559_TYPES_EXT__ -D__STDC_WANT_LIB_EXT2__=0x1
CXXFLAGS+=-std=c++20 -Wall -Wextra -Wpedantic
CXXFLAGS+=-march=native -O3
-LIBS=-lgmp -lmpfr -lpthread -lvulkan -lwayland-client
+LIBS=-lgmp -lmpfr -lpthread -lvulkan -lwayland-client -lxcb
HDRS_CXX=\
include/luma/stdlibsock/gfx.hh \
include/luma/main.hh \
diff --git a/example0.luma b/example0.luma
index 6ac2164..74245a0 100644
--- a/example0.luma
+++ b/example0.luma
@@ -1,15 +1,9 @@
-> mod std
-> mod gfx
-> fn crtwin [str:nm int16:pos_x int16:pos_y int16:res_x int16:res_y bool:flscrn]
-
-frm std/gfx imp clswin crtwin
-
-int32:__main__ -fn []
+frm /std/gfx imp clswin crtwin win_t
+void_t:main -fn []
print “Creating window...\n”
- try std/gfx/crtwin “luma test” #0 #0 #417 #045 no
+ /std/gfx/win_t:win
> Remember that Luma is little-endian, so numbers must be written reverse of what they normaly are (example: 123 becomes 321)
- catch err
- print “Error % when creating window" $.err
- ret failure
- std/gfx/clswin
- ret success
+ catch (win = (/std/gfx/crtwin “luma test” #0 #0 #417 #045 no))
+ print (“Error " + $errval + " when creating window")
+ thrw #1
+ /std/gfx/clswin
diff --git a/include/luma/main.hh b/include/luma/main.hh
index 86b8e71..12aaf1d 100644
--- a/include/luma/main.hh
+++ b/include/luma/main.hh
@@ -1,4 +1,3 @@
-# if !defined(LUMA__HEADER__MAIN)
# if defined(__cplusplus)
# if __cplusplus < 202002L
# error The compiler seems to not have support for C++20 or newer½ (__cplusplus is less than 202002L), which is required to build Luma.
@@ -6,18 +5,33 @@
# else
# error The compiler appears to not support C++ at all (__cplusplus is not defined).
# endif
+# if !defined(LUMA__HEADER__MAIN)
# define LUMA__HEADER__MAIN
+//# if defined(__linux__)
+# define LUMA__USE_X
+//# endif
# include <cstdint>
# include <luma/stdlibsock.hh>
# include <luma/stdlibsock/gfx.hh>
# include <string>
+# if defined(LUMA__USE_X)
# include <wayland-client.h>
+# else
+# include <xcb/xcb.h>
+# endif
using namespace std::literals::string_literals;
namespace luma {
class dat_t {
public:
- char * dispsrv;
- struct wl_display * wldisp;
+ char * dispsrv;
+# if defined(LUMA__USE_X)
+ wl_display * wldisp;
+ wl_shell_surface * wlsurf;
+# else
+ xcb_connection_t * xconn;
+ xcb_screen_t * xscrn;
+ xcb_window_t xwin;
+# endif
};
luma::dat_t extern dat;
void initgfx(uint32_t * retval);
diff --git a/initgfx.cc b/initgfx.cc
index 8d9ef73..a6df6dd 100644
--- a/initgfx.cc
+++ b/initgfx.cc
@@ -1,6 +1,10 @@
# include <luma/main.hh>
# include <stdint.h>
# include <stdio.h>
+# if defined(LUMA__USE_X)
# include <wayland-client.h>
+# else
+# include <xcb/xcb.h>
+# endif
void luma::initgfx(uint32_t * retval) {
}
diff --git a/stdlibsock/gfx/crtwin.cc b/stdlibsock/gfx/crtwin.cc
index 82f8cdc..d6ea03d 100644
--- a/stdlibsock/gfx/crtwin.cc
+++ b/stdlibsock/gfx/crtwin.cc
@@ -3,11 +3,18 @@
# include <luma/main.hh>
# include <string>
# include <unistd.h>
+# include <vulkan/vulkan.hpp>
+# if defined(LUMA__USE_X)
# include <wayland-client.h>
-uint8_t luma::stdlibsock::gfx::crtwin(std::basic_string<char>,uint16_t pos_x,uint16_t pos_y,uint16_t res_x,uint16_t res_y,bool flscrn) {
+# else
+# include <xcb/xcb.h>
+# include <xcb/xcb_atom.h>
+# endif
+uint8_t luma::stdlibsock::gfx::crtwin(std::basic_string<char> nm,uint16_t pos_x,uint16_t pos_y,uint16_t res_x,uint16_t res_y,bool flscrn) {
if(flscrn) {
std::cout << "Fullscreen is not supported yet!\n";
}
+# if defined(LUMA__USE_X)
luma::dat.wldisp = wl_display_connect(NULL);
if(luma::dat.wldisp == nullptr) {
std::cout << "Unable to make a Wayland connection!\n";
@@ -17,5 +24,16 @@ uint8_t luma::stdlibsock::gfx::crtwin(std::basic_string<char>,uint16_t pos_x,uin
}
::sleep(0x6);
::wl_display_disconnect(luma::dat.wldisp);
+# else
+ luma::dat.xconn = xcb_connect(NULL,NULL);
+ luma::dat.xscrn = xcb_setup_roots_iterator(xcb_get_setup(luma::dat.xconn)).data;
+ luma::dat.xwin = xcb_generate_id(luma::dat.xconn);
+ xcb_create_window(luma::dat.xconn,XCB_COPY_FROM_PARENT,luma::dat.xwin,luma::dat.xscrn->root,pos_y,pos_x,res_x,res_y,0xa,XCB_WINDOW_CLASS_INPUT_OUTPUT,luma::dat.xscrn->root_visual,0x0,NULL);
+ xcb_change_property(luma::dat.xconn,XCB_PROP_MODE_REPLACE,luma::dat.xwin,XCB_ATOM_WM_NAME,XCB_ATOM_STRING,0x8,nm.size(),nm.c_str());
+ xcb_map_window(luma::dat.xconn,luma::dat.xwin);
+ xcb_flush(luma::dat.xconn);
+ sleep(0x6);
+ xcb_disconnect(luma::dat.xconn);
+# endif
return 0x0;
}
diff --git a/stdlibsock/gfx/destwin.cc b/stdlibsock/gfx/destwin.cc
index 3280d55..2ee8387 100644
--- a/stdlibsock/gfx/destwin.cc
+++ b/stdlibsock/gfx/destwin.cc
@@ -1,2 +1,4 @@
# include <luma/main.hh>
-void luma::stdlibsock::gfx::destwin();
+void luma::stdlibsock::gfx::destwin() {
+
+}