From 3a0d7703da32e9a5ddf08a334f18588a78038d88 Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * Remark: ES3 compatible desktop profiles are not included.
+ * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}.
+ * GL_ARB_ES3_compatibility
, otherwise false
*/
- public boolean isGL2GL3();
+ public boolean isGLES3Compatible();
/** Indicates whether this GL object supports GLSL. */
public boolean hasGLSL();
@@ -209,6 +236,12 @@ public interface GLBase {
*/
public GLES2 getGLES2() throws GLException;
+ /**
+ * Casts this object to the GLES3 interface.
+ * @throws GLException if this GLObject is not a GLES3 implementation
+ */
+ public GLES3 getGLES3() throws GLException;
+
/**
* Casts this object to the GL2ES1 interface.
* @throws GLException if this GLObject is not a GL2ES1 implementation
@@ -221,6 +254,18 @@ public interface GLBase {
*/
public GL2ES2 getGL2ES2() throws GLException;
+ /**
+ * Casts this object to the GL3ES3 interface.
+ * @throws GLException if this GLObject is not a GL3ES3 implementation
+ */
+ public GL3ES3 getGL3ES3() throws GLException;
+
+ /**
+ * Casts this object to the GL4ES3 interface.
+ * @throws GLException if this GLObject is not a GL3ES3 implementation
+ */
+ public GL4ES3 getGL4ES3() throws GLException;
+
/**
* Casts this object to the GL2GL3 interface.
* @throws GLException if this GLObject is not a GL2GL3 implementation
--
cgit v1.2.3
From 6136457f10d020c779adc78641d0048f77ab1635 Mon Sep 17 00:00:00 2001
From: Sven Gothel
GL_ARB_ES2_compatibility
, otherwise false
+ * the extension GL_ARB_ES2_compatibility
, otherwise false
+ * @see GLContext#isGLES2Compatible()
*/
public boolean isGLES2Compatible();
@@ -182,93 +197,117 @@ public interface GLBase {
* Indicates whether this GL object is compatible with the core OpenGL ES3 functionality.
* @return true if this context is an ES3 context or implements
* the extension GL_ARB_ES3_compatibility
, otherwise false
+ * @see GLContext#isGLES3Compatible()
*/
public boolean isGLES3Compatible();
- /** Indicates whether this GL object supports GLSL. */
+ /**
+ * Indicates whether this GL object supports GLSL.
+ * @see GLContext#hasGLSL()
+ */
public boolean hasGLSL();
+ /**
+ * Returns the downstream GL instance in case this is a wrapping pipeline, otherwise null
.
+ * + * See {@link #getRootGL()} for retrieving the implementing root instance. + *
+ * @throws GLException if the downstream instance is not null and not a GL implementation + * @see #getRootGL() + */ + public GL getDownstreamGL() throws GLException; + + /** + * Returns the implementing root instance, considering a wrapped pipelined hierarchy, see {@link #getDownstreamGL()}. + *+ * If this instance is not a wrapping pipeline, i.e. has no downstream instance, + * this instance is returned. + *
+ * @throws GLException if the root instance is not a GL implementation + */ + public GL getRootGL() throws GLException; + /** * Casts this object to the GL interface. - * @throws GLException if this GLObject is not a GL implementation + * @throws GLException if this object is not a GL implementation */ public GL getGL() throws GLException; /** * Casts this object to the GL4bc interface. - * @throws GLException if this GLObject is not a GL4bc implementation + * @throws GLException if this object is not a GL4bc implementation */ public GL4bc getGL4bc() throws GLException; /** * Casts this object to the GL4 interface. - * @throws GLException if this GLObject is not a GL4 implementation + * @throws GLException if this object is not a GL4 implementation */ public GL4 getGL4() throws GLException; /** * Casts this object to the GL3bc interface. - * @throws GLException if this GLObject is not a GL3bc implementation + * @throws GLException if this object is not a GL3bc implementation */ public GL3bc getGL3bc() throws GLException; /** * Casts this object to the GL3 interface. - * @throws GLException if this GLObject is not a GL3 implementation + * @throws GLException if this object is not a GL3 implementation */ public GL3 getGL3() throws GLException; /** * Casts this object to the GL2 interface. - * @throws GLException if this GLObject is not a GL2 implementation + * @throws GLException if this object is not a GL2 implementation */ public GL2 getGL2() throws GLException; /** * Casts this object to the GLES1 interface. - * @throws GLException if this GLObject is not a GLES1 implementation + * @throws GLException if this object is not a GLES1 implementation */ public GLES1 getGLES1() throws GLException; /** * Casts this object to the GLES2 interface. - * @throws GLException if this GLObject is not a GLES2 implementation + * @throws GLException if this object is not a GLES2 implementation */ public GLES2 getGLES2() throws GLException; /** * Casts this object to the GLES3 interface. - * @throws GLException if this GLObject is not a GLES3 implementation + * @throws GLException if this object is not a GLES3 implementation */ public GLES3 getGLES3() throws GLException; /** * Casts this object to the GL2ES1 interface. - * @throws GLException if this GLObject is not a GL2ES1 implementation + * @throws GLException if this object is not a GL2ES1 implementation */ public GL2ES1 getGL2ES1() throws GLException; /** * Casts this object to the GL2ES2 interface. - * @throws GLException if this GLObject is not a GL2ES2 implementation + * @throws GLException if this object is not a GL2ES2 implementation */ public GL2ES2 getGL2ES2() throws GLException; /** * Casts this object to the GL3ES3 interface. - * @throws GLException if this GLObject is not a GL3ES3 implementation + * @throws GLException if this object is not a GL3ES3 implementation */ public GL3ES3 getGL3ES3() throws GLException; /** * Casts this object to the GL4ES3 interface. - * @throws GLException if this GLObject is not a GL3ES3 implementation + * @throws GLException if this object is not a GL3ES3 implementation */ public GL4ES3 getGL4ES3() throws GLException; /** * Casts this object to the GL2GL3 interface. - * @throws GLException if this GLObject is not a GL2GL3 implementation + * @throws GLException if this object is not a GL2GL3 implementation */ public GL2GL3 getGL2GL3() throws GLException; diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index b27db18af..9d383c371 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -503,6 +503,17 @@ public abstract class GLContext { */ public abstract void destroy(); + /** + * Returns the implementing root GL instance of this GLContext's GL object, + * considering a wrapped pipelined hierarchy, see {@link GLBase#getDownstreamGL()}. + * @throws GLException if the root instance is not a GL implementation + * @see GLBase#getRootGL() + * @see GLBase#getDownstreamGL() + * @see #getGL() + * @see #setGL(GL) + */ + public abstract GL getRootGL(); + /** * Returns the GL pipeline object for this GLContext. * @@ -915,40 +926,83 @@ public abstract class GLContext { isExtensionAvailable(GLExtensions.IMG_texture_format_BGRA8888) ; } - /** @see GLProfile#isGL4bc() */ + /** + * Indicates whether this GLContext is capable of GL4bc.Includes [ GL4bc ].
+ * @see GLProfile#isGL4bc() + */ public final boolean isGL4bc() { return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_COMPAT); } - /** @see GLProfile#isGL4() */ + /** + * Indicates whether this GLContext is capable of GL4.Includes [ GL4bc, GL4 ].
+ * @see GLProfile#isGL4() + */ public final boolean isGL4() { return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } - /** Indicates whether this profile is capable of GL4 (core only).Includes [ GL4 ].
*/ + /** + * Indicates whether this GLContext is capable of GL4 (core only).Includes [ GL4 ].
+ */ public final boolean isGL4core() { return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_CORE); } - /** @see GLProfile#isGL3bc() */ + /** + * Indicates whether this GLContext is capable of GL3bc.Includes [ GL4bc, GL3bc ].
+ * @see GLProfile#isGL3bc() + */ public final boolean isGL3bc() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_COMPAT) && ctxVersion.compareTo(Version310) >= 0 ; } - /** @see GLProfile#isGL3() */ + /** + * Indicates whether this GLContext is capable of GL3.Includes [ GL4bc, GL4, GL3bc, GL3 ].
+ * @see GLProfile#isGL3() + */ public final boolean isGL3() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) && ctxVersion.compareTo(Version310) >= 0 ; } - /** Indicates whether this profile is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1Includes [ GL4, GL3, GLES3 ].
*/ + /** + * Indicates whether this GLContext is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1Includes [ GL4, GL3 ].
+ */ public final boolean isGL3core() { + return 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) && + 0 != ( ctxOptions & CTX_PROFILE_CORE ) && + ctxVersion.compareTo(Version310) >= 0; + } + + /** + * Indicates whether this GLContext's native profile does not implement a default vertex array object (VAO), + * starting w/ OpenGL 3.1 core and GLES3. + *Includes [ GL4, GL3, GLES3 ].
+ *+ Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296), + GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) + there is no more default VAO buffer 0 bound, hence generating and binding one + to avoid INVALID_OPERATION at VertexAttribPointer. + More clear is GL 4.3 core spec: 10.4 (p 307). + *+ *
+ GLES3 is included, since upcoming ES releases > 3.0 may behave the same: + GL ES 3.0 spec F.1. Legacy Features (p 322). + *+ *
+ * If no default VAO is implemented in the native OpenGL profile, + * an own default VAO is being used, see {@link #getDefaultVAO()}. + *
+ * @see #getDefaultVAO() + */ + public final boolean hasNoDefaultVAO() { return ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ) || ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) && 0 != ( ctxOptions & CTX_PROFILE_CORE ) && @@ -956,52 +1010,87 @@ public abstract class GLContext { ) ; } - /** @see GLProfile#isGL2() */ + /** + * If this GLContext does not implement a default VAO, see {@link #hasNoDefaultVAO()}, + * an own default VAO will be created and bound at context creation. + *
+ * If this GLContext does implement a default VAO, i.e. {@link #hasNoDefaultVAO()}
+ * returns false
, this method returns 0
.
+ *
+ * Otherwise this method returns the VAO object name + * representing this GLContext's own default VAO. + *
+ * @see #hasNoDefaultVAO() + */ + public abstract int getDefaultVAO(); + + /** + * @see GLProfile#isGL2() + */ public final boolean isGL2() { return 0 != ( ctxOptions & CTX_PROFILE_COMPAT ) && ctxVersion.getMajor()>=1 ; } - /** @see GLProfile#isGL2GL3() */ + /** + * @see GLProfile#isGL2GL3() + */ public final boolean isGL2GL3() { return isGL2() || isGL3(); } - /** @see GLProfile#isGLES1() */ + /** + * @see GLProfile#isGLES1() + */ public final boolean isGLES1() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ; } - /** @see GLProfile#isGLES2() */ + /** + * @see GLProfile#isGLES2() + */ public final boolean isGLES2() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ; } - /** @see GLProfile#isGLES3() */ + /** + * @see GLProfile#isGLES3() + */ public final boolean isGLES3() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ; } - /** @see GLProfile#isGLES() */ + /** + * @see GLProfile#isGLES() + */ public final boolean isGLES() { return 0 != ( CTX_PROFILE_ES & ctxOptions ) ; } - /** @see GLProfile#isGL2ES1() */ + /** + * @see GLProfile#isGL2ES1() + */ public final boolean isGL2ES1() { return isGLES1() || isGL2(); } - /** @see GLProfile#isGL2ES2() */ + /** + * @see GLProfile#isGL2ES2() + */ public final boolean isGL2ES2() { return isGLES2() || isGL2GL3(); } - /** @see GLProfile#isGL3ES3() */ + /** + * @see GLProfile#isGL3ES3() + */ public final boolean isGL3ES3() { return isGL4ES3() || isGL3(); } - /** @see GLProfile#isGL4ES3() */ + /** + * @see GLProfile#isGL4ES3() + */ public final boolean isGL4ES3() { return isGL4() || isGLES3() ; } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 18e136815..5da60597e 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -67,8 +67,8 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL2ES3; import javax.media.opengl.GL2GL3; +import javax.media.opengl.GL3ES3; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDebugListener; @@ -262,6 +262,17 @@ public abstract class GLContextImpl extends GLContext { return (GLDrawableImpl) getGLDrawable(); } + @Override + public final GL getRootGL() { + GL _gl = gl; + GL _parent = _gl.getDownstreamGL(); + while ( null != _parent ) { + _gl = _parent; + _parent = _gl.getDownstreamGL(); + } + return _gl; + } + @Override public final GL getGL() { return gl; @@ -279,6 +290,11 @@ public abstract class GLContextImpl extends GLContext { return gl; } + @Override + public final int getDefaultVAO() { + return defaultVAO; + } + /** * Call this method to notify the OpenGL context * that the drawable has changed (size or position). @@ -399,7 +415,7 @@ public abstract class GLContextImpl extends GLContext { } if ( 0 != defaultVAO ) { final int[] tmp = new int[] { defaultVAO }; - final GL2ES3 gl3es3 = gl.getGL3ES3(); + final GL3ES3 gl3es3 = gl.getRootGL().getGL3ES3(); gl3es3.glBindVertexArray(0); gl3es3.glDeleteVertexArrays(1, tmp, 0); defaultVAO = 0; @@ -636,14 +652,9 @@ public abstract class GLContextImpl extends GLContext { final boolean created; try { created = createImpl(shareWith); // may throws exception if fails! - if( created && isGL3core() ) { - // Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296), - // GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) - // there is no more default VAO buffer 0 bound, hence generating and binding one - // to avoid INVALID_OPERATION at VertexAttribPointer. - // More clear is GL 4.3 core spec: 10.4 (p 307). + if( created && hasNoDefaultVAO() ) { final int[] tmp = new int[1]; - final GL2ES3 gl3es3 = gl.getGL3ES3(); + final GL3ES3 gl3es3 = gl.getRootGL().getGL3ES3(); gl3es3.glGenVertexArrays(1, tmp, 0); defaultVAO = tmp[0]; gl3es3.glBindVertexArray(defaultVAO); @@ -1955,10 +1966,6 @@ public abstract class GLContextImpl extends GLContext { return glStateTracker; } - public final boolean isDefaultVAO(int vao) { - return defaultVAO == vao; - } - //--------------------------------------------------------------------------- // Helpers for context optimization where the last context is left // current on the OpenGL worker thread -- cgit v1.2.3 From 5dafc958385da595160dc0d3c843c8253334c3c5 Mon Sep 17 00:00:00 2001 From: Sven GothelIncludes [ GL4 ].
+ * @see GLContext#isGL4core() + */ + public boolean isGL4core(); + + /** + * Indicates whether this GL object uses a GL3 core profile.Includes [ GL4, GL3 ].
+ * @see GLContext#isGL3core() + */ + public boolean isGL3core(); + + /** + * Indicates whether this GL object uses a GL core profile.Includes [ GL4, GL3, GLES3, GL2ES2 ].
+ * @see GLContext#isGLcore() + */ + public boolean isGLcore(); + /** * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality. * @return true if this context is an ES2 context or implements diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index d94531221..c3e82e6ee 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -934,8 +934,9 @@ public abstract class GLContext { * @see GLProfile#isGL4bc() */ public final boolean isGL4bc() { - return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & CTX_PROFILE_COMPAT); + return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && + 0 != (ctxOptions & CTX_PROFILE_COMPAT) && + ctxVersion.getMajor() >= 4; } /** @@ -943,16 +944,18 @@ public abstract class GLContext { * @see GLProfile#isGL4() */ public final boolean isGL4() { - return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); + return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && + 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) && + ctxVersion.getMajor() >= 4; } /** - * Indicates whether this GLContext is capable of GL4 (core only).Includes [ GL4 ].
+ * Indicates whether this GLContext uses a GL4 core profile.Includes [ GL4 ].
*/ public final boolean isGL4core() { - return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & CTX_PROFILE_CORE); + return 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) && + 0 != ( ctxOptions & CTX_PROFILE_CORE ) && + ctxVersion.getMajor() >= 4; } /** @@ -973,10 +976,10 @@ public abstract class GLContext { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) && ctxVersion.compareTo(Version310) >= 0 ; - } + } /** - * Indicates whether this GLContext is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1Includes [ GL4, GL3 ].
+ * Indicates whether this GLContext uses a GL3 core profile.Includes [ GL4, GL3 ].
*/ public final boolean isGL3core() { return 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) && @@ -984,6 +987,17 @@ public abstract class GLContext { ctxVersion.compareTo(Version310) >= 0; } + /** + * Indicates whether this GLContext uses a GL core profile.Includes [ GL4, GL3, GLES3, GL2ES2 ].
+ */ + public final boolean isGLcore() { + return ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ) || + ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) && + 0 != ( ctxOptions & CTX_PROFILE_CORE ) && + ctxVersion.compareTo(Version310) >= 0 + ) ; + } + /** * Indicates whether this GLContext's native profile does not implement a default vertex array object (VAO), * starting w/ OpenGL 3.1 core and GLES3. @@ -1029,6 +1043,7 @@ public abstract class GLContext { public abstract int getDefaultVAO(); /** + * Indicates whether this GLContext is capable of GL2.Includes [ GL4bc, GL3bc, GL2 ].
* @see GLProfile#isGL2() */ public final boolean isGL2() { @@ -1036,6 +1051,7 @@ public abstract class GLContext { } /** + * Indicates whether this GLContext is capable of GL2GL3.Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].
* @see GLProfile#isGL2GL3() */ public final boolean isGL2GL3() { @@ -1043,13 +1059,15 @@ public abstract class GLContext { } /** + * Indicates whether this GLContext is capable of GLES1.Includes [ GLES1 ].
* @see GLProfile#isGLES1() */ public final boolean isGLES1() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ; } - /** + /** + * Indicates whether this GLContext is capable of GLES2.Includes [ GLES3, GLES2 ].
* @see GLProfile#isGLES2() */ public final boolean isGLES2() { @@ -1057,6 +1075,7 @@ public abstract class GLContext { } /** + * Indicates whether this GLContext is capable of GLES3.Includes [ GLES3 ].
* @see GLProfile#isGLES3() */ public final boolean isGLES3() { @@ -1064,6 +1083,7 @@ public abstract class GLContext { } /** + * Indicates whether this GLContext is capable of GLES.Includes [ GLES3, GLES1, GLES2 ].
* @see GLProfile#isGLES() */ public final boolean isGLES() { @@ -1071,6 +1091,7 @@ public abstract class GLContext { } /** + * Indicates whether this GLContext is capable of GL2ES1.Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].
* @see GLProfile#isGL2ES1() */ public final boolean isGL2ES1() { @@ -1078,6 +1099,7 @@ public abstract class GLContext { } /** + * Indicates whether this GLContext is capable of GL2ES2.Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].
* @see GLProfile#isGL2ES2() */ public final boolean isGL2ES2() { @@ -1085,6 +1107,7 @@ public abstract class GLContext { } /** + * Indicates whether this GLContext is capable of GL3ES3.Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].
* @see GLProfile#isGL3ES3() */ public final boolean isGL3ES3() { @@ -1092,6 +1115,7 @@ public abstract class GLContext { } /** + * Indicates whether this profile is capable of GL4ES3.Includes [ GL4bc, GL4, GLES3 ].
* @see GLProfile#isGL4ES3() */ public final boolean isGL4ES3() { -- cgit v1.2.3 From 1a20ef3aa1dc9acedd7da0475ee19d4c40b18498 Mon Sep 17 00:00:00 2001 From: Sven GothelIncludes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
* @see GLContext#isGL4ES3() */ public boolean isGL4ES3(); @@ -213,8 +214,13 @@ public interface GLBase { /** * Indicates whether this GL object is compatible with the core OpenGL ES3 functionality. - * @return true if this context is an ES3 context or implements - * the extensionGL_ARB_ES3_compatibility
, otherwise false
+ *
+ * Return true if the underlying context is an ES3 context or implements
+ * the extension GL_ARB_ES3_compatibility
, otherwise false.
+ *
+ * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ] + *
* @see GLContext#isGLES3Compatible() */ public boolean isGLES3Compatible(); @@ -319,7 +325,7 @@ public interface GLBase { /** * Casts this object to the GL4ES3 interface. - * @throws GLException if this object is not a GL3ES3 implementation + * @throws GLException if this object is not a GL4ES3 implementation */ public GL4ES3 getGL4ES3() throws GLException; diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index c3e82e6ee..0cf04d119 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -140,6 +140,9 @@ public abstract class GLContext { /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */ public static final VersionNumber Version320 = new VersionNumber(3, 2, 0); + /** Version 4.3. As an OpenGL version, it qualifies forGL_ARB_ES3_compatibility
*/
+ public static final VersionNumber Version430 = new VersionNumber(4, 3, 0);
+
protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0);
//
@@ -822,8 +825,11 @@ public abstract class GLContext {
}
/**
- * @return true if this context is an ES3 context or implements
- * the extension GL_ARB_ES3_compatibility
, otherwise false
+ * Return true if this context is an ES3 context or implements
+ * the extension GL_ARB_ES3_compatibility
, otherwise false.
+ * + * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ] + *
*/ public final boolean isGLES3Compatible() { return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ; @@ -1115,11 +1121,12 @@ public abstract class GLContext { } /** - * Indicates whether this profile is capable of GL4ES3.Includes [ GL4bc, GL4, GLES3 ].
- * @see GLProfile#isGL4ES3() + * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true. + *Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ * @see GLProfile#isGL4ES3() */ public final boolean isGL4ES3() { - return isGL4() || isGLES3() ; + return isGLES3Compatible() ; } /** @@ -1598,9 +1605,9 @@ public abstract class GLContext { */ protected static final void getRequestMajorAndCompat(final GLProfile glp, int[/*2*/] reqMajorCTP) { final GLProfile glpImpl = glp.getImpl(); - if(glpImpl.isGL4()) { + if( glpImpl.isGL4() ) { reqMajorCTP[0]=4; - } else if (glpImpl.isGL3()) { + } else if ( glpImpl.isGL3() || glpImpl.isGLES3() ) { reqMajorCTP[0]=3; } else if (glpImpl.isGLES1()) { reqMajorCTP[0]=1; @@ -1729,6 +1736,30 @@ public abstract class GLContext { return isGLVersionAvailable(device, 3, GLContext.CTX_PROFILE_ES, isHardware); } + /** + * Returns true if a ES3 compatible profile is available, + * i.e. either a ≥ 4.3 context or a ≥ 3.1 context supportingGL_ARB_ES3_compatibility
,
+ * otherwise false.
+ * + * Includes [ GL4 > 4.3, GL3 > 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]. + *
+ */ + public static final boolean isGLES3CompatibleAvailable(AbstractGraphicsDevice device) { + int major[] = { 0 }; + int minor[] = { 0 }; + int ctp[] = { 0 }; + boolean ok; + + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp); + if( !ok ) { + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_COMPAT, major, minor, ctp); + } + if( !ok ) { + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp); + } + return 0 != ( ctp[0] & CTX_IMPL_ES3_COMPAT ); + } + public static boolean isGL4bcAvailable(AbstractGraphicsDevice device, boolean isHardware[]) { return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware); } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index c2a24e975..51b822449 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -298,13 +298,6 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE); } - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); - } else { - sb.append(", GL4ES3 "); - } - sb.append(isAvailableImpl(map, GL4ES3)); - if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES3").append(indent); } else { @@ -349,13 +342,6 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_COMPAT); } - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); - } else { - sb.append(", GL2ES2 "); - } - sb.append(isAvailableImpl(map, GL2ES2)); - if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); } else { @@ -367,13 +353,6 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); } - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); - } else { - sb.append(", GL2ES1 "); - } - sb.append(isAvailableImpl(map, GL2ES1)); - if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); } else { @@ -385,6 +364,27 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); } + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); + } else { + sb.append(", GL4ES3 "); + } + sb.append(isAvailableImpl(map, GL4ES3)); + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); + } else { + sb.append(", GL2ES2 "); + } + sb.append(isAvailableImpl(map, GL2ES2)); + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); + } else { + sb.append(", GL2ES1 "); + } + sb.append(isAvailableImpl(map, GL2ES1)); + if(useIndent) { indentCount--; doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Profiles"); @@ -1922,24 +1922,37 @@ public class GLProfile { return GLES2; } } else if (GL4ES3.equals(profile)) { - final boolean es3HardwareRasterizer[] = new boolean[1]; - final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) ); - final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ; - if(hasGL234Impl) { - if(GLContext.isGL4Available(device, isHardwareRasterizer)) { - if(!gles3HWAvailable || isHardwareRasterizer[0]) { - return GL4; + final boolean gles3CompatAvail = GLContext.isGLES3CompatibleAvailable(device); + if( desktopCtxUndef || esCtxUndef || gles3CompatAvail ) { + final boolean es3HardwareRasterizer[] = new boolean[1]; + final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) ); + final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ; + if(hasGL234Impl) { + if(GLContext.isGL4Available(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL4; + } } - } - if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { - if(!gles3HWAvailable || isHardwareRasterizer[0]) { - return GL4bc; + if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL4bc; + } + } + if(GLContext.isGL3Available(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL3; + } + } + if( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL3bc; + } } } - } - if(gles3Available) { - isHardwareRasterizer[0] = es3HardwareRasterizer[0]; - return GLES3; + if(gles3Available) { + isHardwareRasterizer[0] = es3HardwareRasterizer[0]; + return GLES3; + } } } else if(GL2GL3.equals(profile)) { if(hasGL234Impl) { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 5da60597e..6f4f6f271 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1536,7 +1536,10 @@ public abstract class GLContextImpl extends GLContext { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; ctxProfileBits |= CTX_IMPL_FBO; } - } else if( isExtensionAvailable( GLExtensions.ARB_ES3_compatibility ) ) { + } else if( ( major > 4 || major == 4 && minor >= 3 ) || + ( ( major > 3 || major == 3 && minor >= 1 ) && isExtensionAvailable( GLExtensions.ARB_ES3_compatibility ) ) ) { + // See GLContext.isGLES3CompatibleAvailable(..)/isGLES3Compatible() + // Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ] ctxProfileBits |= CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ; ctxProfileBits |= CTX_IMPL_FBO; } else if( isExtensionAvailable( GLExtensions.ARB_ES2_compatibility ) ) { diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 537b32355..e85d67dea 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -49,6 +49,8 @@ import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; +import javax.media.opengl.GL3; +import javax.media.opengl.GL4ES3; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -56,6 +58,8 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLES2; +import javax.media.opengl.GLES3; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -830,23 +834,38 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind * A most simple JOGL AWT test entry */ public static void main(String args[]) { - boolean forceES2 = false; - boolean forceES3 = false; - boolean forceGL3 = false; - if( null != args ) { - for(int i=0; i