[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - include/vcl vcl/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Fri Oct 31 11:19:16 PDT 2014


 include/vcl/opengl/OpenGLContext.hxx |    2 ++
 vcl/source/opengl/OpenGLContext.cxx  |   21 +++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 37b4f3b9b7bf801a06d03b601d8c700e9cb830a1
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Fri Oct 31 19:19:47 2014 +0100

    first step at optional single buffered OpenGL rendering
    
    Change-Id: I064de6ca7d40b8e6e378a01dd39a6cd09f040b68

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 91b54e4..1692ba0 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -155,6 +155,7 @@ public:
     ~OpenGLContext();
 
     void requestLegacyContext();
+    void requestSingleBufferedRendering();
 
     bool init(vcl::Window* pParent = 0);
     bool init(SystemChildWindow* pChildWindow);
@@ -207,6 +208,7 @@ private:
     boost::scoped_ptr<SystemChildWindow> m_pChildWindowGC;
     bool mbInitialized;
     bool mbRequestLegacyContext;
+    bool mbUseDoubleBufferedRendering;
 };
 
 #endif
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index c6ab13c..5943532 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -36,7 +36,8 @@ OpenGLContext::OpenGLContext():
     mpWindow(NULL),
     m_pChildWindow(NULL),
     mbInitialized(false),
-    mbRequestLegacyContext(false)
+    mbRequestLegacyContext(false),
+    mbUseDoubleBufferedRendering(true)
 {
 }
 
@@ -71,6 +72,11 @@ void OpenGLContext::requestLegacyContext()
     mbRequestLegacyContext = true;
 }
 
+void OpenGLContext::requestSingleBufferedRendering()
+{
+    mbUseDoubleBufferedRendering = false;
+}
+
 #if defined( _WIN32 )
 static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
@@ -213,6 +219,7 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat)
     // We Support Multisampling On This Hardware.
     int iAttributes[] =
     {
+        WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
         WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
         WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
         WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
@@ -220,12 +227,14 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat)
         WGL_ALPHA_BITS_ARB,8,
         WGL_DEPTH_BITS_ARB,24,
         WGL_STENCIL_BITS_ARB,0,
-        WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
         WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,
         WGL_SAMPLES_ARB,8,
         0,0
     };
 
+    if (!mbUseDoubleBufferedRendering)
+        iAttributes[1] = GL_FALSE;
+
     bool bArbMultisampleSupported = true;
 
     // First We Check To See If We Can Get A Pixel Format For 4 Samples
@@ -370,7 +379,7 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ )
 }
 
 #ifdef DBG_UTIL
-GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC)
+GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC, bool bUseDoubleBufferedRendering)
 {
     if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) )
         return NULL;
@@ -395,6 +404,10 @@ GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC)
         GLX_X_VISUAL_TYPE,      GLX_TRUE_COLOR,
         None
     };
+
+    if (!bUseDoubleBufferedRendering)
+        visual_attribs[1] = False;
+
     int fbCount = 0;
     GLXFBConfig* pFBC = glXChooseFBConfig( dpy,
             screen,
@@ -530,7 +543,7 @@ bool OpenGLContext::ImplInit()
     if (glXCreateContextAttribsARB && !mbRequestLegacyContext)
     {
         int best_fbc = -1;
-        GLXFBConfig* pFBC = getFBConfig(m_aGLWin.dpy, m_aGLWin.win, best_fbc);
+        GLXFBConfig* pFBC = getFBConfig(m_aGLWin.dpy, m_aGLWin.win, best_fbc, mbUseDoubleBufferedRendering);
         if (!pFBC)
             return false;
 


More information about the Libreoffice-commits mailing list