diff options
author | fclem <foucault.clem@gmail.com> | 2018-06-11 14:06:54 +0300 |
---|---|---|
committer | fclem <foucault.clem@gmail.com> | 2018-06-11 14:06:54 +0300 |
commit | 800c3c5ca581d5427c4270c60f022c3ccdd8b312 (patch) | |
tree | f7ce2cd068e84fa39702a444bf5f1f72f7da2165 /intern | |
parent | 5ad7bda45f32f1d258db4be815864aa56ff551f0 (diff) |
GHOST: WGL: Delay context initialization for offscreen contexts.
Same as 128926a41b368e166af63515370d9c9367e3dda2 but for windows.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_ContextWGL.cpp | 43 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextWGL.h | 2 |
2 files changed, 32 insertions, 13 deletions
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp index 18c7844ad7b..35ebb2c78af 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cpp +++ b/intern/ghost/intern/GHOST_ContextWGL.cpp @@ -145,6 +145,10 @@ GHOST_TSuccess GHOST_ContextWGL::getSwapInterval(int &intervalOut) GHOST_TSuccess GHOST_ContextWGL::activateDrawingContext() { + if (m_init == false) { + initContext(); + } + if (WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) { return GHOST_kSuccess; } @@ -958,8 +962,32 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() goto error; } + /* Only init the non-offscreen context directly */ + if (!create_hDC) { + initContext(); + + initClearGL(); + ::SwapBuffers(m_hDC); + } + + return GHOST_kSuccess; +error: + if (m_dummyPbuffer) { + if (m_hDC != NULL) + WIN32_CHK(::wglReleasePbufferDCARB(m_dummyPbuffer, m_hDC)); + + WIN32_CHK(::wglDestroyPbufferARB(m_dummyPbuffer)); + } + ::wglMakeCurrent(prevHDC, prevHGLRC); + return GHOST_kFailure; + +} + + +GHOST_TSuccess GHOST_ContextWGL::initContext() +{ if (!WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) { - goto error; + return GHOST_kFailure; } initContextGLEW(); @@ -973,8 +1001,7 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() glEnable(GL_POINT_SPRITE); } - initClearGL(); - ::SwapBuffers(m_hDC); + m_init = true; #ifndef NDEBUG const char *vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); @@ -989,16 +1016,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() #endif return GHOST_kSuccess; -error: - if (m_dummyPbuffer) { - if (m_hDC != NULL) - WIN32_CHK(::wglReleasePbufferDCARB(m_dummyPbuffer, m_hDC)); - - WIN32_CHK(::wglDestroyPbufferARB(m_dummyPbuffer)); - } - ::wglMakeCurrent(prevHDC, prevHGLRC); - return GHOST_kFailure; - } diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h index be9575844c9..b77a50ae23e 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.h +++ b/intern/ghost/intern/GHOST_ContextWGL.h @@ -140,6 +140,7 @@ private: bool needStencil, bool sRGB, int swapMethod); + GHOST_TSuccess initContext(); void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD); @@ -149,6 +150,7 @@ private: HWND m_hWnd; HDC m_hDC; + bool m_init; const int m_contextProfileMask; const int m_contextMajorVersion; |