diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl')
5 files changed, 44 insertions, 73 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java index e5f8211c3..91530e078 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java @@ -438,6 +438,7 @@ public abstract class GLContextImpl extends GLContext { private void createContextARBMapVersionsAvailable(int reqMajor, boolean compat) { long _context; + int reqProfile = compat ? CTX_PROFILE_COMPAT : CTX_PROFILE_CORE ; int ctp = CTX_IS_ARB_CREATED | CTX_PROFILE_CORE | CTX_OPTION_ANY; // default if(compat) { ctp &= ~CTX_PROFILE_CORE ; @@ -495,7 +496,7 @@ public abstract class GLContextImpl extends GLContext { } if(0!=_context) { destroyContextARBImpl(_context); - mapVersionAvailable(reqMajor, compat, major[0], minor[0], ctp); + mapVersionAvailable(reqMajor, reqProfile, major[0], minor[0], ctp); } } @@ -532,8 +533,7 @@ public abstract class GLContextImpl extends GLContext { */ protected void setContextVersion(int major, int minor, int ctp) { if (0==ctp) { - GLException e = new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); - throw e; + throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } if(major>0 || minor>0) { if (!GLContext.isValidGLVersion(major, minor)) { @@ -543,7 +543,7 @@ public abstract class GLContextImpl extends GLContext { ctxMajorVersion = major; ctxMinorVersion = minor; ctxOptions = ctp; - ctxVersionString = getGLVersion(gl, ctxMajorVersion, ctxMinorVersion, ctxOptions, getGL().glGetString(GL.GL_VERSION)); + ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, getGL().glGetString(GL.GL_VERSION)); return; } @@ -560,46 +560,12 @@ public abstract class GLContextImpl extends GLContext { ctxMajorVersion = version.getMajor(); ctxMinorVersion = version.getMinor(); - ctxVersionString = getGLVersion(gl, ctxMajorVersion, ctxMinorVersion, ctxOptions, versionStr); + ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, versionStr); return; } } } - private static boolean appendString(StringBuffer sb, String string, boolean needColon, boolean condition) { - if(condition) { - if(needColon) { - sb.append(", "); - } - sb.append(string); - needColon=true; - } - return needColon; - } - - protected static String getGLVersion(GL gl, int major, int minor, int ctp, String gl_version) { - boolean needColon = false; - StringBuffer sb = new StringBuffer(); - sb.append(major); - sb.append("."); - sb.append(minor); - sb.append(" ("); - needColon = appendString(sb, "ES", needColon, null!=gl && gl.isGLES()); - needColon = appendString(sb, "compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp )); - needColon = appendString(sb, "core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp )); - needColon = appendString(sb, "forward compatible", needColon, 0 != ( CTX_OPTION_FORWARD & ctp )); - needColon = appendString(sb, "any", needColon, 0 != ( CTX_OPTION_ANY & ctp )); - needColon = appendString(sb, "new", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp )); - needColon = appendString(sb, "old", needColon, 0 == ( CTX_IS_ARB_CREATED & ctp )); - sb.append(") - "); - if(null!=gl_version) { - sb.append(gl_version); - } else { - sb.append("n/a"); - } - return sb.toString(); - } - //---------------------------------------------------------------------- // Helpers for various context implementations // diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java index 144c4692e..95301b9d0 100755 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java @@ -116,7 +116,7 @@ public abstract class EGLContext extends GLContextImpl { } if (created) { - setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY); + setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_ES|CTX_OPTION_ANY); return CONTEXT_CURRENT_NEW; } return CONTEXT_CURRENT; @@ -226,7 +226,7 @@ public abstract class EGLContext extends GLContextImpl { throw new GLException("Error making context 0x" + Long.toHexString(eglContext) + " current: error code " + EGL.eglGetError()); } - setGLFunctionAvailability(true, glProfile.usesNativeGLES2()?2:1, 0, CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY); + setGLFunctionAvailability(true, glProfile.usesNativeGLES2()?2:1, 0, CTX_PROFILE_ES|CTX_OPTION_ANY); } public boolean isCreated() { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java index 5a8454ea7..b289aa9ce 100755 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java @@ -47,7 +47,7 @@ public class EGLExternalContext extends EGLContext { public EGLExternalContext(AbstractGraphicsScreen screen) { super(null, null); GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_IS_ARB_CREATED|CTX_PROFILE_ES|CTX_PROFILE_CORE|CTX_OPTION_ANY); + setGLFunctionAvailability(false, 0, 0, CTX_IS_ARB_CREATED|CTX_PROFILE_ES|CTX_OPTION_ANY); getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java index b59cb7940..489e4c860 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -143,46 +143,49 @@ public class WindowsWGLContext extends GLContextImpl { long _context=0; + final int idx_flags = 4; + final int idx_profile = 6; + + /* WGLExt.WGL_CONTEXT_LAYER_PLANE_ARB, WGLExt.WGL_CONTEXT_LAYER_PLANE_ARB, */ + int attribs[] = { /* 0 */ WGLExt.WGL_CONTEXT_MAJOR_VERSION_ARB, major, /* 2 */ WGLExt.WGL_CONTEXT_MINOR_VERSION_ARB, minor, - /* 4 */ WGLExt.WGL_CONTEXT_LAYER_PLANE_ARB, WGLExt.WGL_CONTEXT_LAYER_PLANE_ARB, // default - /* 6 */ WGLExt.WGL_CONTEXT_FLAGS_ARB, 0, - /* 8 */ 0, 0, - /* 10 */ 0 + /* 4 */ WGLExt.WGL_CONTEXT_FLAGS_ARB, 0, + /* 6 */ 0, 0, + /* 8 */ 0 }; if ( major > 3 || major == 3 && minor >= 2 ) { // FIXME: Verify with a None drawable binding (default framebuffer) - attribs[8+0] = WGLExt.WGL_CONTEXT_PROFILE_MASK_ARB; + attribs[idx_profile+0] = WGLExt.WGL_CONTEXT_PROFILE_MASK_ARB; if( ctBwdCompat ) { - attribs[8+1] = WGLExt.WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + attribs[idx_profile+1] = WGLExt.WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; } else { - attribs[8+1] = WGLExt.WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + attribs[idx_profile+1] = WGLExt.WGL_CONTEXT_CORE_PROFILE_BIT_ARB; } } if ( major >= 3 ) { if( !ctBwdCompat && ctFwdCompat ) { - attribs[6+1] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + attribs[idx_flags+1] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; } if( ctDebug) { - attribs[6+1] |= WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB; + attribs[idx_flags+1] |= WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB; } } _context = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), share, attribs, 0); - if(0==_context) { - if(DEBUG) { - System.err.println("WindowsWGLContext.createContextARB couldn't create "+getGLVersion(null, major, minor, ctp, "@creation")); - } - } else { + if(DEBUG) { + System.err.println("WindowsWGLContext.createContextARB success: "+(0!=_context)+" - "+getGLVersion(major, minor, ctp, "@creation")+", bwdCompat "+ctBwdCompat+", fwdCompat "+ctFwdCompat); + } + if(0!=_context) { // In contrast to GLX no verification with a drawable binding, ie default framebuffer, is necessary, // if no 3.2 is available creation fails already! // Nevertheless .. we do it .. if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), _context)) { if(DEBUG) { - System.err.println("WindowsWGLContext.createContextARB couldn't make current "+getGLVersion(null, major, minor, ctp, "@creation")); + System.err.println("WindowsWGLContext.createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation")); } WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(_context); @@ -270,10 +273,10 @@ public class WindowsWGLContext extends GLContextImpl { if(glCaps.getGLProfile().isGL3()) { WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_hglrc); - throw new GLException("WindowsWGLContext.createContext failed, but context > GL2 requested "+getGLVersion(null, major[0], minor[0], ctp[0], "@creation")+", "); + throw new GLException("WindowsWGLContext.createContext failed, but context > GL2 requested "+getGLVersion(major[0], minor[0], ctp[0], "@creation")+", "); } if(DEBUG) { - System.err.println("WindowsWGLContext.createContext failed, fall back to !ARB context "+getGLVersion(null, major[0], minor[0], ctp[0], "@creation")); + System.err.println("WindowsWGLContext.createContext failed, fall back to !ARB context "+getGLVersion(major[0], minor[0], ctp[0], "@creation")); } // continue with temp context for GL < 3.0 diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java index cdb7931d1..9c3efea2e 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java @@ -148,6 +148,9 @@ public abstract class X11GLXContext extends GLContextImpl { long _context=0; + final int idx_flags = 6; + final int idx_profile = 8; + int attribs[] = { /* 0 */ GLX.GLX_CONTEXT_MAJOR_VERSION_ARB, major, /* 2 */ GLX.GLX_CONTEXT_MINOR_VERSION_ARB, minor, @@ -159,20 +162,20 @@ public abstract class X11GLXContext extends GLContextImpl { if ( major > 3 || major == 3 && minor >= 2 ) { // FIXME: Verify with a None drawable binding (default framebuffer) - attribs[8+0] = GLX.GLX_CONTEXT_PROFILE_MASK_ARB; + attribs[idx_profile+0] = GLX.GLX_CONTEXT_PROFILE_MASK_ARB; if( ctBwdCompat ) { - attribs[8+1] = GLX.GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + attribs[idx_profile+1] = GLX.GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; } else { - attribs[8+1] = GLX.GLX_CONTEXT_CORE_PROFILE_BIT_ARB; + attribs[idx_profile+1] = GLX.GLX_CONTEXT_CORE_PROFILE_BIT_ARB; } } if ( major >= 3 ) { if( !ctBwdCompat && ctFwdCompat ) { - attribs[6+1] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + attribs[idx_flags+1] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; } if( ctDebug) { - attribs[6+1] |= GLX.GLX_CONTEXT_DEBUG_BIT_ARB; + attribs[idx_flags+1] |= GLX.GLX_CONTEXT_DEBUG_BIT_ARB; } } @@ -180,21 +183,20 @@ public abstract class X11GLXContext extends GLContextImpl { _context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0); } catch (RuntimeException re) { if(DEBUG) { - System.err.println("X11GLXContext.createContextARB glXCreateContextAttribsARB failed: "+re+", with "+getGLVersion(null, major, minor, ctp, "@creation")); + System.err.println("X11GLXContext.createContextARB glXCreateContextAttribsARB failed: "+re+", with "+getGLVersion(major, minor, ctp, "@creation")); re.printStackTrace(); } } - if(0==_context) { - if(DEBUG) { - System.err.println("X11GLXContext.createContextARB couldn't create "+getGLVersion(null, major, minor, ctp, "@creation")); - } - } else { + if(DEBUG) { + System.err.println("X11GLXContext.createContextARB success: "+(0!=_context)+" - "+getGLVersion(major, minor, ctp, "@creation")+", bwdCompat "+ctBwdCompat+", fwdCompat "+ctFwdCompat); + } + if(0!=_context) { if (!glXMakeContextCurrent(display, drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), _context)) { if(DEBUG) { - System.err.println("X11GLXContext.createContextARB couldn't make current "+getGLVersion(null, major, minor, ctp, "@creation")); + System.err.println("X11GLXContext.createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation")); } glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, _context); @@ -312,10 +314,10 @@ public abstract class X11GLXContext extends GLContextImpl { if(glp.isGL3()) { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, temp_context); - throw new GLException("X11GLXContext.createContext failed, but context > GL2 requested "+getGLVersion(null, major[0], minor[0], ctp[0], "@creation")+", "); + throw new GLException("X11GLXContext.createContext failed, but context > GL2 requested "+getGLVersion(major[0], minor[0], ctp[0], "@creation")+", "); } if(DEBUG) { - System.err.println("X11GLXContext.createContext failed, fall back to !ARB context "+getGLVersion(null, major[0], minor[0], ctp[0], "@creation")); + System.err.println("X11GLXContext.createContext failed, fall back to !ARB context "+getGLVersion(major[0], minor[0], ctp[0], "@creation")); } // continue with temp context for GL <= 3.0 |