From 7a40768455342ab2d1d43bf435baa42a8ccaf917 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Sun, 18 Mar 2012 22:33:46 +0100
Subject: Fix bug 564 (X11 Mesa 8.0.1 GL 3.0 w/o GLX_ARB_create_context)

X11/Mesa 8.0.1 offers a GL 3.0 context w/o
having the GLX_ARB_create_context extension available
(even though the func-ptr glXCreateContextAttribsARB is not null).

We assumed that if no GLContext device availability is set,
it can be only GL 2.0 or ES1/ES2.

Fix: Relaxed these (false) constrains and map the created context
     reflecting using it's actual attributes.
---
 .../classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'src/jogl/classes/jogamp/opengl/windows/wgl')

diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index ebe202f31..217d88f3c 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -296,12 +296,13 @@ public class WindowsWGLContext extends GLContextImpl {
             throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: "+GDI.GetLastError());
         }
         setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT);  // use GL_VERSION
-        boolean isCreateContextAttribsARBAvailable = isFunctionAvailable("wglCreateContextAttribsARB");
         WGL.wglMakeCurrent(0, 0); // release temp context
 
         if( !createContextARBTried) {
-            if(isCreateContextAttribsARBAvailable &&
-               isExtensionAvailable("WGL_ARB_create_context") ) {
+            // is*Available calls are valid since setGLFunctionAvailability(..) was called
+            final boolean isProcCreateContextAttribsARBAvailable = isFunctionAvailable("wglCreateContextAttribsARB");
+            final boolean isExtARBCreateContextAvailable = isExtensionAvailable("WGL_ARB_create_context");
+            if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) {
                 // initial ARB context creation
                 contextHandle = createContextARB(share, true);
                 createContextARBTried=true;
@@ -313,7 +314,8 @@ public class WindowsWGLContext extends GLContextImpl {
                     }
                 }
             } else if (DEBUG) {
-                System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+share);
+                System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+share+
+                                   ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable);            
             }
         }
     }
-- 
cgit v1.2.3