diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-01-23 13:12:11 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-01-23 13:12:11 +0100 |
commit | 8dad985328e2183b224300aa992951131956fdb3 (patch) | |
tree | ceda3d9805335f36f571fb36585444ebdb421a02 /modules/window-opengl/gl_xcb.hpp | |
parent | a9d2025030d0a7641f4b0701bd4aff7d2db5aeb4 (diff) |
core,codec-json,codec-minecraft,codec-netcdf,codec,io-tls,io,io_codec,window,window-opengl:
Renamed file endings and changed includes
Diffstat (limited to 'modules/window-opengl/gl_xcb.hpp')
-rw-r--r-- | modules/window-opengl/gl_xcb.hpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/modules/window-opengl/gl_xcb.hpp b/modules/window-opengl/gl_xcb.hpp new file mode 100644 index 0000000..a737e41 --- /dev/null +++ b/modules/window-opengl/gl_xcb.hpp @@ -0,0 +1,68 @@ +#pragma once + +#include <forstio/window/xcb.h> + +#ifndef SAW_OGL +#error "OpenGL is not supported" +#endif + +#include "gl_backends.hpp +#include "gl_context.hpp +#include "gl_window.hpp + +#include <GL/glx.h> + +namespace saw { +namespace gfx { + +struct glx_library_extensions { +public: + std::string_view raw_extension_string; + GLXContext (*glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext, Bool, const int*) = nullptr; +}; + +template<> +class gpu_context<backend::gl_linux_xcb> final { +private: + glx_library_extensions ext_lib_; + own<device<backend::linux_xcb>> device_; + int visual_id_; + GLXContext context_; + GLXFBConfig fb_config_; + + friend class gpu_window<backend::gl_linux_xcb>; +public: + gpu_context(const glx_library_extensions&, own<device<backend::linux_xcb>>, int, GLXContext, GLXFBConfig); + ~gpu_context(); + + own<gpu_window<backend::gl_linux_xcb>> create_window(const video_mode&, std::string_view); + + void flush(); +}; + +template<> +class gpu_window<backend::gl_linux_xcb> final { +private: + own<window<backend::linux_xcb>> window_; + gpu_context<backend::gl_linux_xcb>* context_; + + ::GLXWindow glx_window_handle_; +public: + gpu_window(own<window<backend::linux_xcb>> window, gpu_context<backend::gl_linux_xcb>& ctx, + ::GLXWindow); + ~gpu_window(); + + void bind(); + void swap(); + void show(); + void hide(); + + const video_mode& get_video_mode() const; + const std::string_view get_title() const; + + void resize(size_t height, size_t width); + + conveyor<data<schema::WindowEvents>> on_event(); +}; +} +} |