From b49d590153658e77d284e0b87d3cabe65fd37730 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 9 Aug 2023 20:25:16 +0200 Subject: c++,window-opengl: Initial module commit --- c++/window-opengl/gl_xcb.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 c++/window-opengl/gl_xcb.h (limited to 'c++/window-opengl/gl_xcb.h') diff --git a/c++/window-opengl/gl_xcb.h b/c++/window-opengl/gl_xcb.h new file mode 100644 index 0000000..128733b --- /dev/null +++ b/c++/window-opengl/gl_xcb.h @@ -0,0 +1,65 @@ +#pragma once + +#include + +#ifndef SAW_OGL +#error "OpenGL is not supported" +#endif + +#include "gl_backends.h" + +#include + +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 gl_context final { +private: + glx_library_extensions ext_lib_; + own> device_; + int visual_id_; + GLXContext context_; + GLXFBConfig fb_config_; +public: + gl_context(const glx_library_extensions&, own>, int, GLXContext, GLXFBConfig); + ~gl_context(); + + own> create_window(const video_mode&, std::string_view); + + void flush(); +}; + +template<> +class gl_window final { +private: + own> window_; + gl_context* context_; + + ::GLXWindow glx_window_handle_; + +public: + gl_window(own> window, gl_context& ctx, + ::GLXWindow); + ~gl_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> on_event(); +}; +} +} -- cgit v1.2.3