From 83b9722276ef7320fc6c405d02710adad64164fd Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 7 Feb 2013 20:17:53 +0000 Subject: [PATCH] win32-refine opengl init code --- desmume/src/windows/main.cpp | 4 +++- desmume/src/windows/ogl.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index bd80166a6..9ccd2f70d 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -1444,7 +1444,9 @@ struct GLDISPLAY { if(!initialize()) return false; } - wglMakeCurrent(privateDC,privateContext); + + if(wglGetCurrentContext() != privateContext) + wglMakeCurrent(privateDC,privateContext); return true; } diff --git a/desmume/src/windows/ogl.cpp b/desmume/src/windows/ogl.cpp index 9f5018db0..a1d24185f 100644 --- a/desmume/src/windows/ogl.cpp +++ b/desmume/src/windows/ogl.cpp @@ -103,6 +103,10 @@ static HWND main_hWND; static bool _begin() { + //wglMakeCurrent is slow in some environments. so, check if the desired context is already current + if(wglGetCurrentContext() == main_hRC) + return true; + if(!wglMakeCurrent(main_hDC, main_hRC)) return false; @@ -126,7 +130,7 @@ static bool makeBootstrapContext() //it seems we may have to specify some non-zero win int width, height; - width = height = 64; //something safe, but irrelevant + width = height = 512; //something safe, but irrelevant. just to be super-safe, lets try making it big enough for the pbuffer we'll make eventually HWND fakeWindow = CreateWindow("EDIT", 0, 0, 0, 0, width, height, 0, 0, 0, 0); main_hWND = fakeWindow; @@ -227,6 +231,9 @@ bool windows_opengl_init() main_hRC = hGlRc; oglAlreadyInit = true; oglrender_beginOpenGL = _begin; + + //use the new pbuffer context for further extension interrogation in shared opengl init + _begin(); return true; }