+ // create temporary context to retrieve advanced context creation procedures
+ HMODULE aModule = GetModuleHandleW(NULL);
+ WNDCLASSW aClass; memset (&aClass, 0, sizeof(aClass));
+ aClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ aClass.lpfnWndProc = wndProcDummy;
+ aClass.hInstance = aModule;
+ aClass.lpszClassName = L"OpenGl_WindowTmp";
+ HWND aWinTmp = NULL;
+ HDC aDevCtxTmp = NULL;
+ HGLRC aRendCtxTmp = NULL;
+ if (!theCaps->contextDebug
+ || RegisterClassW (&aClass) == 0)
+ {
+ aClass.lpszClassName = NULL;
+ }
+ if (aClass.lpszClassName != NULL)
+ {
+ aWinTmp = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE,
+ aClass.lpszClassName, L"OpenGl_WindowTmp",
+ WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_DISABLED,
+ 2, 2, 4, 4,
+ NULL, NULL, aModule, NULL);
+ }
+ if (aWinTmp != NULL)
+ {
+ aDevCtxTmp = GetDC (aWinTmp);
+ SetPixelFormat (aDevCtxTmp, aPixelFrmtId, &aPixelFrmt);
+ aRendCtxTmp = wglCreateContext (aDevCtxTmp);
+ }
+ if (aRendCtxTmp != NULL)
+ {
+ wglMakeCurrent (aDevCtxTmp, aRendCtxTmp);
+
+ typedef const char* (WINAPI *wglGetExtensionsStringARB_t)(HDC theDeviceContext);
+ typedef HGLRC (WINAPI *wglCreateContextAttribsARB_t)(HDC theDevCtx,
+ HGLRC theShareContext,
+ const int* theAttribs);
+ wglGetExtensionsStringARB_t aGetExtensions = (wglGetExtensionsStringARB_t )wglGetProcAddress ("wglGetExtensionsStringARB");
+ wglCreateContextAttribsARB_t aCreateCtxProc = (wglCreateContextAttribsARB_t )wglGetProcAddress ("wglCreateContextAttribsARB");
+ const char* aWglExts = aGetExtensions (wglGetCurrentDC());
+ if (aCreateCtxProc != NULL
+ && OpenGl_Context::CheckExtension (aWglExts, "WGL_ARB_create_context_profile"))
+ {
+ // Beware! NVIDIA drivers reject context creation when WGL_CONTEXT_PROFILE_MASK_ARB are specified
+ // but not WGL_CONTEXT_MAJOR_VERSION_ARB/WGL_CONTEXT_MINOR_VERSION_ARB.
+ int aCtxAttribs[] =
+ {
+ //WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
+ //WGL_CONTEXT_MINOR_VERSION_ARB, 2,
+ //WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, //WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+ WGL_CONTEXT_FLAGS_ARB, theCaps->contextDebug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
+ 0, 0
+ };
+
+ aGContext = aCreateCtxProc (aWindowDC, aSlaveCtx, aCtxAttribs);
+ if (aGContext != NULL)
+ {
+ aSlaveCtx = NULL;
+ }
+ }
+ }
+
+ if (aRendCtxTmp != NULL)
+ {
+ wglDeleteContext (aRendCtxTmp);
+ }
+ if (aDevCtxTmp != NULL)
+ {
+ ReleaseDC (aWinTmp, aDevCtxTmp);
+ }
+ if (aWinTmp != NULL)
+ {
+ DestroyWindow (aWinTmp);
+ }
+ if (aClass.lpszClassName != NULL)
+ {
+ UnregisterClassW (aClass.lpszClassName, aModule);
+ }
+
+ if (aGContext == NULL)
+ {
+ aGContext = wglCreateContext (aWindowDC);
+ }