浏览代码

GL fix for Epoxy and creating a 3.2 core context with win32 api.

rextimmy 9 年之前
父节点
当前提交
8056a4bfa9
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      Engine/source/gfx/gl/win32/gfxGLDevice.win.cpp

+ 9 - 0
Engine/source/gfx/gl/win32/gfxGLDevice.win.cpp

@@ -272,6 +272,11 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
    int debugFlag = 0;
    int debugFlag = 0;
 #endif
 #endif
 
 
+   // Create a temp rendering context, needed a current context to use wglCreateContextAttribsARB
+   HGLRC tempGLRC = wglCreateContext(hdcGL);
+   if (!wglMakeCurrent(hdcGL, tempGLRC))
+      AssertFatal(false, "Couldn't make temp GL context.");
+
    if( gglHasWExtension(hdcGL, ARB_create_context) )
    if( gglHasWExtension(hdcGL, ARB_create_context) )
    {
    {
       int const create_attribs[] = {
       int const create_attribs[] = {
@@ -292,6 +297,10 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
    else
    else
       mContext = wglCreateContext( hdcGL );
       mContext = wglCreateContext( hdcGL );
 
 
+   // Delete temp rendering context
+   wglMakeCurrent(NULL, NULL);
+   wglDeleteContext(tempGLRC);
+
    if( !wglMakeCurrent( hdcGL, (HGLRC)mContext ) )
    if( !wglMakeCurrent( hdcGL, (HGLRC)mContext ) )
       AssertFatal( false , "GFXGLDevice::init - cannot make our context current. Or maybe we can't create it." );
       AssertFatal( false , "GFXGLDevice::init - cannot make our context current. Or maybe we can't create it." );