From a2be67cbfaf20303704ec549313778729190d89b Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Mon, 23 Sep 2013 22:10:17 +0200 Subject: spicec: use doublebuffer for opengl This visually reduces glitches without noticeable speed difference. It's also the traditionnal way of doing opengl. --- client/red_window.h | 2 ++ client/screen.cpp | 1 + client/x11/platform.cpp | 2 +- client/x11/red_pixmap_gl.cpp | 2 -- client/x11/red_window.cpp | 12 ++++++++++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/client/red_window.h b/client/red_window.h index dbd0c797..bf59d8b8 100644 --- a/client/red_window.h +++ b/client/red_window.h @@ -82,6 +82,8 @@ public: void set_type_gl(); void unset_type_gl(); + + void swap_gl(); #endif int get_screen_num(); diff --git a/client/screen.cpp b/client/screen.cpp index a05d5620..e76fd50a 100644 --- a/client/screen.cpp +++ b/client/screen.cpp @@ -357,6 +357,7 @@ inline void RedScreen::update_done() } layer->on_update_completion(_update_mark - 1); } + _window.swap_gl(); } inline void RedScreen::update_composit(QRegion& composit_rgn) diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp index da6b6342..475ee6a9 100644 --- a/client/x11/platform.cpp +++ b/client/x11/platform.cpp @@ -3224,7 +3224,7 @@ void Platform::init() int num_configs; int attrlist[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DOUBLEBUFFER, False, + GLX_DOUBLEBUFFER, True, GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT | GLX_WINDOW_BIT, GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, GLX_RED_SIZE, 8, diff --git a/client/x11/red_pixmap_gl.cpp b/client/x11/red_pixmap_gl.cpp index 693b67d1..1a586286 100644 --- a/client/x11/red_pixmap_gl.cpp +++ b/client/x11/red_pixmap_gl.cpp @@ -79,8 +79,6 @@ RedPixmapGL::RedPixmapGL(int width, int height, RedDrawable::Format format, glXDestroyContext(XPlatform::get_display(), _glcont); THROW("no GL_EXT_framebuffer_object extension"); } - glDrawBuffer(GL_FRONT); - glReadBuffer(GL_FRONT); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp index 83144a54..b6e11e14 100644 --- a/client/x11/red_window.cpp +++ b/client/x11/red_window.cpp @@ -2122,6 +2122,18 @@ void RedWindow::untouch_context() glXMakeCurrent(x_display, 0, 0); } +void RedWindow::swap_gl() +{ + PixelsSource_p *pix_source = (PixelsSource_p*)get_opaque(); + RedGlContext context = pix_source->x_drawable.context; + + if (!context) + return; + + glXMakeCurrent(x_display, get_window(), context); + glXSwapBuffers(x_display, get_window()); +} + void RedWindow::set_type_gl() { PixelsSource_p *pix_source = (PixelsSource_p*)get_opaque(); -- cgit