Ver Fonte

Fixed retrieval of OpenGL 1.0 and 1.1 on WGL.

Camilla Berglund há 12 anos atrás
pai
commit
194e22dbbe
3 ficheiros alterados com 24 adições e 3 exclusões
  1. 2 0
      README.md
  2. 15 1
      src/wgl_context.c
  3. 7 2
      src/wgl_platform.h

+ 2 - 0
README.md

@@ -102,6 +102,8 @@ See the [GLFW 3.0 documentation](http://www.glfw.org/docs/3.0/).
  - Bugfix: The `-Wall` flag was not used with Clang and other GCC compatibles
  - Bugfix: The default for `GLFW_ALPHA_BITS` was set to zero
  - [Win32] Bugfix: The clipboard string was not freed on terminate
+ - [Win32] Bugfix: Entry points for OpenGL 1.0 and 1.1 functions were not
+                   returned by `glfwGetProcAddress`
  - [Cocoa] Bugfix: The clipboard string was not freed on terminate
  - [X11] Bugfix: Override-redirect windows were resized to the desired instead
                  of the actual resolution of the selected video mode

+ 15 - 1
src/wgl_context.c

@@ -297,6 +297,13 @@ static GLboolean choosePixelFormat(_GLFWwindow* window,
 //
 int _glfwInitContextAPI(void)
 {
+    _glfw.wgl.opengl32.instance = LoadLibrary(L"opengl32.dll");
+    if (!_glfw.wgl.opengl32.instance)
+    {
+        _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to load opengl32.dll");
+        return GL_FALSE;
+    }
+
     _glfw.wgl.current = TlsAlloc();
     if (_glfw.wgl.current == TLS_OUT_OF_INDEXES)
     {
@@ -316,6 +323,9 @@ void _glfwTerminateContextAPI(void)
 {
     if (_glfw.wgl.hasTLS)
         TlsFree(_glfw.wgl.current);
+
+    if (_glfw.wgl.opengl32.instance)
+        FreeLibrary(_glfw.wgl.opengl32.instance);
 }
 
 #define setWGLattrib(attribName, attribValue) \
@@ -632,7 +642,11 @@ int _glfwPlatformExtensionSupported(const char* extension)
 
 GLFWglproc _glfwPlatformGetProcAddress(const char* procname)
 {
-    return (GLFWglproc) wglGetProcAddress(procname);
+    const GLFWglproc proc = (GLFWglproc) wglGetProcAddress(procname);
+    if (proc)
+        return proc;
+
+    return (GLFWglproc) GetProcAddress(_glfw.wgl.opengl32.instance, procname);
 }
 
 

+ 7 - 2
src/wgl_platform.h

@@ -77,8 +77,13 @@ typedef struct _GLFWcontextWGL
 //------------------------------------------------------------------------
 typedef struct _GLFWlibraryWGL
 {
-    GLboolean   hasTLS;
-    DWORD       current;
+    GLboolean       hasTLS;
+    DWORD           current;
+
+    // opengl32.dll
+    struct {
+        HINSTANCE   instance;
+    } opengl32;
 
 } _GLFWlibraryWGL;