win32-improve opengl display method, i hope.

This commit is contained in:
zeromus 2013-03-10 02:45:47 +00:00
parent eb67250f71
commit 7f7beb6027
3 changed files with 15 additions and 9 deletions

View File

@ -1433,7 +1433,7 @@ struct GLDISPLAY
{
//do we need to use another HDC?
if(init) return true;
init = initContext(MainWindow->getHWnd(),&privateContext, &privateDC);
init = initContext(MainWindow->getHWnd(),&privateContext);
return init;
}
@ -1441,8 +1441,6 @@ struct GLDISPLAY
{
if(!init) return;
wglDeleteContext(privateContext);
DeleteObject(privateDC);
privateDC = NULL;
privateContext = NULL;
init = false;
}
@ -1460,11 +1458,18 @@ struct GLDISPLAY
if(!initialize()) return false;
}
if(wglGetCurrentContext() != privateContext)
wglMakeCurrent(privateDC,privateContext);
privateDC = GetDC(MainWindow->getHWnd());
wglMakeCurrent(privateDC,privateContext);
return true;
}
void end()
{
wglMakeCurrent(NULL,privateContext);
ReleaseDC(MainWindow->getHWnd(),privateDC);
privateDC = NULL;
}
void showPage()
{
SwapBuffers(privateDC);
@ -1634,6 +1639,8 @@ static void OGL_DoDisplay()
glEnd();
gldisplay.showPage();
gldisplay.end();
}
//the directdraw final presentation portion of display, including rotating

View File

@ -63,10 +63,9 @@ int CheckHardwareSupport(HDC hdc)
return -1; // check error
}
bool initContext(HWND hwnd, HGLRC *hRC, HDC *hdc)
bool initContext(HWND hwnd, HGLRC *hRC)
{
*hRC = NULL;
*hdc = NULL;
HDC oglDC = GetDC (hwnd);
@ -91,7 +90,7 @@ bool initContext(HWND hwnd, HGLRC *hRC, HDC *hdc)
return false;
}
*hdc = oglDC;
wglMakeCurrent(NULL,NULL);
return true;
}

View File

@ -18,4 +18,4 @@
#pragma once
bool windows_opengl_init();
bool initContext(HWND hwnd, HGLRC *hRC, HDC *hdc);
bool initContext(HWND hwnd, HGLRC *hRC);