diff options
Diffstat (limited to 'c++/window-opengl')
-rw-r--r-- | c++/window-opengl/gl_backends.h | 6 | ||||
-rw-r--r-- | c++/window-opengl/gl_window.h | 2 | ||||
-rw-r--r-- | c++/window-opengl/gl_xcb.cpp | 34 | ||||
-rw-r--r-- | c++/window-opengl/gl_xcb.h | 17 |
4 files changed, 28 insertions, 31 deletions
diff --git a/c++/window-opengl/gl_backends.h b/c++/window-opengl/gl_backends.h index 0af10fc..652954f 100644 --- a/c++/window-opengl/gl_backends.h +++ b/c++/window-opengl/gl_backends.h @@ -2,11 +2,9 @@ namespace saw { namespace gfx { -namespace gl { namespace backend { -struct linux_xcb {}; -struct wasm {}; -} +struct gl_linux_xcb {}; +struct gl_wasm {}; } } } diff --git a/c++/window-opengl/gl_window.h b/c++/window-opengl/gl_window.h index 55012f4..3bb9f83 100644 --- a/c++/window-opengl/gl_window.h +++ b/c++/window-opengl/gl_window.h @@ -3,6 +3,6 @@ namespace saw { namespace gfx { template<typename T> -class gl_window; +class gpu_window; } } diff --git a/c++/window-opengl/gl_xcb.cpp b/c++/window-opengl/gl_xcb.cpp index 41c262a..5babaf2 100644 --- a/c++/window-opengl/gl_xcb.cpp +++ b/c++/window-opengl/gl_xcb.cpp @@ -60,10 +60,10 @@ int translate_drawable_type_setting(gl_settings::drawable_type cmp){ } } -gl_context<gl::backend::linux_xcb>::gl_context(const glx_library_extensions& ext_lib, +gpu_context<backend::gl_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(dev)}, visual_id_{visual_id}, context_{context}, fb_config_{fb_config}{} -gl_context<gl::backend::linux_xcb>::~gl_context(){ +gpu_context<backend::gl_linux_xcb>::~gl_context(){ assert(device_); assert(device_->get_xcb_display()); @@ -75,7 +75,7 @@ gl_context<gl::backend::linux_xcb>::~gl_context(){ device_->flush(); } -own<gl_window<gl::backend::linux_xcb>> gl_context<gl::backend::linux_xcb>::create_window(const video_mode& vid_mode, std::string_view title_view){ +own<gpu_window<backend::gl_linux_xcb>> gpu_context<backend::gl_linux_xcb>::create_window(const video_mode& vid_mode, std::string_view title_view){ SAW_ASSERT(device_){ return nullptr; @@ -87,17 +87,17 @@ own<gl_window<gl::backend::linux_xcb>> gl_context<gl::backend::linux_xcb>::creat } ::GLXWindow glx_win = glXCreateWindow(device_->get_xcb_display(), fb_config_, win->get_xcb_window_handle(), nullptr); - return heap<gl_window<gl::backend::linux_xcb>>(std::move(win), *this, glx_win); + return heap<gpu_window<backend::gl_linux_xcb>>(std::move(win), *this, glx_win); } -void gl_context<gl::backend::linux_xcb>::flush(){ +void gpu_context<backend::gl_linux_xcb>::flush(){ assert(device_); if(device_){ device_->flush(); } } -own<gl_context<gl::backend::linux_xcb> > create_gl_context(io_provider& prov, const gl_settings& settings){ +own<gpu_context<backend::gl_linux_xcb> > create_gl_context(io_provider& prov, const gl_settings& settings){ own<device<backend::linux_xcb>> device = create_xcb_device(prov); if (!device) { return nullptr; @@ -185,25 +185,25 @@ own<gl_context<gl::backend::linux_xcb> > create_gl_context(io_provider& prov, co int visual_id = 0; glXGetFBConfigAttrib(device->display, fb_config, GLX_VISUAL_ID, &visual_id); - return heap<xcb_gl_context>(lib_ext, std::move(device), visual_id, + return heap<xcb_gpu_context>(lib_ext, std::move(device), visual_id, context, fb_config); } return nullptr; } -gl_window<gl::backend::linux_xcb>::gl_window(own<xcb_window> &&win, gl_context<gl::backend::linux_xcb> &ctx, +gpu_window<backend::gl_linux_xcb>::gpu_window(own<xcb_window> &&win, gpu_context<backend::gl_linux_xcb> &ctx, ::GLXWindow glx_win) : window_{std::move(win)}, context_{&ctx}, glx_window_handle_{glx_win} {} -gl_window<gl::backend::linux_xcb>::~gl_window() { +gpu_window<backend::gl_linux_xcb>::~gpu_window() { assert(context.device); if (context.device) { ::glXDestroyWindow(context_->device_->get_xcb_display(), glx_window_); } } -void gl_window<gl::backend::linux_xcb>::bind() { +void gpu_window<backend::gl_linux_xcb>::bind() { assert(window_ && context_->device && context_->device_->get_xcb_display()); if (window) { if (context_->device_ && context_->device_->get_xcb_display()) { @@ -213,21 +213,21 @@ void gl_window<gl::backend::linux_xcb>::bind() { } } -void gl_window<gl::backend::linux_xcb>::show() { +void gpu_window<backend::gl_linux_xcb>::show() { assert(window_); if (window_) { window->show(); } } -void gl_window<gl::backend::linux_xcb>::hide() { +void gpu_window<backend::gl_linux_xcb>::hide() { assert(window_); if (window_) { window->hide(); } } -void gl_window<gl::backend::linux_xcb>::swap() { +void gpu_window<backend::gl_linux_xcb>::swap() { assert(context_->device_); assert(context_->device_->get_xcb_display()); if (context_->device && context_->device_->get_xcb_display()) { @@ -235,12 +235,12 @@ void gl_window<gl::backend::linux_xcb>::swap() { } } -const video_mode &gl_window<gl::backend::linux_xcb>::get_video_mode() const { +const video_mode &gpu_window<backend::gl_linux_xcb>::get_video_mode() const { assert(window_); return window_->get_video_mode(); } -const std::string_view gl_window<gl::backend::linux_xcb>::title() const { +const std::string_view gpu_window<backend::gl_linux_xcb>::title() const { assert(window_); if (window_) { return window_->get_title(); @@ -249,14 +249,14 @@ const std::string_view gl_window<gl::backend::linux_xcb>::title() const { return "Bad window"; } -void gl_window<gl::backend::linux_xcb>::resize(size_t height, size_t width) { +void gpu_window<backend::gl_linux_xcb>::resize(size_t height, size_t width) { assert(window_); if (window_) { window->resize(height, width); } } -conveyor<window::variant_event> gl_window<gl::backend::linux_xcb>::on_event() { +conveyor<window::variant_event> gpu_window<backend::gl_linux_xcb>::on_event() { assert(window_); return window_->on_event(); } diff --git a/c++/window-opengl/gl_xcb.h b/c++/window-opengl/gl_xcb.h index d89541d..f7f5d6a 100644 --- a/c++/window-opengl/gl_xcb.h +++ b/c++/window-opengl/gl_xcb.h @@ -22,7 +22,7 @@ public: }; template<> -class gl_context<gl::backend::linux_xcb> final { +class gpu_context<backend::gl_linux_xcb> final { private: glx_library_extensions ext_lib_; own<device<backend::linux_xcb>> device_; @@ -30,26 +30,25 @@ private: GLXContext context_; GLXFBConfig fb_config_; public: - gl_context(const glx_library_extensions&, own<device<backend::linux_xcb>>, int, GLXContext, GLXFBConfig); - ~gl_context(); + gpu_context(const glx_library_extensions&, own<device<backend::linux_xcb>>, int, GLXContext, GLXFBConfig); + ~gpu_context(); - own<gl_window<gl::backend::linux_xcb>> create_window(const video_mode&, std::string_view); + own<gpu_window<backend::gl_linux_xcb>> create_window(const video_mode&, std::string_view); void flush(); }; template<> -class gl_window<gl::backend::linux_xcb> final { +class gpu_window<backend::gl_linux_xcb> final { private: own<window<backend::linux_xcb>> window_; - gl_context<gl::backend::linux_xcb>* context_; + gpu_context<backend::gl_linux_xcb>* context_; ::GLXWindow glx_window_handle_; - public: - gl_window(own<window<backend::linux_xcb>> window, gl_context<gl::backend::linux_xcb>& ctx, + gpu_window(own<window<backend::linux_xcb>> window, gpu_context<backend::gl_linux_xcb>& ctx, ::GLXWindow); - ~gl_window(); + ~gpu_window(); void bind(); void swap(); |