summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile35
-rw-r--r--checkdispsrv.c19
-rw-r--r--include/luma/main.h32
-rw-r--r--include/luma/main.hh25
-rw-r--r--include/luma/stdlibsock.hh (renamed from include/luma/stdlibsock.h)0
-rw-r--r--include/luma/stdlibsock/gfx.h7
-rw-r--r--include/luma/stdlibsock/gfx.hh13
-rw-r--r--initgfx.cc6
-rw-r--r--initx.c14
-rw-r--r--main.c21
-rw-r--r--main.cc20
-rw-r--r--stdlibsock/gfx/crtwin.c28
-rw-r--r--stdlibsock/gfx/crtwin.cc21
-rw-r--r--stdlibsock/gfx/destwin.c2
-rw-r--r--stdlibsock/gfx/destwin.cc2
15 files changed, 105 insertions, 140 deletions
diff --git a/Makefile b/Makefile
index 5d506d2..87722ed 100644
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,22 @@
-CC=clang
-CFLAGS+=-Iinclude -std=c17 -Wall -Wextra -Wpedantic -Werror
-CFLAGS+=-march=native -O3
-LIBS=-lgmp -lmpfr -lpthread -lxcb -lvulkan -lwayland-client
-HDR=\
- include/luma/stdlibsock/gfx.h \
- include/luma/main.h \
- include/luma/stdlibsock.h
-SRC=\
- stdlibsock/gfx/crtwin.c \
- stdlibsock/gfx/destwin.c \
- checkdispsrv.c \
- initx.c \
- main.c
-OBJ=$(SRC:.c=.o)
+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+=-std=c++20 -Wall -Wextra -Wpedantic
+CXXFLAGS+=-march=native -O3
+LIBS=-lgmp -lmpfr -lpthread -lvulkan -lwayland-client
+HDRS_CXX=\
+ include/luma/stdlibsock/gfx.hh \
+ include/luma/main.hh \
+ include/luma/stdlibsock.hh
+SRCS_CXX=\
+ stdlibsock/gfx/crtwin.cc \
+ stdlibsock/gfx/destwin.cc \
+ initgfx.cc \
+ main.cc
+SRCS=$(SRCS_CXX)
+OBJ=$(SRCS:.cc=.o)
luma.elf: $(OBJ)
- $(CC) $(CCFLAGS) $(LIBS) $(OBJ) -o $@
-$(OBJ): $(HDR) $(SRC)
+ $(CXX) $(LIBS) $(OBJ) -o $@
+$(OBJ): $(HDRS_CXX) $(SRCS_CXX)
.PHONY: clean
clean:
rm $(OBJ)
diff --git a/checkdispsrv.c b/checkdispsrv.c
deleted file mode 100644
index a7e6bbf..0000000
--- a/checkdispsrv.c
+++ /dev/null
@@ -1,19 +0,0 @@
-# include <luma/main.h>
-# include <stdint.h>
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-void luma__checkdispsrv(uint32_t * retval) {
- retval = 0x0;
- char const * sesstype = getenv("XDG_SESSION_TYPE");
- if(strncmp(sesstype,"wayland",0x10)) {
- luma__dat.dispsrv = "wayland";
- }
- else if(strncmp(sesstype,"x11",0x10)) {
- luma__dat.dispsrv = "x";
- }
- else {
- printf("Environment variable $XDG_SESSION_TYPE is \"%s\", which is not understood.\n");
- *retval = 0x1;
- }
-}
diff --git a/include/luma/main.h b/include/luma/main.h
deleted file mode 100644
index 960ece1..0000000
--- a/include/luma/main.h
+++ /dev/null
@@ -1,32 +0,0 @@
-# if !defined(LUMA__HEADER__MAIN)
-# if (!defined(__STDC_VERSION__) && (__STDC_VERSION__ <= 201710L))
-# error The compiler seems to not have support for C17 or newer (__STDC_VERSION__ is less than 201710L), which is required to build Luma.
-# endif
-# define LUMA__HEADER__MAIN
-# define _ATFILE_SOURCE
-# define _FORTIFY_SOURCE 2
-# define _LARGEFILE_SOURCE
-# define _LARGEFILE64_SOURCE
-# define _ISOC99_SOURCE
-# define _ISOC11_SOURCE
-# define _ISOC2X_SOURCE
-# define _POSIX_C_SOURCE 200809L
-# define _XOPEN_SOURCE
-# define _XOPEN_SOURCE_EXTENDED
-# define __STDC_WANT_IEC_60559_BFP_EXT__
-# define __STDC_WANT_IEC_60559_FUNCS_EXT__
-# define __STDC_WANT_IEC_60559_TYPES_EXT__
-# define __STDC_WANT_LIB_EXT2__ 0x1
-# include <luma/stdlibsock.h>
-# include <luma/stdlibsock/gfx.h>
-# include <stdint.h>
-# include <xcb/xcb.h>
-struct luma__dat_t {
- char * dispsrv;
- xcb_connection_t * xconn;
- xcb_screen_t * xscrn;
- xcb_window_t xwin;
-};
-struct luma__dat_t extern luma__dat;
-void luma__initx(uint32_t * retval);
-# endif
diff --git a/include/luma/main.hh b/include/luma/main.hh
new file mode 100644
index 0000000..86b8e71
--- /dev/null
+++ b/include/luma/main.hh
@@ -0,0 +1,25 @@
+# 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.
+# endif
+# else
+# error The compiler appears to not support C++ at all (__cplusplus is not defined).
+# endif
+# define LUMA__HEADER__MAIN
+# include <cstdint>
+# include <luma/stdlibsock.hh>
+# include <luma/stdlibsock/gfx.hh>
+# include <string>
+# include <wayland-client.h>
+using namespace std::literals::string_literals;
+namespace luma {
+ class dat_t {
+ public:
+ char * dispsrv;
+ struct wl_display * wldisp;
+ };
+ luma::dat_t extern dat;
+ void initgfx(uint32_t * retval);
+}
+# endif
diff --git a/include/luma/stdlibsock.h b/include/luma/stdlibsock.hh
index 3224e09..3224e09 100644
--- a/include/luma/stdlibsock.h
+++ b/include/luma/stdlibsock.hh
diff --git a/include/luma/stdlibsock/gfx.h b/include/luma/stdlibsock/gfx.h
deleted file mode 100644
index bc36a07..0000000
--- a/include/luma/stdlibsock/gfx.h
+++ /dev/null
@@ -1,7 +0,0 @@
-# if !defined(LUMA__HEADER__STDLIBSOCK__GFX)
-# define LUMA__HEADER__STDLIBSOCK__GFX
-# include <stdbool.h>
-# include <stdint.h>
-uint8_t luma__stdlibsock__gfx__crtwin(char * nm, uint16_t pos_x, uint16_t pos_y, uint16_t res_x, uint16_t res_y, bool flscrn);
-void luma__stdlibsock__gfx__destwin(void);
-# endif
diff --git a/include/luma/stdlibsock/gfx.hh b/include/luma/stdlibsock/gfx.hh
new file mode 100644
index 0000000..a9d7805
--- /dev/null
+++ b/include/luma/stdlibsock/gfx.hh
@@ -0,0 +1,13 @@
+# if !defined(LUMA__HEADER__STDLIBSOCK__GFX)
+# define LUMA__HEADER__STDLIBSOCK__GFX
+# include <cstdint>
+# include <string>
+namespace luma {
+ namespace stdlibsock {
+ namespace gfx {
+ uint8_t crtwin(std::basic_string<char> nm, uint16_t pos_x, uint16_t pos_y, uint16_t res_x, uint16_t res_y, bool flscrn);
+ void destwin();
+ }
+ }
+}
+# endif
diff --git a/initgfx.cc b/initgfx.cc
new file mode 100644
index 0000000..8d9ef73
--- /dev/null
+++ b/initgfx.cc
@@ -0,0 +1,6 @@
+# include <luma/main.hh>
+# include <stdint.h>
+# include <stdio.h>
+# include <wayland-client.h>
+void luma::initgfx(uint32_t * retval) {
+}
diff --git a/initx.c b/initx.c
deleted file mode 100644
index 9e2b5d7..0000000
--- a/initx.c
+++ /dev/null
@@ -1,14 +0,0 @@
-# include <luma/main.h>
-# include <stdint.h>
-# include <stdio.h>
-# include <xcb/xcb.h>
-void luma__initx(uint32_t * retval) {
- if(luma__dat.xconn) {
- luma__dat.xconn = xcb_connect(NULL,NULL);
- }
- else {
- printf("luma__crtxconn called with a valid X connection!\n");
- *retval = 0x1;
- return;
- }
-}
diff --git a/main.c b/main.c
deleted file mode 100644
index 45241d7..0000000
--- a/main.c
+++ /dev/null
@@ -1,21 +0,0 @@
-# include <luma/main.h>
-# include <stdio.h>
-# include <stdlib.h>
-# include <unistd.h>
-struct luma__dat_t luma__dat;
-int main(int argc, char * * argv) {
- if(argc < 0x2) {
- printf("Missing argument \"file\".\n");
- exit(EXIT_FAILURE);
- }
- if((access(argv[0x1], F_OK) == 0)) {
- printf("\f");
- luma__initstdlib__gfx();
- luma__stdlibsock__gfx__crtwin("luma test",0x0,0x0,0x400,0x300,false);
- }
- else {
- printf("The file doesn't exist.\n");
- exit(EXIT_FAILURE);
- }
- exit(EXIT_SUCCESS);
-}
diff --git a/main.cc b/main.cc
new file mode 100644
index 0000000..773e0f4
--- /dev/null
+++ b/main.cc
@@ -0,0 +1,20 @@
+# include <cstdlib>
+# include <iostream>
+# include <luma/main.hh>
+# include <string>
+# include <unistd.h>
+luma::dat_t luma::dat;
+int main(int argc, char * * argv) {
+ if(argc < 0x2) {
+ std::cout << "Missing argument \"file\".\n";
+ exit(EXIT_FAILURE);
+ }
+ if((access(argv[0x1], F_OK) == 0)) {
+ luma::stdlibsock::gfx::crtwin("luma test"s,0x0,0x0,0x400,0x300,false);
+ }
+ else {
+ std::cout << "The file doesn't exist.\n";
+ exit(EXIT_FAILURE);
+ }
+ exit(EXIT_SUCCESS);
+}
diff --git a/stdlibsock/gfx/crtwin.c b/stdlibsock/gfx/crtwin.c
deleted file mode 100644
index 4ab2fcf..0000000
--- a/stdlibsock/gfx/crtwin.c
+++ /dev/null
@@ -1,28 +0,0 @@
-# include <luma/main.h>
-# include <stdint.h>
-# include <stdio.h>
-# include <string.h>
-# include <unistd.h>
-# include <xcb/xcb.h>
-# include <xcb/xcb_atom.h>
-uint8_t luma__stdlibsock__gfx__crtwin(char * nm,uint16_t pos_x,uint16_t pos_y,uint16_t res_x,uint16_t res_y,bool flscrn) {
- uint32_t retval = 0x0;
- if(flscrn) {
- printf("Fullscreen is not supported yet!\n");
- }
- if(strncmp(luma__dat.dispsrv,"wayland",0x10)) {
-
- }
- else if(strncmp(luma__dat.dispsrv,"x",0x10)) {
- luma__initx(&retval);
- 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,strlen(nm),nm);
- xcb_map_window(luma__dat.xconn,luma__dat.xwin);
- xcb_flush(luma__dat.xconn);
- sleep(0x6);
- xcb_disconnect(luma__dat.xconn);
- }
- return 0x0;
-}
diff --git a/stdlibsock/gfx/crtwin.cc b/stdlibsock/gfx/crtwin.cc
new file mode 100644
index 0000000..82f8cdc
--- /dev/null
+++ b/stdlibsock/gfx/crtwin.cc
@@ -0,0 +1,21 @@
+# include <cstdint>
+# include <iostream>
+# include <luma/main.hh>
+# include <string>
+# include <unistd.h>
+# 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) {
+ if(flscrn) {
+ std::cout << "Fullscreen is not supported yet!\n";
+ }
+ luma::dat.wldisp = wl_display_connect(NULL);
+ if(luma::dat.wldisp == nullptr) {
+ std::cout << "Unable to make a Wayland connection!\n";
+ }
+ else {
+ std::cout << "A Wayland connection has been made.\n";
+ }
+ ::sleep(0x6);
+ ::wl_display_disconnect(luma::dat.wldisp);
+ return 0x0;
+}
diff --git a/stdlibsock/gfx/destwin.c b/stdlibsock/gfx/destwin.c
deleted file mode 100644
index 4ccc013..0000000
--- a/stdlibsock/gfx/destwin.c
+++ /dev/null
@@ -1,2 +0,0 @@
-# include <luma/main.h>
-void destwin(void);
diff --git a/stdlibsock/gfx/destwin.cc b/stdlibsock/gfx/destwin.cc
new file mode 100644
index 0000000..3280d55
--- /dev/null
+++ b/stdlibsock/gfx/destwin.cc
@@ -0,0 +1,2 @@
+# include <luma/main.hh>
+void luma::stdlibsock::gfx::destwin();