diff options
Diffstat (limited to 'old')
-rw-r--r-- | old/initgfx.cc | 52 | ||||
-rw-r--r-- | old/isvkphysdevvalid.cc | 5 | ||||
-rw-r--r-- | old/setdispsrvproto.cc | 35 | ||||
-rw-r--r-- | old/stdlibsock__gfx__crtwin.cc | 30 | ||||
-rw-r--r-- | old/stdlibsock__gfx__destwin.cc | 4 | ||||
-rw-r--r-- | old/termgfx.cc | 13 |
6 files changed, 139 insertions, 0 deletions
diff --git a/old/initgfx.cc b/old/initgfx.cc new file mode 100644 index 0000000..ffaf1e5 --- /dev/null +++ b/old/initgfx.cc @@ -0,0 +1,52 @@ +# include <luma/main.hh> +# include <vulkan/vulkan.h> +# include <wayland-client.h> +# include <xcb/xcb.h> +void luma::app_t::initgfx() { + this->gfxisinit = true; + // Determine if X should be used or if Wayland is da way. + this->setdispsrvproto(); + if(this->dispsrvproto == this->dispsrvproto_t::x) { + this->dbgmsg("Creating X connection... "); + this->xconn = xcb_connect(nullptr,nullptr); + this->xscrn = xcb_setup_roots_iterator(xcb_get_setup(this->xconn)).data; + this->xwin = xcb_generate_id(this->xconn); + this->dbgmsg("O.K.\n"); + } + else { + this->dbgmsg("Creating Wayland connection... "); + this->wldisp = wl_display_connect(nullptr); + if(this->wldisp == nullptr) { + this->dbgmsg("Error\n"); + } + else { + this->dbgmsg("O.K.\n"); + } + } + // Set data required by Vulkan. + this->vkappinf.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; + this->vkappinf.pApplicationName = "Luma Standard Library"; + this->vkappinf.pEngineName = "Luma Standard Library"; + this->vkinstcrtinf.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + this->vkinstcrtinf.pApplicationInfo = &this->vkappinf; + this->vkinstcrtinf.enabledLayerCount = 0x0; + this->dbgmsg("Creating Vulkan instance... "); + this->vkreslt = vkCreateInstance(&this->vkinstcrtinf,nullptr,&this->vkinst); + if(this->vkreslt == VK_SUCCESS) { + this->dbgmsg("O.K.\n"); + } + else { + this->dbgmsg("Error\n"); + } + int extcount = 0x0; + this->vkexts = std::vector<VkExtensionProperties>(extcount); + ::vkEnumerateInstanceExtensionProperties(nullptr,&extcount,this->vkexts.data()); + //this->dbgmsg(std::basic_string<char_t> {std::to_string(extcount) + " Vulkan extensions supported.\n"}.c_str()); + this->dbgmsg("The following Vulkan extensions are supported:\n"); + for(auto const & ext : this->vkexts) { + this->dbgmsg(ext.extensionName); + } + int devcount = 0x0; + ::vkEnumeratePhysicalDevices(this->vkinst,&devcount,this->vkphysdevs.data()); + //this->dbgmsg(std::basic_string<char> {std::to_string(devcount) + " Vulkan-compatible device(s) found.\n"}.c_str()); +} diff --git a/old/isvkphysdevvalid.cc b/old/isvkphysdevvalid.cc new file mode 100644 index 0000000..27a169b --- /dev/null +++ b/old/isvkphysdevvalid.cc @@ -0,0 +1,5 @@ +# include <luma/main.hh> +# include <vulkan/vulkan.h> +//isVulkanPhysicalDeviceValid +void luma::app_t::isvkphysdevvalid(VkPhysicalDevice & dev) { +} diff --git a/old/setdispsrvproto.cc b/old/setdispsrvproto.cc new file mode 100644 index 0000000..a423ccc --- /dev/null +++ b/old/setdispsrvproto.cc @@ -0,0 +1,35 @@ +# include <luma/main.hh> +void luma::app_t::setdispsrvproto() { + this->dispsrvproto = this->dispsrvproto_t::wayland; +# if 0 + char const * envval = this->getenv("LUMA__DISPSRVPROTO"); + if(envval != "") { + if(envval == "x") { + this->dbgmsg("Setting the display server protocol to X.\n"); + this->dispsrvproto = this->dispsrvproto_t::x; + } + else if(envval == "wayland") { + this->dbgmsg("Setting the display server protocol to Wayland.\n"); + this->dispsrvproto = this->dispsrvproto_t::wayland; + } + else { + //std::cerr << "$LUMA__DISPSRVPROTO is set to \"" + envval + "\", which is an unrecognized display server protocol.\n"; + } + } + else { + this->dbgmsg("Getting current display server protocol.\n"); + std::string xdgsesstype = std::getenv("XDG_SESSION_TYPE"); + if(xdgsesstype == "wayland") { + this->dbgmsg("It appears to be Wayland.\n"); + this->dispsrvproto = this->dispsrvproto_t::wayland; + } + else if(xdgsesstype == "x11") { + this->dbgmsg("It appears to be X.\n"); + this->dispsrvproto = this->dispsrvproto_t::x; + } + else { + this->dbgmsg("Error\n"); + } + } +# endif +} diff --git a/old/stdlibsock__gfx__crtwin.cc b/old/stdlibsock__gfx__crtwin.cc new file mode 100644 index 0000000..8ef4325 --- /dev/null +++ b/old/stdlibsock__gfx__crtwin.cc @@ -0,0 +1,30 @@ +# include <cstring> +# include <iostream> +# include <luma/main.hh> +# include <string> +# include <unistd.h> +# include <vulkan/vulkan.h> +# include <wayland-client.h> +# include <xcb/xcb.h> +# include <xcb/xcb_atom.h> +int luma::app_t::stdlibsock__gfx__crtwin(char const * nm, int pos_x, int pos_y, int res_x, int res_y, bool flscrn) { + if(!this->gfxisinit) { + this->initgfx(); + } + if(flscrn) { + std::cerr << "Fullscreen is not supported yet!\n"; + } + if(this->dispsrvproto == luma::dispsrvproto_t::wayland) { + } + else if(this->dispsrvproto == luma::dispsrvproto_t::x) { + this->dbgmsg("Creating X window... "); + ::xcb_create_window(this->xconn,XCB_COPY_FROM_PARENT,this->xwin,this->xscrn->root,pos_y,pos_x,res_x,res_y,0xa,XCB_WINDOW_CLASS_INPUT_OUTPUT,this->xscrn->root_visual,0x0,nullptr); + ::xcb_change_property(this->xconn,XCB_PROP_MODE_REPLACE,this->xwin,XCB_ATOM_WM_NAME,XCB_ATOM_STRING,0x8,nm.size(),nm.c_str()); + ::xcb_map_window(this->xconn,this->xwin); + ::xcb_flush(this->xconn); + this->dbgmsg("O.K.\n"); + } + ::sleep(0x6); + this->termgfx(); + return 0x0; +} diff --git a/old/stdlibsock__gfx__destwin.cc b/old/stdlibsock__gfx__destwin.cc new file mode 100644 index 0000000..c2445e4 --- /dev/null +++ b/old/stdlibsock__gfx__destwin.cc @@ -0,0 +1,4 @@ +# include <luma/main.hh> +void luma::app_t::stdlibsock__gfx__destwin() { + +} diff --git a/old/termgfx.cc b/old/termgfx.cc new file mode 100644 index 0000000..2897b13 --- /dev/null +++ b/old/termgfx.cc @@ -0,0 +1,13 @@ +# include <luma/main.hh> +# include <vulkan/vulkan.h> +# include <wayland-client.h> +# include <xcb/xcb.h> +void luma::app_t::termgfx() { + ::vkDestroyInstance(this->vkinst,nullptr); + if(this->dispsrvproto == this->dispsrvproto_t::x) { + ::xcb_disconnect(this->xconn); + } + else if(this->dispsrvproto == this->dispsrvproto_t::wayland) { + ::wl_display_disconnect(this->wldisp); + } +} |