Disabled GL extensions when rendering to offscreen contexts.

This commit is contained in:
leo 2012-06-26 00:20:05 +00:00
parent 79d8081373
commit ec6b87d8a9
4 changed files with 25 additions and 8 deletions

View file

@ -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;
}

View file

@ -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;
}
// =============================================================================

View file

@ -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);

View file

@ -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);