aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-08-03 13:18:17 -0700
committerSven Gothel <[email protected]>2009-08-03 13:18:17 -0700
commit33c4fbf49ff5d91925d3653dd5d5f034825954e7 (patch)
treea604f5bf2d384733ca9671ce5c78325b8f5ed774
parent733d54f7e2977c20e373eba50b9cd16966a4fb77 (diff)
Doc: OpenGL 3.1 .. 3.2 profile clarification
GLX_ARB_create_context: Add 3.2 context WGL_ARB_create_context: Add 3.2 context Add: Trying to use 3.2 core profile creation for GL3, disabled by default. (Disabled per default due to a freezing JVM on Linux _after_ the Java main thread and Hotspot finishes.) Experimental: You may try '3.2 core profile creation' setting the java system property 'jogl.GLContext.3_2'.
-rw-r--r--make/doc/jogl/spec-overview.html3
-rw-r--r--make/stub_includes/opengl/GL/glxext.h7
-rw-r--r--make/stub_includes/opengl/GL/wglext.h7
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java1
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java81
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java76
6 files changed, 120 insertions, 55 deletions
diff --git a/make/doc/jogl/spec-overview.html b/make/doc/jogl/spec-overview.html
index f2c0c0339..5d4779c57 100644
--- a/make/doc/jogl/spec-overview.html
+++ b/make/doc/jogl/spec-overview.html
@@ -329,12 +329,13 @@ according the following rules: <br>
<li> OpenGL 3.1 requires a new native context, incompatible with prior versions.</li>
<li> OpenGL 3.1 forward compatible profile drops fixed functionality.</li>
</ul></li>
- <li>Forward compatibility, dropping fixed functionality, is choosen because:
+ <li>Forward compatibility, aka core, ie a context without <code>GL_ARB_compatibility</code>, is chosen because:
<ul>
<li> It shares a commont subset with ES2.x</li>
<li> It is not guaranteed to be provided by all vendors.</li>
<li> It is not guaranteed to be provided in future versions.</li>
<li> OpenGL 3.2 core profile is compatible with OpenGL 3.1 forward compatible spec.</li>
+ <li> OpenGL 3.2 Spec Appendix E.1: It is not possible to implement both core and compatibility profiles in a single GL context, ..</li>
</ul></li>
</ul></li>
<a name="GL2InclusionCriteria"/>
diff --git a/make/stub_includes/opengl/GL/glxext.h b/make/stub_includes/opengl/GL/glxext.h
index 2d6036bcd..2ed99a824 100644
--- a/make/stub_includes/opengl/GL/glxext.h
+++ b/make/stub_includes/opengl/GL/glxext.h
@@ -77,11 +77,14 @@ extern "C" {
#endif
#ifndef GLX_ARB_create_context
-#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
-#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
+#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
+#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
+#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
+#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
#define GLX_CONTEXT_FLAGS_ARB 0x2094
+#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
#endif
#ifndef GLX_SGIS_multisample
diff --git a/make/stub_includes/opengl/GL/wglext.h b/make/stub_includes/opengl/GL/wglext.h
index 6f367c09b..d581756c2 100644
--- a/make/stub_includes/opengl/GL/wglext.h
+++ b/make/stub_includes/opengl/GL/wglext.h
@@ -190,12 +190,15 @@ extern "C" {
#endif
#ifndef WGL_ARB_create_context
+#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
+#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
+#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
+#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
-#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
-#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
+#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define ERROR_INVALID_VERSION_ARB 0x2095
#endif
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
index 16eb934bd..d1a35b1b6 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -61,6 +61,7 @@ public abstract class GLContextImpl extends GLContext {
// platforms anyway in particular with the disabling of the
// GLWorkerThread which we found to be necessary in 1.0 beta 4.
protected boolean optimizationEnabled = Debug.isPropertyDefined("jogl.GLContext.optimize", true);
+ protected boolean tryGLContext3_2 = Debug.isPropertyDefined("jogl.GLContext.3_2", true);
// Cache of the functions that are available to be called at the current
// moment in time
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
index 6d810ed39..008dd6ac2 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -154,13 +154,9 @@ public class WindowsWGLContext extends GLContextImpl {
if( !isFunctionAvailable("wglCreateContextAttribsARB") ||
!isExtensionAvailable("WGL_ARB_create_context") ) {
if(glCaps.getGLProfile().isGL3()) {
- if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
- }
- if (!WGL.wglDeleteContext(temp_hglrc)) {
- throw new GLException("Unable to delete OpenGL context");
- }
- throw new GLException("Unable to create OpenGL 3.1 context (no WGL_ARB_create_context)");
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(temp_hglrc);
+ throw new GLException("Unable to create OpenGL >= 3.1 context (no WGL_ARB_create_context)");
}
// continue with temp context for GL < 3.0
@@ -173,44 +169,71 @@ public class WindowsWGLContext extends GLContextImpl {
// preset with default values
int attribs[] = {
- WGLExt.WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
- WGLExt.WGL_CONTEXT_MINOR_VERSION_ARB, 0,
- WGLExt.WGL_CONTEXT_FLAGS_ARB, 0,
- 0
+ /* 0 */ WGLExt.WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
+ /* 2 */ WGLExt.WGL_CONTEXT_MINOR_VERSION_ARB, 0,
+ /* 4 */ WGLExt.WGL_CONTEXT_FLAGS_ARB, 0 /* WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB */,
+ /* 6 */ 0, 0,
+ /* 8 */ 0
};
if(glCaps.getGLProfile().isGL3()) {
- attribs[1] |= 3;
- attribs[3] |= 1;
- // attribs[5] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB ; // NVidia WGL driver doesn't support this one ..
- // attribs[5] |= WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB ;
+ if(tryGLContext3_2) {
+ // Try >= 3.2 core first !
+ // and verify with a None drawable binding (default framebuffer)
+ attribs[0+1] = 3;
+ attribs[2+1] = 2;
+ attribs[6+0] = WGLExt.WGL_CONTEXT_PROFILE_MASK_ARB;
+ attribs[6+1] = WGLExt.WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
+ hglrc = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), hglrc2, attribs, 0);
+ if(0!=hglrc) {
+ if (!WGL.wglMakeCurrent(0, hglrc)) {
+ if(DEBUG) {
+ System.err.println("WindowsWGLContext.createContext couldn't make >= 3.2 core context current - fallback");
+ }
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(hglrc);
+ hglrc = 0;
+ } else if(DEBUG) {
+ System.err.println("WindowsWGLContext.createContext >= 3.2 available 0x"+Long.toHexString(hglrc));
+ }
+ }
+ }
+ if(0==hglrc) {
+ if(tryGLContext3_2 && DEBUG) {
+ System.err.println("WindowsWGLContext.createContext couldn't create >= 3.2 core context");
+ }
+ // Try >= 3.1 forward compatible - last resort for GL3 !
+ attribs[0+1] = 3;
+ attribs[2+1] = 1;
+ attribs[4+1] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ attribs[6+0] = 0;
+ attribs[6+1] = 0;
+ }
+ }
+ if(0==hglrc) {
+ // 3.1 or 3.0 ..
+ hglrc = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), hglrc2, attribs, 0);
}
- hglrc = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), hglrc2, attribs, 0);
if(0==hglrc) {
if(glCaps.getGLProfile().isGL3()) {
- if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
- }
- if (!WGL.wglDeleteContext(temp_hglrc)) {
- throw new GLException("Unable to delete OpenGL context");
- }
- throw new GLException("Unable to create OpenGL 3.1 context (have WGL_ARB_create_context)");
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(temp_hglrc);
+ throw new GLException("Unable to create OpenGL >= 3.1 context (have WGL_ARB_create_context)");
}
// continue with temp context for GL < 3.0
hglrc = temp_hglrc;
+ if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
+ throw new GLException("Error making old context current: " + WGL.GetLastError());
+ }
if(DEBUG) {
System.err.println("WindowsWGLContext.create done (old ctx < 3.0 - no 3.0) 0x"+Long.toHexString(hglrc));
}
} else {
hglrc2 = 0; // mark as shared ..
- if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
- }
- if (!WGL.wglDeleteContext(temp_hglrc)) {
- throw new GLException("Unable to delete temp OpenGL context");
- }
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(temp_hglrc);
if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
throw new GLException("Error making new context current: " + WGL.GetLastError());
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
index da1548d0d..6513fbe29 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
@@ -142,7 +142,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if(config.getFBConfigID()<0) {
// not able to use FBConfig
if(glCaps.getGLProfile().isGL3()) {
- throw new GLException("Unable to create OpenGL 3.1 context");
+ throw new GLException("Unable to create OpenGL >= 3.1 context");
}
context = GLX.glXCreateContext(display, config.getXVisualInfo(), share, direct);
if (context == 0) {
@@ -178,11 +178,9 @@ public abstract class X11GLXContext extends GLContextImpl {
if( !isFunctionAvailable("glXCreateContextAttribsARB") ||
!isExtensionAvailable("GLX_ARB_create_context") ) {
if(glCaps.getGLProfile().isGL3()) {
- if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
- throw new GLException("Error freeing temp OpenGL context");
- }
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
- throw new GLException("Unable to create OpenGL 3.1 context (no GLX_ARB_create_context)");
+ throw new GLException("Unable to create OpenGL >= 3.1 context (no GLX_ARB_create_context)");
}
// continue with temp context for GL < 3.0
@@ -195,38 +193,74 @@ public abstract class X11GLXContext extends GLContextImpl {
// preset with default values
int attribs[] = {
- GLX.GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
- GLX.GLX_CONTEXT_MINOR_VERSION_ARB, 0,
- GLX.GLX_CONTEXT_FLAGS_ARB, 0,
- GLX.GLX_RENDER_TYPE, GLX.GLX_RGBA_TYPE,
- 0
+ /* 0 */ GLX.GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+ /* 2 */ GLX.GLX_CONTEXT_MINOR_VERSION_ARB, 0,
+ /* 4 */ GLX.GLX_RENDER_TYPE, GLX.GLX_RGBA_TYPE,
+ /* 6 */ GLX.GLX_CONTEXT_FLAGS_ARB, 0 /* GLX.GLX_CONTEXT_DEBUG_BIT_ARB */,
+ /* 8 */ 0, 0,
+ /* 10 */ 0
};
if(glCaps.getGLProfile().isGL3()) {
- attribs[1] |= 3;
- attribs[3] |= 1;
- attribs[5] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /* | GLX.GLX_CONTEXT_DEBUG_BIT_ARB */;
+ if(tryGLContext3_2) {
+ // Try >= 3.2 core first
+ // and verify with a None drawable binding (default framebuffer)
+ attribs[0+1] = 3;
+ attribs[2+1] = 2;
+ attribs[8+0] = GLX.GLX_CONTEXT_PROFILE_MASK_ARB;
+ attribs[8+1] = GLX.GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
+
+ context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
+ if(0!=context) {
+ if (!GLX.glXMakeContextCurrent(display, 0, 0, context)) {
+ if(DEBUG) {
+ System.err.println("X11GLXContext.createContext couldn't make >= 3.2 core context current - fallback");
+ }
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ GLX.glXDestroyContext(display, context);
+ context = 0;
+ } else if(DEBUG) {
+ System.err.println("X11GLXContext.createContext >= 3.2 available 0x"+Long.toHexString(context));
+ }
+ }
+ }
+ if(0==context) {
+ if(tryGLContext3_2 && DEBUG) {
+ System.err.println("X11GLXContext.createContext couldn't create >= 3.2 core context - fallback");
+ }
+ // Try >= 3.1 forward compatible - last resort for GL3 !
+ attribs[0+1] = 3;
+ attribs[2+1] = 1;
+ attribs[6+1] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ attribs[8+0] = 0;
+ attribs[8+1] = 0;
+ }
+ }
+ if(0==context) {
+ // 3.1 or 3.0 ..
+ context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
}
- context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
if(0==context) {
if(glCaps.getGLProfile().isGL3()) {
- if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
- throw new GLException("Error freeing temp OpenGL context");
- }
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
- throw new GLException("Unable to create OpenGL 3.1 context (have GLX_ARB_create_context)");
+ throw new GLException("Unable to create OpenGL >= 3.1 context (have GLX_ARB_create_context)");
}
// continue with temp context for GL < 3.0
context = temp_context;
+ if (!GLX.glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawable.getNativeWindow().getSurfaceHandle(),
+ context)) {
+ throw new GLException("Error making context (old) current: display 0x"+Long.toHexString(display)+", context 0x"+Long.toHexString(context)+", drawable "+drawable);
+ }
if(DEBUG) {
System.err.println("X11GLXContext.createContext done (old ctx < 3.0 - no 3.0) 0x"+Long.toHexString(context));
}
} else {
- if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
- throw new GLException("Error freeing temp OpenGL context");
- }
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
// need to update the GL func table ..