win32-improve opengl display method, i hope.
This commit is contained in:
parent
eb67250f71
commit
7f7beb6027
|
@ -1433,7 +1433,7 @@ struct GLDISPLAY
|
||||||
{
|
{
|
||||||
//do we need to use another HDC?
|
//do we need to use another HDC?
|
||||||
if(init) return true;
|
if(init) return true;
|
||||||
init = initContext(MainWindow->getHWnd(),&privateContext, &privateDC);
|
init = initContext(MainWindow->getHWnd(),&privateContext);
|
||||||
return init;
|
return init;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1441,8 +1441,6 @@ struct GLDISPLAY
|
||||||
{
|
{
|
||||||
if(!init) return;
|
if(!init) return;
|
||||||
wglDeleteContext(privateContext);
|
wglDeleteContext(privateContext);
|
||||||
DeleteObject(privateDC);
|
|
||||||
privateDC = NULL;
|
|
||||||
privateContext = NULL;
|
privateContext = NULL;
|
||||||
init = false;
|
init = false;
|
||||||
}
|
}
|
||||||
|
@ -1460,11 +1458,18 @@ struct GLDISPLAY
|
||||||
if(!initialize()) return false;
|
if(!initialize()) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(wglGetCurrentContext() != privateContext)
|
privateDC = GetDC(MainWindow->getHWnd());
|
||||||
wglMakeCurrent(privateDC,privateContext);
|
wglMakeCurrent(privateDC,privateContext);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void end()
|
||||||
|
{
|
||||||
|
wglMakeCurrent(NULL,privateContext);
|
||||||
|
ReleaseDC(MainWindow->getHWnd(),privateDC);
|
||||||
|
privateDC = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void showPage()
|
void showPage()
|
||||||
{
|
{
|
||||||
SwapBuffers(privateDC);
|
SwapBuffers(privateDC);
|
||||||
|
@ -1634,6 +1639,8 @@ static void OGL_DoDisplay()
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
gldisplay.showPage();
|
gldisplay.showPage();
|
||||||
|
|
||||||
|
gldisplay.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
//the directdraw final presentation portion of display, including rotating
|
//the directdraw final presentation portion of display, including rotating
|
||||||
|
|
|
@ -63,10 +63,9 @@ int CheckHardwareSupport(HDC hdc)
|
||||||
return -1; // check error
|
return -1; // check error
|
||||||
}
|
}
|
||||||
|
|
||||||
bool initContext(HWND hwnd, HGLRC *hRC, HDC *hdc)
|
bool initContext(HWND hwnd, HGLRC *hRC)
|
||||||
{
|
{
|
||||||
*hRC = NULL;
|
*hRC = NULL;
|
||||||
*hdc = NULL;
|
|
||||||
|
|
||||||
HDC oglDC = GetDC (hwnd);
|
HDC oglDC = GetDC (hwnd);
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ bool initContext(HWND hwnd, HGLRC *hRC, HDC *hdc)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*hdc = oglDC;
|
wglMakeCurrent(NULL,NULL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
bool windows_opengl_init();
|
bool windows_opengl_init();
|
||||||
bool initContext(HWND hwnd, HGLRC *hRC, HDC *hdc);
|
bool initContext(HWND hwnd, HGLRC *hRC);
|
||||||
|
|
Loading…
Reference in New Issue