From eced1d4e45772a862d649e3cd7b500c6bc1643a1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 6 Mar 2015 10:01:02 +0100 Subject: Bug 1135 - GL/GLContext: Add isGLES31Compatible() --- src/jogl/classes/com/jogamp/opengl/GLContext.java | 47 ++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/GLContext.java') diff --git a/src/jogl/classes/com/jogamp/opengl/GLContext.java b/src/jogl/classes/com/jogamp/opengl/GLContext.java index 6366c4e37..5ecd5e1e1 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/GLContext.java @@ -193,10 +193,13 @@ public abstract class GLContext { // /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ - protected static final int CTX_IMPL_ES2_COMPAT = 1 << 10; + protected static final int CTX_IMPL_ES2_COMPAT = 1 << 10; /** GL_ARB_ES3_compatibility implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ - protected static final int CTX_IMPL_ES3_COMPAT = 1 << 11; + protected static final int CTX_IMPL_ES3_COMPAT = 1 << 11; + + /** GL_ARB_ES3_1_compatibility implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES31Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + protected static final int CTX_IMPL_ES31_COMPAT = 1 << 12; /** * Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. @@ -204,7 +207,7 @@ public abstract class GLContext { * @see #hasBasicFBOSupport() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ - protected static final int CTX_IMPL_FBO = 1 << 12; + protected static final int CTX_IMPL_FBO = 1 << 13; /** * Context supports OES_single_precision, fp32, fixed function point (FFP) compatibility entry points, @@ -213,7 +216,7 @@ public abstract class GLContext { * @see #hasFP32CompatAPI() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ - protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 13; + protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 14; private static final ThreadLocal currentContext = new ThreadLocal(); @@ -910,6 +913,17 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ; } + /** + * Return true if this context is an ES3 context ≥ 3.1 or implements + * the extension GL_ARB_ES3_1_compatibility, otherwise false. + *

+ * Includes [ GL ≥ 4.5, GL ≥ 3.1 w/ GL_ARB_ES3_1_compatibility and GLES3 ≥ 3.1 ] + *

+ */ + public final boolean isGLES31Compatible() { + return 0 != ( ctxOptions & CTX_IMPL_ES31_COMPAT ) ; + } + /** * @return true if impl. is a hardware rasterizer, otherwise false. * @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile) @@ -988,7 +1002,7 @@ public abstract class GLContext { final GL gl = getGL(); final int[] val = new int[] { 0 } ; try { - gl.glGetIntegerv(GL2ES3.GL_MAX_SAMPLES, val, 0); + gl.glGetIntegerv(GL.GL_MAX_SAMPLES, val, 0); final int glerr = gl.glGetError(); if(GL.GL_NO_ERROR == glerr) { return val[0]; @@ -1958,6 +1972,29 @@ public abstract class GLContext { } return 0 != ( ctp[0] & CTX_IMPL_ES3_COMPAT ); } + /** + * Returns true if a ES3 ≥ 3.1 compatible profile is available, + * i.e. either a ≥ 4.5 context or a ≥ 3.1 context supporting GL_ARB_ES3_1_compatibility, + * otherwise false. + *

+ * Includes [ GL ≥ 4.5, GL ≥ 3.1 w/ GL_ARB_ES3_1_compatibility and GLES3 ≥ 3.1 ] + *

+ */ + public static final boolean isGLES31CompatibleAvailable(final AbstractGraphicsDevice device) { + final int major[] = { 0 }; + final int minor[] = { 0 }; + final int ctp[] = { 0 }; + boolean ok; + + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp); + if( !ok ) { + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp); + } + if( !ok ) { + GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_COMPAT, major, minor, ctp); + } + return 0 != ( ctp[0] & CTX_IMPL_ES31_COMPAT ); + } public static boolean isGL4bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[]) { return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware); -- cgit v1.2.3