From 6136457f10d020c779adc78641d0048f77ab1635 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 15 Jul 2013 22:49:47 +0200 Subject: Fix BuildComposablePipeline's isGL*/getGL* ; GLBase: getDownstreamGL()/getRootGL(); GLContext.isGL* added proper API doc., isGL3core()/hasNoDefaultVAO() and getDefaultVAO(). - Fix BuildComposablePipeline's isGL*/getGL* (regression of commit 3a0d7703da32e9a5ddf08a334f18588a78038d880) - GLBase: getDownstreamGL()/getRootGL() Allows user traversing through pipelined GL instances. Also added getRootGL() to GLContext. - GLContext.isGL* added proper API doc.: We test the actual context, not the profile. - GLContext isGL3core()/hasNoDefaultVAO() and getDefaultVAO() - Move isGL3code() def. back to pre 3a0d7703da32e9a5ddf08a334f18588a78038d880, i.e. Includes [ GL4, GL3 ] w/o GLES3. - Added hasNoDefaultVAO() and getDefaultVAO() .. incl. [ GL4, GL3, GLES3 ] --- src/jogl/classes/javax/media/opengl/GLContext.java | 121 ++++++++++++++++++--- 1 file changed, 105 insertions(+), 16 deletions(-) (limited to 'src/jogl/classes/javax/media/opengl/GLContext.java') 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.1

Includes [ GL4, GL3, GLES3 ].

*/ + /** + * Indicates whether this GLContext is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1

Includes [ 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() ; } -- cgit v1.2.3