Kaydet (Commit) 690de8a3 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

first step at optional single buffered OpenGL rendering

Change-Id: I064de6ca7d40b8e6e378a01dd39a6cd09f040b68
üst 4ec36db0
...@@ -155,6 +155,7 @@ public: ...@@ -155,6 +155,7 @@ public:
~OpenGLContext(); ~OpenGLContext();
void requestLegacyContext(); void requestLegacyContext();
void requestSingleBufferedRendering();
bool init(vcl::Window* pParent = 0); bool init(vcl::Window* pParent = 0);
bool init(SystemChildWindow* pChildWindow); bool init(SystemChildWindow* pChildWindow);
...@@ -207,6 +208,7 @@ private: ...@@ -207,6 +208,7 @@ private:
boost::scoped_ptr<SystemChildWindow> m_pChildWindowGC; boost::scoped_ptr<SystemChildWindow> m_pChildWindowGC;
bool mbInitialized; bool mbInitialized;
bool mbRequestLegacyContext; bool mbRequestLegacyContext;
bool mbUseDoubleBufferedRendering;
}; };
#endif #endif
......
...@@ -36,7 +36,8 @@ OpenGLContext::OpenGLContext(): ...@@ -36,7 +36,8 @@ OpenGLContext::OpenGLContext():
mpWindow(NULL), mpWindow(NULL),
m_pChildWindow(NULL), m_pChildWindow(NULL),
mbInitialized(false), mbInitialized(false),
mbRequestLegacyContext(false) mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true)
{ {
} }
...@@ -71,6 +72,11 @@ void OpenGLContext::requestLegacyContext() ...@@ -71,6 +72,11 @@ void OpenGLContext::requestLegacyContext()
mbRequestLegacyContext = true; mbRequestLegacyContext = true;
} }
void OpenGLContext::requestSingleBufferedRendering()
{
mbUseDoubleBufferedRendering = false;
}
#if defined( _WIN32 ) #if defined( _WIN32 )
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
...@@ -213,6 +219,7 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat) ...@@ -213,6 +219,7 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat)
// We Support Multisampling On This Hardware. // We Support Multisampling On This Hardware.
int iAttributes[] = int iAttributes[] =
{ {
WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
WGL_DRAW_TO_WINDOW_ARB,GL_TRUE, WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
WGL_SUPPORT_OPENGL_ARB,GL_TRUE, WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB, WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
...@@ -220,12 +227,14 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat) ...@@ -220,12 +227,14 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat)
WGL_ALPHA_BITS_ARB,8, WGL_ALPHA_BITS_ARB,8,
WGL_DEPTH_BITS_ARB,24, WGL_DEPTH_BITS_ARB,24,
WGL_STENCIL_BITS_ARB,0, WGL_STENCIL_BITS_ARB,0,
WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
WGL_SAMPLE_BUFFERS_ARB,GL_TRUE, WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,
WGL_SAMPLES_ARB,8, WGL_SAMPLES_ARB,8,
0,0 0,0
}; };
if (!mbUseDoubleBufferedRendering)
iAttributes[1] = GL_FALSE;
bool bArbMultisampleSupported = true; bool bArbMultisampleSupported = true;
// First We Check To See If We Can Get A Pixel Format For 4 Samples // 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*/ ) ...@@ -370,7 +379,7 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ )
} }
#ifdef DBG_UTIL #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 ) ) if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) )
return NULL; return NULL;
...@@ -395,6 +404,10 @@ GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC) ...@@ -395,6 +404,10 @@ GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC)
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
None None
}; };
if (!bUseDoubleBufferedRendering)
visual_attribs[1] = False;
int fbCount = 0; int fbCount = 0;
GLXFBConfig* pFBC = glXChooseFBConfig( dpy, GLXFBConfig* pFBC = glXChooseFBConfig( dpy,
screen, screen,
...@@ -530,7 +543,7 @@ bool OpenGLContext::ImplInit() ...@@ -530,7 +543,7 @@ bool OpenGLContext::ImplInit()
if (glXCreateContextAttribsARB && !mbRequestLegacyContext) if (glXCreateContextAttribsARB && !mbRequestLegacyContext)
{ {
int best_fbc = -1; 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) if (!pFBC)
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment