diff --git a/common/opengl.cpp b/common/opengl.cpp index e9fb5cb2..976f4299 100755 --- a/common/opengl.cpp +++ b/common/opengl.cpp @@ -1081,7 +1081,8 @@ bool GL_Initialize(const char* LibraryName) // ============================================================================= // Extensions support -bool GL_VertexBufferObject = false; +bool GL_SupportsVertexBufferObject = false; +bool GL_UseVertexBufferObject = false; static bool GL_ExtensionSupported(const char* extension) { @@ -1119,7 +1120,7 @@ static bool GL_ExtensionSupported(const char* extension) } // Extensions can only be initialized if there's a current OpenGL context. -bool GL_InitializeExtensions() +void GL_InitializeExtensions() { if (GL_ExtensionSupported("GL_ARB_vertex_buffer_object")) { @@ -1135,8 +1136,6 @@ bool GL_InitializeExtensions() glGetBufferParameterivARB = (GLGETBUFFERPARAMETERIVARBPROC)Sys_GLGetExtension("glGetBufferParameterivARB"); glGetBufferPointervARB = (GLGETBUFFERPOINTERVARBPROC)Sys_GLGetExtension("glGetBufferPointervARB"); - GL_VertexBufferObject = true; + GL_SupportsVertexBufferObject = true; } - - return true; } diff --git a/common/opengl.h b/common/opengl.h index c0152436..94049134 100755 --- a/common/opengl.h +++ b/common/opengl.h @@ -19,12 +19,24 @@ bool GL_Initialize(const char* libname); void GL_Shutdown(); -bool GL_InitializeExtensions(); +void GL_InitializeExtensions(); + +extern bool GL_SupportsVertexBufferObject; +extern bool GL_UseVertexBufferObject; + +inline void GL_DisableVertexBufferObject() +{ + GL_UseVertexBufferObject = false; +} + +inline void GL_EnableVertexBufferObject() +{ + GL_UseVertexBufferObject = GL_SupportsVertexBufferObject; +} inline bool GL_HasVertexBufferObject() { - extern bool GL_VertexBufferObject; - return GL_VertexBufferObject; + return GL_UseVertexBufferObject; } // ============================================================================= diff --git a/win/Print.cpp b/win/Print.cpp index 30b4aed8..c2904fd3 100644 --- a/win/Print.cpp +++ b/win/Print.cpp @@ -188,6 +188,7 @@ static void PrintCatalogThread (CWnd* pParent, CFrameWndEx* pMainFrame) HGLRC hmemrc = wglCreateContext(pMemDC->GetSafeHdc()); // Setting up the current OpenGL context + GL_DisableVertexBufferObject(); wglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc); double aspect = (float)w/(float)h; glMatrixMode(GL_MODELVIEW); @@ -368,6 +369,7 @@ static void PrintCatalogThread (CWnd* pParent, CFrameWndEx* pMainFrame) free(previous); } + GL_EnableVertexBufferObject(); wglMakeCurrent(NULL, NULL); wglDeleteContext(hmemrc); SelectObject(pMemDC->GetSafeHdc(), hBmOld); @@ -568,6 +570,7 @@ static void PrintPiecesThread(void* pv) DescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); SetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd); HGLRC hmemrc = wglCreateContext(pMemDC->GetSafeHdc()); + GL_DisableVertexBufferObject(); wglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc); double aspect = (float)picw/(float)h; glMatrixMode(GL_MODELVIEW); @@ -766,6 +769,7 @@ static void PrintPiecesThread(void* pv) free(previous); } + GL_EnableVertexBufferObject(); wglMakeCurrent(NULL, NULL); wglDeleteContext(hmemrc); SelectObject(pMemDC->GetSafeHdc(), hBmOld); diff --git a/win/System.cpp b/win/System.cpp index 5fba0f56..a519c041 100644 --- a/win/System.cpp +++ b/win/System.cpp @@ -1433,6 +1433,7 @@ void* Sys_StartMemoryRender(int width, int height) SetPixelFormat(render->hdc, pixelformat, &pfd); render->hrc = wglCreateContext(render->hdc); wglMakeCurrent(render->hdc, render->hrc); + GL_DisableVertexBufferObject(); return render; } @@ -1441,6 +1442,7 @@ void Sys_FinishMemoryRender(void* param) { LC_RENDER* render = (LC_RENDER*)param; + GL_EnableVertexBufferObject(); wglMakeCurrent (render->oldhdc, render->oldhrc); wglDeleteContext(render->hrc); SelectObject(render->hdc, render->oldhbm);