From 3a0d7703da32e9a5ddf08a334f18588a78038d88 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 15 Jul 2013 13:39:22 +0200 Subject: Add Support for GL 4.3 (Bug 716) and ES 3.0 (Bug 717) ES3 / GL4.3: - Update all EGL, GLX, WGL and GL (desktop and mobile) khronos headers to latest version. - GL3/gl3* -> GL/glcorearb* - Explicitly preserve ES2_compatibility and ES3_compatibility in header, most extension grouping was removed in new headers. - Always load all GLHeader to ensure proper extension association across all profiles. - Unified method signatures - Added GL_EXT_map_buffer_range to core - Using common 'glMapBufferImpl(..)' for all glMapBuffer(..) and glMapBufferRange(..) impl. - Init necessary fields of GL instances via 'finalizeInit()' called by reflection, if exist. This allows removing initialization checks, i.e. for all buffer validations. - BuildStaticGLInfo: Can handle new GL header structure, i.e. one CPP extenstion block incl. define + funcs. - GLJavaMethodBindingEmitter: Simply print the - No GL duplication due to new intermediate interfaces, see below - OO lineare inheritance (Added GL2ES3, GL3ES3 and GL4ES3 intemediates): GLBase - GL - GL2ES2 - GLES2 GLBase - GL - GL2ES2 - GL2GL3 - [ GL2, GL3 ] GLBase - GL - GL2ES2 - GL2ES3 - GL3ES3 - [ GL3 ] GLBase - GL - GL2ES2 - GL2ES3 - GL3ES3 - GL4ES3 - [ GLES3, GL4, .. ] - Expose 'usable' intermediate interfaces GL3ES3 and GL4ES3 in GLBase/GLProfile/GLContext via is*() and get*(). - GLContext*: - isGL3core() is true if [ GL4, GL3, GLES3 ] (added GLES3) - Added ctxProfile argument to allow handling ES versions: - getMaxMajor(..), getMaxMinor(..), isValidGLVersion(..) and decrementGLVersion(..) - mapGLVersions(..) prepared for ES ARB/KHR validation - EGLContext checks ES3 (via old ctx's GL_VERSION) - ExtensionAvailabilityCache adds GL_ES_Version_X_Y for ES. - Prelim tests w/ Mesa 9.1.3 GL Version 3.0 (ES profile, ES2 compat, ES3 compat, FBO, hardware) - OpenGL ES 3.0 Mesa 9.1.3 [GL 3.0.0, vendor 9.1.3 (Mesa 9.1.3)] - TODO: - Use KHR_create_context in EGLContext.createContextARBImpl(..) - More tests (Mobile, ..) +++ Misc: - GLContext*: - Complete glAllocateMemoryNV w/ glFreeMemoryNV. --- .../gluegen/opengl/BuildComposablePipeline.java | 42 ++++++++++------------ 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java') diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 5334d45cf..b9096df3c 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -71,7 +71,7 @@ public class BuildComposablePipeline { // Only desktop OpenGL has immediate mode glBegin / glEnd private boolean hasImmediateMode; // Desktop OpenGL and GLES1 have GL_STACK_OVERFLOW and GL_STACK_UNDERFLOW errors - private boolean hasStackOverflow; + private boolean hasGL2ES1StackOverflow; public static Class getClass(String name) { Class clazz = null; @@ -155,7 +155,7 @@ public class BuildComposablePipeline { } try { - hasStackOverflow = + hasGL2ES1StackOverflow = hasImmediateMode && (classToComposeAround.getField("GL_STACK_OVERFLOW") != null); } catch (Exception e) { } @@ -602,13 +602,9 @@ public class BuildComposablePipeline { * Emits one of the isGL* methods. */ protected void emitGLIsMethod(PrintWriter output, String type) { + output.println(" @Override"); output.println(" public boolean is" + type + "() {"); - Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); - if (clazz.isAssignableFrom(baseInterfaceClass)) { - output.println(" return true;"); - } else { - output.println(" return false;"); - } + output.println(" return " + getDownstreamObjectName() + ".is" + type + "();"); output.println(" }"); } @@ -624,28 +620,24 @@ public class BuildComposablePipeline { emitGLIsMethod(output, "GL2"); emitGLIsMethod(output, "GLES1"); emitGLIsMethod(output, "GLES2"); + emitGLIsMethod(output, "GLES3"); emitGLIsMethod(output, "GL2ES1"); emitGLIsMethod(output, "GL2ES2"); + emitGLIsMethod(output, "GL3ES3"); + emitGLIsMethod(output, "GL4ES3"); emitGLIsMethod(output, "GL2GL3"); - output.println(" public boolean isGLES() {"); - output.println(" return isGLES2() || isGLES1();"); - output.println(" }"); - output.println(" public boolean isGLES2Compatible() {"); - output.println(" return " + getDownstreamObjectName() + ".isGLES2Compatible();"); - output.println(" }"); + emitGLIsMethod(output, "GLES"); + emitGLIsMethod(output, "GLES2Compatible"); + emitGLIsMethod(output, "GLES3Compatible"); } /** * Emits one of the getGL* methods. */ protected void emitGLGetMethod(PrintWriter output, String type) { + output.println(" @Override"); output.println(" public javax.media.opengl." + type + " get" + type + "() {"); - Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); - if (clazz.isAssignableFrom(baseInterfaceClass)) { - output.println(" return this;"); - } else { - output.println(" throw new GLException(\"Not a " + type + " implementation\");"); - } + output.println(" return " + getDownstreamObjectName() + ".get" + type + "();"); output.println(" }"); } @@ -661,9 +653,13 @@ public class BuildComposablePipeline { emitGLGetMethod(output, "GL2"); emitGLGetMethod(output, "GLES1"); emitGLGetMethod(output, "GLES2"); + emitGLGetMethod(output, "GLES3"); emitGLGetMethod(output, "GL2ES1"); emitGLGetMethod(output, "GL2ES2"); + emitGLGetMethod(output, "GL3ES3"); + emitGLGetMethod(output, "GL4ES3"); emitGLGetMethod(output, "GL2GL3"); + output.println(" @Override"); output.println(" public GLProfile getGLProfile() {"); output.println(" return " + getDownstreamObjectName() + ".getGLProfile();"); output.println(" }"); @@ -870,9 +866,9 @@ public class BuildComposablePipeline { output.println(" case GL_INVALID_ENUM: buf.append(\"GL_INVALID_ENUM \"); break;"); output.println(" case GL_INVALID_VALUE: buf.append(\"GL_INVALID_VALUE \"); break;"); output.println(" case GL_INVALID_OPERATION: buf.append(\"GL_INVALID_OPERATION \"); break;"); - if (hasStackOverflow) { - output.println(" case GL_STACK_OVERFLOW: buf.append(\"GL_STACK_OVERFLOW \"); break;"); - output.println(" case GL_STACK_UNDERFLOW: buf.append(\"GL_STACK_UNDERFLOW \"); break;"); + if (hasGL2ES1StackOverflow) { + output.println(" case GL2ES1.GL_STACK_OVERFLOW: buf.append(\"GL_STACK_OVERFLOW \"); break;"); + output.println(" case GL2ES1.GL_STACK_UNDERFLOW: buf.append(\"GL_STACK_UNDERFLOW \"); break;"); } output.println(" case GL_OUT_OF_MEMORY: buf.append(\"GL_OUT_OF_MEMORY \"); break;"); output.println(" case GL_NO_ERROR: throw new InternalError(\"Should not be treating GL_NO_ERROR as error\");"); -- cgit v1.2.3 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 ] --- .../config/jogl/gl-impl-CustomJavaCode-common.java | 10 ++ make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 2 +- make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 2 +- .../gluegen/opengl/BuildComposablePipeline.java | 49 ++++++--- src/jogl/classes/javax/media/opengl/GLBase.java | 71 +++++++++--- src/jogl/classes/javax/media/opengl/GLContext.java | 121 ++++++++++++++++++--- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 33 +++--- 7 files changed, 228 insertions(+), 60 deletions(-) (limited to 'src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index 4024d8e1a..2254e5f0b 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -24,6 +24,16 @@ return checkElementVBOEnabled(false); } + @Override + public final GL getDownstreamGL() throws GLException { + return null; + } + + @Override + public final GL getRootGL() throws GLException { + return this; + } + @Override public final boolean isGL() { return true; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index cacea322a..5ac2837fa 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -287,7 +287,7 @@ private final boolean checkBufferObject(boolean extensionAvail, } if ( allowVAO ) { buffer = bufferStateTracker.getBoundBufferObject(GL2GL3.GL_VERTEX_ARRAY_BINDING, this); - if( 0 != buffer && !_context.isDefaultVAO(buffer) ) { + if( 0 != buffer && _context.getDefaultVAO() != buffer ) { return true; } } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java index e0b0c6a09..bb4a6246b 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -205,7 +205,7 @@ private final boolean checkBufferObject(boolean extensionAvail, } if ( allowVAO ) { buffer = bufferStateTracker.getBoundBufferObject(GLES3.GL_VERTEX_ARRAY_BINDING, this); - if( 0 != buffer && !_context.isDefaultVAO(buffer) ) { + if( 0 != buffer && _context.getDefaultVAO() != buffer ) { return true; } } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index b9096df3c..0bd3086c8 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -167,16 +167,16 @@ public class BuildComposablePipeline { */ public void emit() throws IOException { - List publicMethodsRaw = Arrays.asList(classToComposeAround.getMethods()); + final List publicMethodsRaw = Arrays.asList(classToComposeAround.getMethods()); - Set publicMethodsPlain = new HashSet(); + final Set publicMethodsPlain = new HashSet(); for (Iterator iter = publicMethodsRaw.iterator(); iter.hasNext();) { - Method method = iter.next(); + final Method method = iter.next(); // Don't hook methods which aren't real GL methods, // such as the synthetic "isGL2ES2" "getGL2ES2" - String name = method.getName(); + final String name = method.getName(); boolean runHooks = name.startsWith("gl"); - if (!name.startsWith("getGL") && !name.startsWith("isGL") && !name.equals("toString")) { + if ( !name.startsWith("getGL") && !name.startsWith("isGL") && !name.equals("getDownstreamGL") && !name.equals("toString") ) { publicMethodsPlain.add(new PlainMethod(method, runHooks)); } } @@ -603,8 +603,13 @@ public class BuildComposablePipeline { */ protected void emitGLIsMethod(PrintWriter output, String type) { output.println(" @Override"); - output.println(" public boolean is" + type + "() {"); - output.println(" return " + getDownstreamObjectName() + ".is" + type + "();"); + output.println(" public final boolean is" + type + "() {"); + final Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); + if (clazz.isAssignableFrom(baseInterfaceClass)) { + output.println(" return true;"); + } else { + output.println(" return false;"); + } output.println(" }"); } @@ -626,9 +631,18 @@ public class BuildComposablePipeline { emitGLIsMethod(output, "GL3ES3"); emitGLIsMethod(output, "GL4ES3"); emitGLIsMethod(output, "GL2GL3"); - emitGLIsMethod(output, "GLES"); - emitGLIsMethod(output, "GLES2Compatible"); - emitGLIsMethod(output, "GLES3Compatible"); + output.println(" @Override"); + output.println(" public final boolean isGLES() {"); + output.println(" return isGLES2() || isGLES1();"); + output.println(" }"); + output.println(" @Override"); + output.println(" public final boolean isGLES2Compatible() {"); + output.println(" return " + getDownstreamObjectName() + ".isGLES2Compatible();"); + output.println(" }"); + output.println(" @Override"); + output.println(" public final boolean isGLES3Compatible() {"); + output.println(" return " + getDownstreamObjectName() + ".isGLES3Compatible();"); + output.println(" }"); } /** @@ -636,8 +650,13 @@ public class BuildComposablePipeline { */ protected void emitGLGetMethod(PrintWriter output, String type) { output.println(" @Override"); - output.println(" public javax.media.opengl." + type + " get" + type + "() {"); - output.println(" return " + getDownstreamObjectName() + ".get" + type + "();"); + output.println(" public final javax.media.opengl." + type + " get" + type + "() {"); + final Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); + if (clazz.isAssignableFrom(baseInterfaceClass)) { + output.println(" return this;"); + } else { + output.println(" throw new GLException(\"Not a " + type + " implementation\");"); + } output.println(" }"); } @@ -660,7 +679,11 @@ public class BuildComposablePipeline { emitGLGetMethod(output, "GL4ES3"); emitGLGetMethod(output, "GL2GL3"); output.println(" @Override"); - output.println(" public GLProfile getGLProfile() {"); + output.println(" public final GL getDownstreamGL() throws GLException {"); + output.println(" return " + getDownstreamObjectName() + ";"); + output.println(" }"); + output.println(" @Override"); + output.println(" public final GLProfile getGLProfile() {"); output.println(" return " + getDownstreamObjectName() + ".getGLProfile();"); output.println(" }"); } diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index 49c5bf72d..fcfe34132 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -88,35 +88,41 @@ public interface GLBase { /** * Indicates whether this GL object conforms to the OpenGL ≥ 4.0 compatibility profile. * The GL4 compatibility profile includes the GL2, GL2ES1, GL2ES2, GL3, GL3bc and GL4 profile. + * @see GLContext#isGL4bc() */ public boolean isGL4bc(); /** * Indicates whether this GL object conforms to the OpenGL ≥ 4.0 core profile. * The GL4 core profile includes the GL2ES2, and GL3 profile. + * @see GLContext#isGL4() */ public boolean isGL4(); /** * Indicates whether this GL object conforms to the OpenGL ≥ 3.1 compatibility profile. * The GL3 compatibility profile includes the GL2, GL2ES1, GL2ES2 and GL3 profile. + * @see GLContext#isGL3bc() */ public boolean isGL3bc(); /** * Indicates whether this GL object conforms to the OpenGL ≥ 3.1 core profile. * The GL3 core profile includes the GL2ES2 profile. + * @see GLContext#isGL3() */ public boolean isGL3(); /** * Indicates whether this GL object conforms to the OpenGL ≤ 3.0 profile. * The GL2 profile includes the GL2ES1 and GL2ES2 profile. + * @see GLContext#isGL2() */ public boolean isGL2(); /** * Indicates whether this GL object conforms to the OpenGL ES1 ≥ 1.0 profile. + * @see GLContext#isGLES1() */ public boolean isGLES1(); @@ -127,6 +133,7 @@ public interface GLBase { * To query whether core ES2 functionality is provided, use {@link #isGLES2Compatible()}. *

* @see #isGLES2Compatible() + * @see GLContext#isGLES2() */ public boolean isGLES2(); @@ -137,44 +144,52 @@ public interface GLBase { * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}. *

* @see #isGLES3Compatible() + * @see GLContext#isGLES3() */ public boolean isGLES3(); /** * Indicates whether this GL object conforms to one of the OpenGL ES profiles, * see {@link #isGLES1()} and {@link #isGLES2()}. + * @see GLContext#isGLES() */ public boolean isGLES(); /** * Indicates whether this GL object conforms to a GL2ES1 compatible profile. + * @see GLContext#isGL2ES1() */ public boolean isGL2ES1(); /** * Indicates whether this GL object conforms to a GL2ES2 compatible profile. + * @see GLContext#isGL2ES2() */ public boolean isGL2ES2(); /** * Indicates whether this GL object conforms to a GL3ES3 compatible profile. + * @see GLContext#isGL3ES3() */ public boolean isGL3ES3(); /** * Indicates whether this GL object conforms to a GL4ES3 compatible profile. + * @see GLContext#isGL4ES3() */ public boolean isGL4ES3(); /** * Indicates whether this GL object conforms to a GL2GL3 compatible profile. + * @see GLContext#isGL2GL3() */ public boolean isGL2GL3(); /** * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality. * @return true if this context is an ES2 context or implements - * the extension 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.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() ; } 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 0002fccdcd6383874b2813dc6bbe3e33f5f00924 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 16 Jul 2013 03:46:59 +0200 Subject: Only use base pipelines for Trace/Debug, mock others (ES2, GL2, ..); BuildComposablePipeline: Unify GL identify methods - Only use base pipelines for Trace/Debug, mock others (ES2, GL2, ..) The Trace/Debug generated pipelines consume quite some space and only the actual GL*Impl pipeline is actually required. To make this work, we have to identify the GL type via it's downstream instance to implement isGL*() and getGL*() methods, see below! Adding dummy Trace/Debug type wrapper for GL2, GL3, GL3bc, GL4 and GLES2. BuildComposablePipeline: Unify GL identify methods As described above, Trace/Debug shall utilize downstream identification for isGL*() and getGL*() methods. Custom types, like FixedFuncImpl may choose to be identified by their class inheritance, by passing command-line argument 'gl_identity_by_assignable_class'. --- make/build-jogl.xml | 53 ++-------- .../gluegen/opengl/BuildComposablePipeline.java | 116 +++++++++++++++------ src/jogl/classes/javax/media/opengl/DebugGL2.java | 21 ++++ src/jogl/classes/javax/media/opengl/DebugGL3.java | 21 ++++ .../classes/javax/media/opengl/DebugGL3bc.java | 21 ++++ src/jogl/classes/javax/media/opengl/DebugGL4.java | 21 ++++ .../classes/javax/media/opengl/DebugGLES2.java | 21 ++++ .../javax/media/opengl/GLPipelineFactory.java | 20 +++- src/jogl/classes/javax/media/opengl/TraceGL2.java | 23 ++++ src/jogl/classes/javax/media/opengl/TraceGL3.java | 23 ++++ .../classes/javax/media/opengl/TraceGL3bc.java | 23 ++++ src/jogl/classes/javax/media/opengl/TraceGL4.java | 23 ++++ .../classes/javax/media/opengl/TraceGLES2.java | 23 ++++ 13 files changed, 329 insertions(+), 80 deletions(-) create mode 100644 src/jogl/classes/javax/media/opengl/DebugGL2.java create mode 100644 src/jogl/classes/javax/media/opengl/DebugGL3.java create mode 100644 src/jogl/classes/javax/media/opengl/DebugGL3bc.java create mode 100644 src/jogl/classes/javax/media/opengl/DebugGL4.java create mode 100644 src/jogl/classes/javax/media/opengl/DebugGLES2.java create mode 100644 src/jogl/classes/javax/media/opengl/TraceGL2.java create mode 100644 src/jogl/classes/javax/media/opengl/TraceGL3.java create mode 100644 src/jogl/classes/javax/media/opengl/TraceGL3bc.java create mode 100644 src/jogl/classes/javax/media/opengl/TraceGL4.java create mode 100644 src/jogl/classes/javax/media/opengl/TraceGLES2.java (limited to 'src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 7b9b8a957..31dcb2398 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -976,19 +976,19 @@ targetfile="${src.generated.java}/javax/media/opengl/DebugGL3.java" /> - + - + + includes="DebugGL4bc.java,TraceGL4bc.java" /> - + @@ -999,14 +999,6 @@ - - - - - - - - @@ -1015,35 +1007,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1051,7 +1015,7 @@ - + @@ -1078,6 +1042,7 @@ + diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 0bd3086c8..7659238fc 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -57,10 +57,31 @@ import java.util.Set; public class BuildComposablePipeline { - public static final int GEN_DEBUG = 1 << 0; // default - public static final int GEN_TRACE = 1 << 1; // default + /**

Default: true

. */ + public static final int GEN_DEBUG = 1 << 0; + /**

Default: true

. */ + public static final int GEN_TRACE = 1 << 1; + /**

Default: false

. */ public static final int GEN_CUSTOM = 1 << 2; + /** + * By extra command-line argument: prolog_xor_downstream. + *

+ * If true, either prolog (if exist) is called or downstream's method, but not both. + * By default, both methods would be called. + *

+ *

Default: false

+ */ public static final int GEN_PROLOG_XOR_DOWNSTREAM = 1 << 3; + /** + * By extra command-line argument: gl_identity_by_assignable_class. + *

+ * If true, implementation does not utilize downstream's isGL*() + * implementation, but determines whether the GL profile is matched by interface inheritance. + *

+ *

Default: false

+ */ + public static final int GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS = 1 << 4; + int mode; private String outputDir; private String outputPackage; @@ -110,8 +131,12 @@ public class BuildComposablePipeline { classDownstream = getClass(args[4]); mode = GEN_CUSTOM; if (args.length > 5) { - if (args[5].equals("prolog_xor_downstream")) { - mode |= GEN_PROLOG_XOR_DOWNSTREAM; + for(int i=5; i clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); - if (clazz.isAssignableFrom(baseInterfaceClass)) { - output.println(" return true;"); + if( 0 != (GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS & getMode() ) ) { + final Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); + if (clazz.isAssignableFrom(baseInterfaceClass)) { + output.println(" return true;"); + } else { + output.println(" return false;"); + } } else { - output.println(" return false;"); + output.println(" return " + getDownstreamObjectName() + ".is" + type + "();"); } output.println(" }"); } @@ -631,10 +660,14 @@ public class BuildComposablePipeline { emitGLIsMethod(output, "GL3ES3"); emitGLIsMethod(output, "GL4ES3"); emitGLIsMethod(output, "GL2GL3"); - output.println(" @Override"); - output.println(" public final boolean isGLES() {"); - output.println(" return isGLES2() || isGLES1();"); - output.println(" }"); + if( 0 != (GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS & getMode() ) ) { + output.println(" @Override"); + output.println(" public final boolean isGLES() {"); + output.println(" return isGLES2() || isGLES1();"); + output.println(" }"); + } else { + emitGLIsMethod(output, "GLES"); + } output.println(" @Override"); output.println(" public final boolean isGLES2Compatible() {"); output.println(" return " + getDownstreamObjectName() + ".isGLES2Compatible();"); @@ -651,11 +684,15 @@ public class BuildComposablePipeline { protected void emitGLGetMethod(PrintWriter output, String type) { output.println(" @Override"); output.println(" public final javax.media.opengl." + type + " get" + type + "() {"); - final Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); - if (clazz.isAssignableFrom(baseInterfaceClass)) { - output.println(" return this;"); + if( 0 != (GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS & getMode() ) ) { + final Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); + if (clazz.isAssignableFrom(baseInterfaceClass)) { + output.println(" return this;"); + } else { + output.println(" throw new GLException(\"Not a " + type + " implementation\");"); + } } else { - output.println(" throw new GLException(\"Not a " + type + " implementation\");"); + output.println(" return " + getDownstreamObjectName() + ".get" + type + "();"); } output.println(" }"); } @@ -921,15 +958,20 @@ public class BuildComposablePipeline { } protected void emitClassDocComment(PrintWriter output) { - output.println("/**

Composable pipeline which wraps an underlying {@link GL} implementation,"); - output.println(" providing error checking after each OpenGL method call. If an error occurs,"); - output.println(" causes a {@link GLException} to be thrown at exactly the point of failure."); - output.println(" Sample code which installs this pipeline:

"); - output.println(); - output.println("
");
-            output.println("     GL gl = drawable.setGL(new DebugGL(drawable.getGL()));");
-            output.println("
"); - output.println("*/"); + output.println("/**"); + output.println(" *

"); + output.println(" * Composable pipeline which wraps an underlying {@link GL} implementation,"); + output.println(" * providing error checking after each OpenGL method call. If an error occurs,"); + output.println(" * causes a {@link GLException} to be thrown at exactly the point of failure."); + output.println(" *

"); + output.println(" *

"); + output.println(" * Sample code which installs this pipeline:"); + output.println(" *

");
+            output.println(" *   gl = drawable.setGL(new DebugGL(drawable.getGL()));");
+            output.println(" * 
"); + output.println(" * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}"); + output.println(" *

"); + output.println(" */"); } protected boolean hasPreDownstreamCallHook(Method m) { @@ -1057,14 +1099,20 @@ public class BuildComposablePipeline { } protected void emitClassDocComment(PrintWriter output) { - output.println("/**

Composable pipeline which wraps an underlying {@link GL} implementation,"); - output.println(" providing tracing information to a user-specified {@link java.io.PrintStream}"); - output.println(" before and after each OpenGL method call. Sample code which installs this pipeline:

"); - output.println(); - output.println("
");
-            output.println("     GL gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));");
-            output.println("
"); - output.println("*/"); + output.println("/**"); + output.println(" *

"); + output.println(" * Composable pipeline which wraps an underlying {@link GL} implementation,"); + output.println(" * providing tracing information to a user-specified {@link java.io.PrintStream}"); + output.println(" * before and after each OpenGL method call."); + output.println(" *

"); + output.println(" *

"); + output.println(" * Sample code which installs this pipeline:"); + output.println(" *

");
+            output.println(" *   gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));");
+            output.println(" * 
"); + output.println(" * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}"); + output.println(" *

"); + output.println(" */"); } protected boolean hasPreDownstreamCallHook(Method m) { diff --git a/src/jogl/classes/javax/media/opengl/DebugGL2.java b/src/jogl/classes/javax/media/opengl/DebugGL2.java new file mode 100644 index 000000000..05bcf3d5e --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/DebugGL2.java @@ -0,0 +1,21 @@ +package javax.media.opengl; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing error checking after each OpenGL method call. If an error occurs, + * causes a {@link GLException} to be thrown at exactly the point of failure. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class DebugGL2 extends DebugGL4bc { + public DebugGL2(GL2 downstream) { + super((GL4bc)downstream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/DebugGL3.java b/src/jogl/classes/javax/media/opengl/DebugGL3.java new file mode 100644 index 000000000..c17f90667 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/DebugGL3.java @@ -0,0 +1,21 @@ +package javax.media.opengl; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing error checking after each OpenGL method call. If an error occurs, + * causes a {@link GLException} to be thrown at exactly the point of failure. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class DebugGL3 extends DebugGL4bc { + public DebugGL3(GL3 downstream) { + super((GL4bc)downstream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/DebugGL3bc.java b/src/jogl/classes/javax/media/opengl/DebugGL3bc.java new file mode 100644 index 000000000..6e294d42b --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/DebugGL3bc.java @@ -0,0 +1,21 @@ +package javax.media.opengl; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing error checking after each OpenGL method call. If an error occurs, + * causes a {@link GLException} to be thrown at exactly the point of failure. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class DebugGL3bc extends DebugGL4bc { + public DebugGL3bc(GL3bc downstream) { + super((GL4bc)downstream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/DebugGL4.java b/src/jogl/classes/javax/media/opengl/DebugGL4.java new file mode 100644 index 000000000..d21d39390 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/DebugGL4.java @@ -0,0 +1,21 @@ +package javax.media.opengl; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing error checking after each OpenGL method call. If an error occurs, + * causes a {@link GLException} to be thrown at exactly the point of failure. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class DebugGL4 extends DebugGL4bc { + public DebugGL4(GL4 downstream) { + super((GL4bc)downstream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/DebugGLES2.java b/src/jogl/classes/javax/media/opengl/DebugGLES2.java new file mode 100644 index 000000000..dee363c1b --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/DebugGLES2.java @@ -0,0 +1,21 @@ +package javax.media.opengl; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing error checking after each OpenGL method call. If an error occurs, + * causes a {@link GLException} to be thrown at exactly the point of failure. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class DebugGLES2 extends DebugGLES3 { + public DebugGLES2(GLES2 downstream) { + super((GLES3)downstream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java index 2bfc77d4a..c6bf26235 100644 --- a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java @@ -51,8 +51,23 @@ public class GLPipelineFactory { /** * Creates a pipelined GL instance using the given downstream downstream - * and optional arguments additionalArgs for the constructor.
+ * and optional arguments additionalArgs for the constructor. * + *

+ * Sample code which installs a Debug and Trace pipeline + * automatic w/ user defined interface, here: GL2ES2: + *

+     *     gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, gl, null) );
+     *     gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, gl, new Object[] { System.err } ) );
+     * 
+ * or automatic w/ automatic defined class: + *
+     *     gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Debug",         null, gl, null) );
+     *     gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Trace",         null, gl, new Object[] { System.err } ) );
+     * 
+ *

+ * + *

* The upstream GL instance is determined as follows: *

    *
  • Use pipelineClazzBaseName as the class name's full basename, incl. package name
  • @@ -65,7 +80,8 @@ public class GLPipelineFactory { *
  • If upstream class is available use it, end loop.
  • *
* - *
+ * + *

* * @param pipelineClazzBaseName the basename of the pipline class name * @param reqInterface optional requested interface to be used, may be null, in which case the first matching one is used diff --git a/src/jogl/classes/javax/media/opengl/TraceGL2.java b/src/jogl/classes/javax/media/opengl/TraceGL2.java new file mode 100644 index 000000000..58f5d9f99 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/TraceGL2.java @@ -0,0 +1,23 @@ +package javax.media.opengl; + +import java.io.PrintStream; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing tracing information to a user-specified {@link java.io.PrintStream} + * before and after each OpenGL method call. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class TraceGL2 extends TraceGL4bc { + public TraceGL2(GL2 downstream, PrintStream stream) { + super((GL4bc)downstream, stream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/TraceGL3.java b/src/jogl/classes/javax/media/opengl/TraceGL3.java new file mode 100644 index 000000000..616b31f61 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/TraceGL3.java @@ -0,0 +1,23 @@ +package javax.media.opengl; + +import java.io.PrintStream; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing tracing information to a user-specified {@link java.io.PrintStream} + * before and after each OpenGL method call. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class TraceGL3 extends TraceGL4bc { + public TraceGL3(GL3 downstream, PrintStream stream) { + super((GL4bc)downstream, stream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/TraceGL3bc.java b/src/jogl/classes/javax/media/opengl/TraceGL3bc.java new file mode 100644 index 000000000..f3761d4d6 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/TraceGL3bc.java @@ -0,0 +1,23 @@ +package javax.media.opengl; + +import java.io.PrintStream; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing tracing information to a user-specified {@link java.io.PrintStream} + * before and after each OpenGL method call. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class TraceGL3bc extends TraceGL4bc { + public TraceGL3bc(GL3bc downstream, PrintStream stream) { + super((GL4bc)downstream, stream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/TraceGL4.java b/src/jogl/classes/javax/media/opengl/TraceGL4.java new file mode 100644 index 000000000..a12bf0f47 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/TraceGL4.java @@ -0,0 +1,23 @@ +package javax.media.opengl; + +import java.io.PrintStream; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing tracing information to a user-specified {@link java.io.PrintStream} + * before and after each OpenGL method call. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class TraceGL4 extends TraceGL4bc { + public TraceGL4(GL4 downstream, PrintStream stream) { + super((GL4bc)downstream, stream); + } +} diff --git a/src/jogl/classes/javax/media/opengl/TraceGLES2.java b/src/jogl/classes/javax/media/opengl/TraceGLES2.java new file mode 100644 index 000000000..38d60e3ac --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/TraceGLES2.java @@ -0,0 +1,23 @@ +package javax.media.opengl; + +import java.io.PrintStream; + +/** + *

+ * Composable pipeline which wraps an underlying {@link GL} implementation, + * providing tracing information to a user-specified {@link java.io.PrintStream} + * before and after each OpenGL method call. + *

+ *

+ * Sample code which installs this pipeline, manual: + *

+ *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
+ * 
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. + *

+ */ +public class TraceGLES2 extends TraceGLES3 { + public TraceGLES2(GLES2 downstream, PrintStream stream) { + super((GLES3)downstream, stream); + } +} -- cgit v1.2.3 From 5dafc958385da595160dc0d3c843c8253334c3c5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 16 Jul 2013 05:34:49 +0200 Subject: GL*: Expose isGL*Core(); GLContext: isGL*() API doc cleanup - align queries. --- make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 15 ++++++++ make/config/jogl/gl-impl-CustomJavaCode-gles1.java | 15 ++++++++ make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 15 ++++++++ .../gluegen/opengl/BuildComposablePipeline.java | 12 ++++++ src/jogl/classes/javax/media/opengl/GLBase.java | 18 +++++++++ src/jogl/classes/javax/media/opengl/GLContext.java | 44 +++++++++++++++++----- 6 files changed, 109 insertions(+), 10 deletions(-) (limited to 'src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index 5ac2837fa..6cec06d04 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -99,6 +99,21 @@ public final boolean isGL4ES3() { return _context.isGL4ES3(); } +@Override +public final boolean isGL4core() { + return _context.isGL4core(); +} + +@Override +public final boolean isGL3core() { + return _context.isGL3core(); +} + +@Override +public final boolean isGLcore() { + return _context.isGLcore(); +} + @Override public final boolean isGLES2Compatible() { return _context.isGLES2Compatible(); diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index 2fa83dca6..35e8b0916 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -77,6 +77,21 @@ public final boolean isGL4ES3() { return false; } +@Override +public final boolean isGL4core() { + return false; +} + +@Override +public final boolean isGL3core() { + return false; +} + +@Override +public final boolean isGLcore() { + return false; +} + @Override public final boolean isGLES2Compatible() { return false; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java index bb4a6246b..a03352409 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -78,6 +78,21 @@ public final boolean isGL4ES3() { return _isES3; } +@Override +public final boolean isGL4core() { + return false; +} + +@Override +public final boolean isGL3core() { + return false; +} + +@Override +public final boolean isGLcore() { + return true; +} + @Override public final boolean isGLES2Compatible() { return true; diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 7659238fc..262fed934 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -669,6 +669,18 @@ public class BuildComposablePipeline { emitGLIsMethod(output, "GLES"); } output.println(" @Override"); + output.println(" public final boolean isGL4core() {"); + output.println(" return " + getDownstreamObjectName() + ".isGL4core();"); + output.println(" }"); + output.println(" @Override"); + output.println(" public final boolean isGL3core() {"); + output.println(" return " + getDownstreamObjectName() + ".isGL3core();"); + output.println(" }"); + output.println(" @Override"); + output.println(" public final boolean isGLcore() {"); + output.println(" return " + getDownstreamObjectName() + ".isGLcore();"); + output.println(" }"); + output.println(" @Override"); output.println(" public final boolean isGLES2Compatible() {"); output.println(" return " + getDownstreamObjectName() + ".isGLES2Compatible();"); output.println(" }"); diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index fcfe34132..3e578dc68 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -185,6 +185,24 @@ public interface GLBase { */ public boolean isGL2GL3(); + /** + * Indicates whether this GL object uses a GL4 core profile.

Includes [ 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.1

Includes [ 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