diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index de6fa4980..89a081623 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -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 diff --git a/desmume/src/windows/ogl.cpp b/desmume/src/windows/ogl.cpp index d714d540a..8e8945ef8 100644 --- a/desmume/src/windows/ogl.cpp +++ b/desmume/src/windows/ogl.cpp @@ -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; } diff --git a/desmume/src/windows/ogl.h b/desmume/src/windows/ogl.h index 2fd367359..4ed498f83 100644 --- a/desmume/src/windows/ogl.h +++ b/desmume/src/windows/ogl.h @@ -18,4 +18,4 @@ #pragma once bool windows_opengl_init(); -bool initContext(HWND hwnd, HGLRC *hRC, HDC *hdc); +bool initContext(HWND hwnd, HGLRC *hRC);