summaryrefslogtreecommitdiff
path: root/c++
diff options
context:
space:
mode:
Diffstat (limited to 'c++')
-rw-r--r--c++/window-opengl/.nix/derivation.nix2
-rw-r--r--c++/window-opengl/SConstruct2
-rw-r--r--c++/window-opengl/gl_context.h3
-rw-r--r--c++/window-opengl/gl_window.h1
-rw-r--r--c++/window-opengl/gl_xcb.cpp34
-rw-r--r--c++/window-opengl/gl_xcb.h2
-rw-r--r--c++/window/xcb.h10
7 files changed, 35 insertions, 19 deletions
diff --git a/c++/window-opengl/.nix/derivation.nix b/c++/window-opengl/.nix/derivation.nix
index 95cd318..95ef1e8 100644
--- a/c++/window-opengl/.nix/derivation.nix
+++ b/c++/window-opengl/.nix/derivation.nix
@@ -6,6 +6,7 @@
, version
, forstio
, xorg
+, libGL
}:
let
@@ -31,6 +32,7 @@ in stdenvNoCC.mkDerivation {
forstio.window
xorg.libX11
xorg.libxcb
+ libGL
];
outputs = ["out" "dev"];
diff --git a/c++/window-opengl/SConstruct b/c++/window-opengl/SConstruct
index 05fc016..42fb205 100644
--- a/c++/window-opengl/SConstruct
+++ b/c++/window-opengl/SConstruct
@@ -44,7 +44,7 @@ env_vars.Add('prefix',
)
env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[],
- CPPDEFINES=['SAW_UNIX', 'SAW_UNIX_XCB'],
+ CPPDEFINES=['SAW_UNIX', 'SAW_UNIX_XCB', 'SAW_OGL'],
CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'],
LIBS=['forstio-core', 'forstio-io', 'forstio-async', 'forstio-codec'])
env.__class__.add_source_files = add_kel_source_files
diff --git a/c++/window-opengl/gl_context.h b/c++/window-opengl/gl_context.h
index 8821650..9f684fb 100644
--- a/c++/window-opengl/gl_context.h
+++ b/c++/window-opengl/gl_context.h
@@ -3,6 +3,7 @@
namespace saw {
namespace gfx {
class gl_settings {
+public:
uint8_t gl_major = 3;
uint8_t gl_minor = 3;
@@ -20,7 +21,7 @@ class gl_settings {
pbuffer_bit = 0x04
};
- drawable_type drawable_t = drawable_type.:window_bit;
+ drawable_type drawable_t = drawable_type::window_bit;
bool double_buffer = true;
int red_bits = 8;
diff --git a/c++/window-opengl/gl_window.h b/c++/window-opengl/gl_window.h
index e4ee6aa..55012f4 100644
--- a/c++/window-opengl/gl_window.h
+++ b/c++/window-opengl/gl_window.h
@@ -2,6 +2,7 @@
namespace saw {
namespace gfx {
+template<typename T>
class gl_window;
}
}
diff --git a/c++/window-opengl/gl_xcb.cpp b/c++/window-opengl/gl_xcb.cpp
index f93e9a9..18ce1cf 100644
--- a/c++/window-opengl/gl_xcb.cpp
+++ b/c++/window-opengl/gl_xcb.cpp
@@ -27,8 +27,8 @@ glx_library_extensions load_glx_library_extensions(const char* extension_string)
GLXContext (*glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext, Bool, const int*) = nullptr;
if(find != extensions.end()){
glXCreateContextAttribsARB = reinterpret_cast<GLXContext(*)(
- Display*, GLXConfig, GLXContext, Bool, const int*)>(
- glxGetProcAddress(reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB")));
+ Display*, GLXFBConfig, GLXContext, Bool, const int*)>(
+ glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB")));
}
return {extensions_view, glXCreateContextAttribsARB};
@@ -45,15 +45,15 @@ int translate_render_type_settings(gl_settings::render_type cmp){
int translate_drawable_type_setting(gl_settings::drawable_type cmp){
int i = 0;
if (static_cast<int32_t>(cmp) &
- static_cast<int32_t>(GlSettings::DrawableType::windowBit)) {
+ static_cast<int32_t>(gl_settings::drawable_type::window_bit)) {
i |= static_cast<int32_t>(GLX_WINDOW_BIT);
}
if (static_cast<int32_t>(cmp) &
- static_cast<int32_t>(GlSettings::DrawableType::PixMapBit)) {
+ static_cast<int32_t>(gl_settings::drawable_type::pixmap_bit)) {
i |= static_cast<int32_t>(GLX_PIXMAP_BIT);
}
if (static_cast<int32_t>(cmp) &
- static_cast<int32_t>(GlSettings::DrawableType::PBufferBit)) {
+ static_cast<int32_t>(gl_settings::drawable_type::pbuffer_bit)) {
i |= static_cast<int32_t>(GLX_PBUFFER_BIT);
}
return i;
@@ -61,16 +61,16 @@ int translate_drawable_type_setting(gl_settings::drawable_type cmp){
}
gl_context<gl::backend::linux_xcb>::gl_context(const glx_library_extensions& ext_lib,
- own<device<backend::linux_xcb>> dev, int visual_id, GLXContext context, GLXFBConfig fb_config): ext_lib_{ext_lib}, device_{std::move(device)}, visual_id_{visual_id}, context_{context}, fb_config_{fb_config}{}
+ own<device<backend::linux_xcb>> dev, int visual_id, GLXContext context, GLXFBConfig fb_config): ext_lib_{ext_lib}, device_{std::move(dev)}, visual_id_{visual_id}, context_{context}, fb_config_{fb_config}{}
gl_context<gl::backend::linux_xcb>::~gl_context(){
assert(device_);
- assert(device_->display_);
+ assert(device_->get_xcb_display());
if(context_){
/// @todo Check if this context is bound and only unbind if that is the case
- // ::glXMakeContextCurrent(device_->display_, None, None, nullptr);
- ::glXMakeDestroyContext(device_->display_, context_);
+ // ::glXMakeContextCurrent(device_->get_xcb_display(), None, None, nullptr);
+ ::glXMakeDestroyContext(device_->get_xcb_display(), context_);
}
device_->flush();
}
@@ -86,7 +86,7 @@ own<gl_window<gl::backnd::linux_xcb>> gl_context<gl::backend::linux_xcb>::create
return nullptr;
}
- ::GLXWindow glx_win = glXCreateWindow(device_->display_, fb_config_, win->xcb_window_, nullptr);
+ ::GLXWindow glx_win = glXCreateWindow(device_->get_xcb_display(), fb_config_, win->xcb_window_, nullptr);
return heap<gl_window<gl::backend::linux_xcb>>(std::move(win), *this, glx_win);
}
@@ -199,15 +199,15 @@ gl_window<gl::backend::linux_xcb>::gl_window(own<xcb_window> &&win, gl_context<g
gl_window<gl::backend::linux_xcb>::~gl_window() {
assert(context.device);
if (context.device) {
- ::glXDestroyWindow(context_->device_->display, glx_window_);
+ ::glXDestroyWindow(context_->device_->get_xcb_display(), glx_window_);
}
}
void gl_window<gl::backend::linux_xcb>::bind() {
- assert(window_ && context_->device && context_->device_->display);
+ assert(window_ && context_->device && context_->device_->get_xcb_display());
if (window) {
- if (context_->device_ && context_->device_->display) {
- ::glXMakeContextCurrent(context_->device_->display, glx_window_,
+ if (context_->device_ && context_->device_->get_xcb_display()) {
+ ::glXMakeContextCurrent(context_->device_->get_xcb_display(), glx_window_,
glx_window_, context_->context);
}
}
@@ -229,9 +229,9 @@ void gl_window<gl::backend::linux_xcb>::hide() {
void gl_window<gl::backend::linux_xcb>::swap() {
assert(context_->device_);
- assert(context_->device_->display);
- if (context_->device && context_->device_->display) {
- ::glXSwapBuffers(context_->device_->display, glx_window_);
+ assert(context_->device_->get_xcb_display());
+ if (context_->device && context_->device_->get_xcb_display()) {
+ ::glXSwapBuffers(context_->device_->get_xcb_display(), glx_window_);
}
}
diff --git a/c++/window-opengl/gl_xcb.h b/c++/window-opengl/gl_xcb.h
index 128733b..d89541d 100644
--- a/c++/window-opengl/gl_xcb.h
+++ b/c++/window-opengl/gl_xcb.h
@@ -7,6 +7,8 @@
#endif
#include "gl_backends.h"
+#include "gl_context.h"
+#include "gl_window.h"
#include <GL/glx.h>
diff --git a/c++/window/xcb.h b/c++/window/xcb.h
index 612b6ed..0457b58 100644
--- a/c++/window/xcb.h
+++ b/c++/window/xcb.h
@@ -52,6 +52,16 @@ public:
own<window<backend::linux_xcb>> create_window(const video_mode& vid_mod, std::string_view title_view);
void flush();
+
+ // XCB specific info for other classes
+
+ ::Display* get_xcb_display() {
+ return display_;
+ }
+
+ int get_xcb_screen() const {
+ return screen_;
+ }
};
error_or<own<device<backend::linux_xcb>>> create_xcb_device(io_provider& provider);