Author: spitzak
Date: 2008-11-10 11:35:46 -0800 (Mon, 10 Nov 2008)
New Revision: 6511
Log:
Copied change from 1.3 branch by Chris <[EMAIL PROTECTED]> to enable
OpenGL3 under GLX. 


Modified:
   trunk/OpenGL/Fl_Gl_Choice.cxx

Modified: trunk/OpenGL/Fl_Gl_Choice.cxx
===================================================================
--- trunk/OpenGL/Fl_Gl_Choice.cxx       2008-11-10 18:21:38 UTC (rev 6510)
+++ trunk/OpenGL/Fl_Gl_Choice.cxx       2008-11-10 19:35:46 UTC (rev 6511)
@@ -226,7 +226,35 @@
 #endif
 
 GLContext fltk::create_gl_context(XVisualInfo* vis) {
-  GLContext context = glXCreateContext(xdisplay, vis, first_context, 1);
+  GLContext context;
+#if 1 // enable OpenGL3 support if possible
+  typedef GLXFBConfig (*PFNGLXGETFBCONFIGFROMVISUALSGIXPROC)(
+               Display *dpy,
+               XVisualInfo *vis );
+  typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARB)(
+               Display *dpy,
+               GLXFBConfig config,
+               GLXContext share_context,
+               Bool direct,
+               const int *attrib_list);
+
+  PFNGLXGETFBCONFIGFROMVISUALSGIXPROC glXGetFBConfigFromVisualSGIX = 
(PFNGLXGETFBCONFIGFROMVISUALSGIXPROC)
+               glXGetProcAddress((const GLubyte *) 
"glXGetFBConfigFromVisualSGIX");
+
+  PFNGLXCREATECONTEXTATTRIBSARB glXCreateContextAttribsARB =
+               (PFNGLXCREATECONTEXTATTRIBSARB)  glXGetProcAddress((const 
GLubyte *) "glXCreateContextAttribsARB");
+
+  if (glXGetFBConfigFromVisualSGIX && glXCreateContextAttribsARB) {
+    printf("Success!\n");
+    GLXFBConfig c = glXGetFBConfigFromVisualSGIX(xdisplay, vis);
+#   define GLX_CONTEXT_MAJOR_VERSION_ARB               0x2091
+#   define GLX_CONTEXT_MINOR_VERSION_ARB               0x2092
+    int arr2[] = {  GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+                    GLX_CONTEXT_MINOR_VERSION_ARB, 0, None };
+    context = glXCreateContextAttribsARB(xdisplay, c, first_context, True, 
arr2);
+  } else
+#endif
+    context = glXCreateContext(xdisplay, vis, first_context, 1);
 #if DESTROY_ON_EXIT
   Contexts* p = new Contexts;
   p->context = context;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to