[OpenGL] Fix last warning (hopefully :-) )

Lionel Ulmer lionel.ulmer at free.fr
Thu Jul 10 12:49:30 CDT 2003


Hi all,

This patch should fix the last warning we had in the OpenGL directory... And
it will also remove the link-time dependency on the presence of
glXGetProcAddressARB in the GL library (not that many Windows games /
applications will work if wglGetProcAddress does not work, but well :-) ).

Now our requirement is simply to have an OpenGL 1.2 - compliant library.

BTW, I am wondering why each time the patches to the auto-generated files
are somehow 'cleaned' to remove the extra line at the end.. Not that it's a
big deal, it's just plain annoying to always have this difference between
the generated files in my tree and what is in CVS :-) (any Perl expert
wanting to remove this line in the generation script is welcome too).

Changelog:
 - load dynamically glXGetProcAddressARB

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: dlls/opengl32/opengl_ext.c
===================================================================
RCS file: /home/wine/wine/dlls/opengl32/opengl_ext.c,v
retrieving revision 1.14
diff -u -r1.14 opengl_ext.c
--- dlls/opengl32/opengl_ext.c	8 Jul 2003 21:07:03 -0000	1.14
+++ dlls/opengl32/opengl_ext.c	10 Jul 2003 17:45:36 -0000
@@ -9169,3 +9169,4 @@
   func_wglFreeMemoryNV( pointer );
   LEAVE_GL();
 }
+
Index: dlls/opengl32/opengl_norm.c
===================================================================
RCS file: /home/wine/wine/dlls/opengl32/opengl_norm.c,v
retrieving revision 1.9
diff -u -r1.9 opengl_norm.c
--- dlls/opengl32/opengl_norm.c	8 Jul 2003 21:07:03 -0000	1.9
+++ dlls/opengl32/opengl_norm.c	10 Jul 2003 17:45:36 -0000
@@ -3762,3 +3762,4 @@
   glViewport( x, y, width, height );
   LEAVE_GL();
 }
+
Index: dlls/opengl32/wgl.c
===================================================================
RCS file: /home/wine/wine/dlls/opengl32/wgl.c,v
retrieving revision 1.34
diff -u -r1.34 wgl.c
--- dlls/opengl32/wgl.c	30 Jun 2003 20:53:49 -0000	1.34
+++ dlls/opengl32/wgl.c	10 Jul 2003 17:45:37 -0000
@@ -30,6 +30,7 @@
 #include "wgl.h"
 #include "opengl_ext.h"
 #include "wine/debug.h"
+#include "wine/port.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
 
@@ -48,6 +49,8 @@
 static GLXContext default_cx = NULL;
 static Display *default_display;  /* display to use for default context */
 
+static void *(*p_glXGetProcAddressARB)(const GLubyte *);
+
 typedef struct wine_glcontext {
   HDC hdc;
   Display *display;
@@ -315,6 +318,11 @@
     return local_func;
   }
 
+  if (p_glXGetProcAddressARB == NULL) {
+    ERR("Warning : dynamic GL extension loading not supported by native GL library.");
+    return NULL;
+  }
+  
   /* After that, search in the thunks to find the real name of the extension */
   ext.name = (char *) lpszProc;
   ext_ret = (OpenGL_extension *) bsearch(&ext, extension_registry,
@@ -322,7 +330,10 @@
 
   if (ext_ret == NULL) {
     /* Some sanity checks :-) */
-    if (glXGetProcAddressARB(lpszProc) != NULL) {
+    ENTER_GL();
+    local_func = p_glXGetProcAddressARB(lpszProc);
+    LEAVE_GL();
+    if (local_func != NULL) {
       ERR("Extension %s defined in the OpenGL library but NOT in opengl_ext.c... Please report (lionel.ulmer at free.fr) !\n", lpszProc);
       return NULL;
     }
@@ -330,8 +341,12 @@
     WARN("Did not find extension %s in either Wine or your OpenGL library.\n", lpszProc);
     return NULL;
   } else {
+    ENTER_GL();
+    local_func = p_glXGetProcAddressARB(ext_ret->glx_name);
+    LEAVE_GL();
+    
     /* After that, look at the extensions defined in the Linux OpenGL library */
-    if ((local_func = glXGetProcAddressARB(ext_ret->glx_name)) == NULL) {
+    if (local_func == NULL) {
       char buf[256];
       void *ret = NULL;
 
@@ -589,6 +604,12 @@
   return FALSE;
 }
 
+/* No need to load any other libraries as according to the ABI, libGL should be self-sufficient and
+   include all dependencies
+*/
+#ifndef SONAME_LIBGL
+#define SONAME_LIBGL "libGL.so"
+#endif
 
 /* This is for brain-dead applications that use OpenGL functions before even
    creating a rendering context.... */
@@ -602,6 +623,7 @@
   XVisualInfo *vis = NULL;
   Window root = (Window)GetPropA( GetDesktopWindow(), "__wine_x11_whole_window" );
   HMODULE mod = GetModuleHandleA( "x11drv.dll" );
+  void *opengl_handle;
 
   if (!root || !mod)
   {
@@ -646,6 +668,12 @@
   XFree(vis);
   LEAVE_GL();
 
+  opengl_handle = wine_dlopen(SONAME_LIBGL, RTLD_NOW|RTLD_GLOBAL, NULL, 0);
+  if (opengl_handle != NULL) {
+    p_glXGetProcAddressARB = wine_dlsym(opengl_handle, "glXGetProcAddressARB", NULL, 0);
+    wine_dlclose(opengl_handle, NULL, 0);
+  }
+  
   if (default_cx == NULL) {
     ERR("Could not create default context.\n");
   }


More information about the wine-patches mailing list