use glXGetProcAddressARB to avoid extension linkage problems
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 27 Nov 2001 02:55:58 +0000 (02:55 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 27 Nov 2001 02:55:58 +0000 (02:55 +0000)
src/glut/glx/glut_dstr.c
src/glut/glx/glut_glxext.c
src/glut/glx/glut_overlay.c
src/glut/glx/glut_vidresize.c
src/glut/glx/glut_win.c
src/glut/glx/glutint.h

index 29a699fa5713b4dbbea669168343827780ca32e3..3f7dba80f35c036fd1d9d6fea23245ae42a35f2a 100644 (file)
@@ -439,15 +439,15 @@ loadVisuals(int *nitems_return)
         GLXFBConfigSGIX fbc;
         int fbconfigID, drawType, renderType;
 
-        fbc = glXGetFBConfigFromVisualSGIX(__glutDisplay, vlist[i]);
+        fbc = __glut_glXGetFBConfigFromVisualSGIX(__glutDisplay, vlist[i]);
         if (fbc) {
-          rc = glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
+          rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
            GLX_FBCONFIG_ID_SGIX, &fbconfigID);
           if ((rc == 0) && (fbconfigID != None)) {
-            rc = glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
+            rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
              GLX_DRAWABLE_TYPE_SGIX, &drawType);
             if ((rc == 0) && (drawType & GLX_WINDOW_BIT_SGIX)) {
-              rc = glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
+              rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
                GLX_RENDER_TYPE_SGIX, &renderType);
               if ((rc == 0) && (renderType & GLX_RGBA_BIT_SGIX)) {
                 mode->fbc = fbc;
@@ -459,7 +459,7 @@ loadVisuals(int *nitems_return)
 
                 /* Start with "j = 1" to skip the GLX_RGBA attribute. */
                 for (j = 1; j < NUM_GLXCAPS; j++) {
-                  rc = glXGetFBConfigAttribSGIX(__glutDisplay,
+                  rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay,
                    fbc, glxcap[j], &mode->cap[j]);
                   if (rc != 0) {
                     mode->valid = 0;
@@ -509,7 +509,7 @@ loadVisuals(int *nitems_return)
 #define GLX_VISUAL_CAVEAT_EXT 0x20
 #endif
 
-                  rc = glXGetFBConfigAttribSGIX(__glutDisplay,
+                  rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay,
                    fbc, GLX_VISUAL_CAVEAT_EXT, &rating);
                   if (rc != 0) {
                     mode->cap[SLOW] = 0;
@@ -558,7 +558,7 @@ loadVisuals(int *nitems_return)
 #define GLX_TRANSPARENT_TYPE_EXT 0x23
 #endif
 
-                  rc = glXGetFBConfigAttribSGIX(__glutDisplay,
+                  rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay,
                    fbc, GLX_TRANSPARENT_TYPE_EXT, &transparent);
                   if (rc != 0) {
                     mode->cap[TRANSPARENT] = 0;
@@ -573,7 +573,7 @@ loadVisuals(int *nitems_return)
 #endif
 #if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample)
                 if (multisample) {
-                  rc = glXGetFBConfigAttribSGIX(__glutDisplay,
+                  rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay,
                    fbc, GLX_SAMPLES_SGIS, &mode->cap[SAMPLES]);
                   if (rc != 0) {
                     mode->cap[SAMPLES] = 0;
index 04862432fc13020e1672f029f1fcfc0dc4858809..bb2eb475ce27975810ba0e56d91094666419ebf3 100644 (file)
@@ -46,3 +46,210 @@ __glutIsSupportedByGLX(char *extension)
   return 0;
 }
 #endif
+
+
+
+/*
+ * Wrapping of GLX extension functions.
+ * Technically, we should do a runtime test to see if we've got the
+ * glXGetProcAddressARB() function.  I think GLX_ARB_get_proc_address
+ * is pretty widely supported now and any system that has
+ * GLX_ARB_get_proc_address defined in its header files should be OK
+ * at runtime.
+ */
+
+int
+__glut_glXBindChannelToWindowSGIX(Display *dpy, int screen,
+                                  int channel, Window window)
+{
+#ifdef GLX_ARB_get_proc_address
+  typedef int (*glXBindChannelToWindowSGIX_t) (Display *, int, int, Window);
+  static glXBindChannelToWindowSGIX_t glXBindChannelToWindowSGIX_ptr = NULL;
+  if (!glXBindChannelToWindowSGIX_ptr) {
+    glXBindChannelToWindowSGIX_ptr = (glXBindChannelToWindowSGIX_t)
+      glXGetProcAddressARB((const GLubyte *) "glXBindChannelToWindowSGIX");
+  }
+  if (glXBindChannelToWindowSGIX_ptr)
+    return (*glXBindChannelToWindowSGIX_ptr)(dpy, screen, channel, window);
+  else
+    return 0;
+#elif defined(GLX_SGIX_video_resize)
+  return glXBindChannelToWindowSGIX(dpy, screen, channel, window);
+#else
+  return 0;
+#endif   
+}
+
+
+int
+__glut_glXChannelRectSGIX(Display *dpy, int screen, int channel,
+                          int x, int y, int w, int h)
+{
+#ifdef GLX_ARB_get_proc_address
+  typedef int (*glXChannelRectSGIX_t)(Display *, int, int, int, int, int, int);
+  static glXChannelRectSGIX_t glXChannelRectSGIX_ptr = NULL;
+  if (!glXChannelRectSGIX_ptr) {
+    glXChannelRectSGIX_ptr = (glXChannelRectSGIX_t)
+      glXGetProcAddressARB((const GLubyte *) "glXChannelRectSGIX");
+  }
+  if (glXChannelRectSGIX_ptr)
+    return (*glXChannelRectSGIX_ptr)(dpy, screen, channel, x, y, w, h);
+  else
+    return 0;
+#elif defined(GLX_SGIX_video_resize)
+  return glXChannelRectSGIX(dpy, screen, channel, x, y, w, h);
+#else
+  return 0;
+#endif   
+}
+
+
+int
+__glut_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel,
+                               int *x, int *y, int *w, int *h)
+{
+#ifdef GLX_ARB_get_proc_address
+  typedef int (*glXQueryChannelRectSGIX_t)(Display *, int, int,
+                                           int *, int *, int *, int *);
+  static glXQueryChannelRectSGIX_t glXQueryChannelRectSGIX_ptr = NULL;
+  if (!glXQueryChannelRectSGIX_ptr) {
+    glXQueryChannelRectSGIX_ptr = (glXQueryChannelRectSGIX_t)
+      glXGetProcAddressARB((const GLubyte *) "glXQueryChannelRectSGIX");
+  }
+  if (glXQueryChannelRectSGIX_ptr)
+    return (*glXQueryChannelRectSGIX_ptr)(dpy, screen, channel, x, y, w, h);
+  else
+    return 0;
+#elif defined(GLX_SGIX_video_resize)
+  return glXQueryChannelRectSGIX(dpy, screen, channel, x, y, w, h);
+#else
+  return 0;
+#endif   
+}
+
+
+int
+__glut_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel,
+                                 int *dx, int *dy, int *dw, int *dh)
+{
+#ifdef GLX_ARB_get_proc_address
+  typedef int (*glXQueryChannelDeltasSGIX_t)(Display *, int, int,
+                                             int *, int *, int *, int *);
+  static glXQueryChannelDeltasSGIX_t glXQueryChannelDeltasSGIX_ptr = NULL;
+  if (!glXQueryChannelDeltasSGIX_ptr) {
+    glXQueryChannelDeltasSGIX_ptr = (glXQueryChannelDeltasSGIX_t)
+      glXGetProcAddressARB((const GLubyte *) "glXQueryChannelDeltasSGIX");
+  }
+  if (glXQueryChannelDeltasSGIX_ptr)
+    return (*glXQueryChannelDeltasSGIX_ptr)(dpy, screen, channel,
+                                            dx, dy, dw, dh);
+  else
+    return 0;
+#elif defined(GLX_SGIX_video_resize)
+  return glXQueryChannelDeltasSGIX(dpy, screen, channel, dx, dy, dw, dh);
+#else
+  return 0;
+#endif   
+}
+
+
+int
+__glut_glXChannelRectSyncSGIX(Display *dpy, int screen,
+                              int channel, GLenum synctype)
+{
+#ifdef GLX_ARB_get_proc_address
+  typedef int (*glXChannelRectSyncSGIX_t)(Display *, int, int, GLenum);
+  static glXChannelRectSyncSGIX_t glXChannelRectSyncSGIX_ptr = NULL;
+  if (!glXChannelRectSyncSGIX_ptr) {
+    glXChannelRectSyncSGIX_ptr = (glXChannelRectSyncSGIX_t)
+      glXGetProcAddressARB((const GLubyte *) "glXChannelRectSyncSGIX");
+  }
+  if (glXChannelRectSyncSGIX_ptr)
+    return (*glXChannelRectSyncSGIX_ptr)(dpy, screen, channel, synctype);
+  else
+    return 0;
+#elif defined(GLX_SGIX_video_resize)
+  return glXChannelRectSyncSGIX(dpy, screen, channel, synctype);
+#else
+  return 0;
+#endif   
+}
+
+
+
+GLXContext
+__glut_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config,
+                                      int render_type, GLXContext share_list,
+                                      Bool direct)
+{
+#ifdef GLX_ARB_get_proc_address
+  typedef GLXContext (*glXCreateContextWithConfigSGIX_t)(Display *,
+                                 GLXFBConfigSGIX, int, GLXContext, Bool);
+  static glXCreateContextWithConfigSGIX_t glXCreateContextWithConfig_ptr = NULL;
+  if (!glXCreateContextWithConfig_ptr) {
+    glXCreateContextWithConfig_ptr = (glXCreateContextWithConfigSGIX_t)
+       glXGetProcAddress((const GLubyte *) "glXCreateContextWithConfigSGIX");
+  }
+  if (glXCreateContextWithConfig_ptr)
+    return (*glXCreateContextWithConfig_ptr)(dpy, config, render_type,
+                                             share_list, direct);
+  else
+    return 0;
+#elif defined(GLX_SGIX_fbconfig)
+  return glXCreateContextWithConfigSGIX(dpy, config, render_type,
+                                        share_list, direct);
+#else
+  return 0;
+#endif
+}
+
+
+int
+__glut_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config,
+                                int attribute, int *value)
+{
+#ifdef GLX_ARB_get_proc_address
+  typedef int (*glXGetFBConfigAttribSGIX_t)(Display *,
+                                            GLXFBConfigSGIX, int, int *);
+  static glXGetFBConfigAttribSGIX_t glXGetFBConfigAttrib_ptr = NULL;
+  if (!glXGetFBConfigAttrib_ptr) {
+    glXGetFBConfigAttrib_ptr = (glXGetFBConfigAttribSGIX_t)
+       glXGetProcAddress((const GLubyte *) "glXGetFBConfigAttribSGIX");
+  }
+  if (glXGetFBConfigAttrib_ptr)
+    return (*glXGetFBConfigAttrib_ptr)(dpy, config, attribute, value);
+  else
+    return 0;
+#elif defined(GLX_SGIX_fbconfig)
+  return glXGetFBConfigAttribSGIX(dpy, config, attribute, value);
+#else
+  return 0;
+#endif
+}
+
+
+GLXFBConfigSGIX
+__glut_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
+{
+#ifdef GLX_ARB_get_proc_address
+  typedef GLXFBConfigSGIX (*glXGetFBConfigFromVisualSGIX_t)(Display *,
+                                                            XVisualInfo *);
+  static glXGetFBConfigFromVisualSGIX_t glXGetFBConfigFromVisual_ptr = NULL;
+  if (!glXGetFBConfigFromVisual_ptr) {
+    glXGetFBConfigFromVisual_ptr = (glXGetFBConfigFromVisualSGIX_t)
+       glXGetProcAddress((const GLubyte *) "glXGetFBConfigFromVisualSGIX");
+  }
+  if (glXGetFBConfigFromVisual_ptr)
+    return (*glXGetFBConfigFromVisual_ptr)(dpy, vis);
+  else
+    return 0;
+#elif defined(GLX_SGIX_fbconfig)
+  return glXGetFBConfigFromVisualSGIX(dpy, vis);
+#else
+  return 0;
+#endif
+}
+
+
+
+
index cc3c8ced6417d99c8aea888cef31ce10578f4c1e..33ab53982e36a2ab85fa9043047dcf52f002803d 100644 (file)
@@ -395,7 +395,7 @@ glutEstablishOverlay(void)
   }
 #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
   if (fbc) {
-    window->ctx = glXCreateContextWithConfigSGIX(__glutDisplay, fbc,
+    window->ctx = __glut_glXCreateContextWithConfigSGIX(__glutDisplay, fbc,
       GLX_RGBA_TYPE_SGIX, None, __glutTryDirect);
   } else
 #endif
index 0146a29d8c521194526cb6560aebe53577203a16..6024d9514aa26db92ca9211b99c2853459ed9833 100644 (file)
@@ -57,7 +57,7 @@ glutVideoResizeGet(GLenum param)
   if (canVideoResize < 0) {
     canVideoResize = __glutIsSupportedByGLX("GLX_SGIX_video_resize");
     if (canVideoResize) {
-#if __sgi
+#if defined(__sgi) && __sgi
       /* This is a hack because IRIX 6.2, 6.3, and some 6.4
          versions were released with GLX_SGIX_video_resize
          being advertised by the X server though the video
@@ -94,7 +94,8 @@ glutVideoResizeGet(GLenum param)
 
 #if defined(GLX_GLXEXT_PROTOTYPES)
 #endif
-        glXQueryChannelDeltasSGIX(__glutDisplay, __glutScreen,
+
+        __glut_glXQueryChannelDeltasSGIX(__glutDisplay, __glutScreen,
           videoResizeChannel, &dx, &dy, &dw, &dh);
 
         /* glXQueryChannelDeltasSGIX is an inherent X server
@@ -138,7 +139,7 @@ glutVideoResizeGet(GLenum param)
     if (videoResizeInUse) {
       int x, y, width, height;
 
-      glXQueryChannelRectSGIX(__glutDisplay, __glutScreen,
+      __glut_glXQueryChannelRectSGIX(__glutDisplay, __glutScreen,
         videoResizeChannel, &x, &y, &width, &height);
       switch (param) {
       case GLUT_VIDEO_RESIZE_X:
@@ -164,7 +165,7 @@ glutSetupVideoResizing(void)
 {
 #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
   if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
-    glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
+    __glut_glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
       videoResizeChannel, __glutCurrentWindow->win);
     videoResizeInUse = 1;
   } else
@@ -178,7 +179,7 @@ glutStopVideoResizing(void)
 #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
   if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
     if (videoResizeInUse) {
-      glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
+      __glut_glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
         videoResizeChannel, None);
       videoResizeInUse = 0;
     }
@@ -196,10 +197,10 @@ glutVideoResize(int x, int y, int width, int height)
     /* glXChannelRectSyncSGIX introduced in a patch to IRIX
        6.2; the original unpatched IRIX 6.2 behavior is always
        GLX_SYNC_SWAP_SGIX. */
-    glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
+    __glut_glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
       videoResizeChannel, GLX_SYNC_SWAP_SGIX);
 #endif
-    glXChannelRectSGIX(__glutDisplay, __glutScreen,
+    __glut_glXChannelRectSGIX(__glutDisplay, __glutScreen,
       videoResizeChannel, x, y, width, height);
   }
 #endif
@@ -218,10 +219,10 @@ glutVideoPan(int x, int y, int width, int height)
        accomplish GLX_SYNC_FRAME_SGIX on IRIX unpatched 6.2;
        this means you'd need a glutSwapBuffers to actually
        realize the video resize. */
-    glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
+    __glut_glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
       videoResizeChannel, GLX_SYNC_FRAME_SGIX);
 #endif
-    glXChannelRectSGIX(__glutDisplay, __glutScreen,
+    __glut_glXChannelRectSGIX(__glutDisplay, __glutScreen,
       videoResizeChannel, x, y, width, height);
   }
 #endif
index d03829c3a1a5e0fe7c0782d549bd1c0706c6dcb3..ec8ad07f221a1038a9a3490e1afa6a41dc0fb518 100644 (file)
@@ -577,7 +577,7 @@ __glutCreateWindow(GLUTwindow * parent,
   window->renderWin = window->win;
 #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
   if (fbc) {
-    window->ctx = glXCreateContextWithConfigSGIX(__glutDisplay, fbc,
+    window->ctx = __glut_glXCreateContextWithConfigSGIX(__glutDisplay, fbc,
       GLX_RGBA_TYPE_SGIX, None, __glutTryDirect);
   } else
 #endif
index 292cc27729c7c92c0e5faec84ea28a9233cd7b8b..b0d6c86b7c42fc97ee5c50e936306da34b06e8e5 100644 (file)
@@ -764,6 +764,29 @@ extern void __glutDestroyWindow(
 #if !defined(_WIN32)
 /* private routines from glut_glxext.c */
 extern int __glutIsSupportedByGLX(char *);
+extern int __glut_glXBindChannelToWindowSGIX(Display *dpy, int screen,
+                                             int channel, Window window);
+extern int __glut_glXChannelRectSGIX(Display *dpy, int screen, int channel,
+                                     int x, int y, int w, int h);
+extern int __glut_glXQueryChannelRectSGIX(Display *dpy, int screen,
+                                          int channel, int *x, int *y,
+                                          int *w, int *h);
+extern int __glut_glXQueryChannelDeltasSGIX(Display *dpy, int screen,
+                                            int channel, int *dx, int *dy,
+                                            int *dw, int *dh);
+extern int __glut_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel,
+                                         GLenum synctype);
+extern GLXContext __glut_glXCreateContextWithConfigSGIX(Display *dpy,
+                                                        GLXFBConfigSGIX config,
+                                                        int render_type,
+                                                        GLXContext share_list,
+                                                        Bool direct);
+extern int __glut_glXGetFBConfigAttribSGIX(Display *dpy,
+                                           GLXFBConfigSGIX config,
+                                           int attribute,
+                                           int *value);
+extern GLXFBConfigSGIX __glut_glXGetFBConfigFromVisualSGIX(Display *dpy,
+                                                           XVisualInfo *vis);
 #endif
 
 /* private routines from glut_input.c */