From 2dce639c479f820d1a1e701f5eddffc4b02f5e0f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 7 Nov 2013 08:36:46 +0100 Subject: Bug 890 - Fix GLES3 Profile Mapping, i.e. GL2ES2 queries and mappings; Validate isGLES*() usage and definition ; Add and use ShaderCode.createExtensionDirective(..) - Fix GLES3 Profile Mapping, i.e. GL2ES2 queries and mappings - GLProfile: Add GL2ES2 -> ES3 mapping - EGLContext: Reuqest major '3' for ES3 - EGLGLCapabilities/EGLGraphicsConfiguration: Consider EGLExt.EGL_OPENGL_ES3_BIT_KHR - Validate isGLES*() usage and definition - Fix BuildComposablePipeline's isGLES() code - For GLSL related queries use isGLES() instead of isGLES2(), which would exclude ES3 - Add and use ShaderCode.createExtensionDirective(..) - Supporting creating GLSL extension directives while reusing strings from GLExtensions - Minor cleanup of GLContextImpl.setGLFuncAvail(..) --- .../gluegen/opengl/BuildComposablePipeline.java | 2 +- .../com/jogamp/graph/curve/opengl/Renderer.java | 2 +- .../classes/com/jogamp/opengl/GLExtensions.java | 1 + .../com/jogamp/opengl/util/glsl/ShaderCode.java | 28 ++++++++++++++++++---- .../opengl/util/texture/TextureSequence.java | 1 - 5 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src/jogl/classes/com') diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index b7a9c270e..df60d2f73 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -667,7 +667,7 @@ public class BuildComposablePipeline { 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(" return isGLES3() || isGLES2() || isGLES1();"); output.println(" }"); } else { emitGLIsMethod(output, "GLES"); diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java index c642fb652..8783906c2 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -279,7 +279,7 @@ public abstract class Renderer { public static final String es2_precision_fp = "\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n"; protected String getFragmentShaderPrecision(GL2ES2 gl) { - if( gl.isGLES2() ) { + if( gl.isGLES() ) { return es2_precision_fp; } if( ShaderCode.requiresGL3DefaultPrecision(gl) ) { diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index c7aadcd14..da9e08a32 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -72,6 +72,7 @@ public class GLExtensions { public static final String OES_read_format = "GL_OES_read_format"; public static final String OES_single_precision = "GL_OES_single_precision"; public static final String OES_EGL_image_external = "GL_OES_EGL_image_external"; + public static final String OES_standard_derivatives = "GL_OES_standard_derivatives"; public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; public static final String ARB_shader_objects = "GL_ARB_shader_objects"; diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 206aa0fd7..6a64edeb5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -843,8 +843,28 @@ public class ShaderCode { /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #gl3_default_precision_fp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n/*precision mediump sampler2D;*/\n"; - /** Prefer enable over require, since it won't force a failure. */ - public static final String extOESDerivativesEnable = "#extension GL_OES_standard_derivatives : enable\n"; + /** Behavior for GLSL extension directive, see {@link #createExtensionDirective(String, String)}, value {@value}. */ + public static final String REQUIRE = "require"; + /** Behavior for GLSL extension directive, see {@link #createExtensionDirective(String, String)}, value {@value}. */ + public static final String ENABLE = "enable"; + /** Behavior for GLSL extension directive, see {@link #createExtensionDirective(String, String)}, value {@value}. */ + public static final String DISABLE = "disable"; + /** Behavior for GLSL extension directive, see {@link #createExtensionDirective(String, String)}, value {@value}. */ + public static final String WARN = "warn"; + + /** + * Creates a GLSL extension directive. + *

+ * Prefer {@link #ENABLE} over {@link #REQUIRE}, since the latter will force a failure if not supported. + *

+ * + * @param extensionName + * @param behavior shall be either {@link #REQUIRE}, {@link #ENABLE}, {@link #DISABLE} or {@link #WARN} + * @return the complete extension directive + */ + public static String createExtensionDirective(String extensionName, String behavior) { + return "#extension " + extensionName + " : " + behavior; + } /** * Add GLSL version at the head of this shader source code. @@ -915,7 +935,7 @@ public class ShaderCode { /** Returns true, if GLSL version requires default precision, i.e. ES2 or GLSL [1.30 .. 1.50[. */ public static final boolean requiresDefaultPrecision(GL2ES2 gl) { - if( gl.isGLES2() || gl.isGLES3() ) { + if( gl.isGLES() ) { return true; } return requiresGL3DefaultPrecision(gl); @@ -979,7 +999,7 @@ public class ShaderCode { } else { pos = 0; } - if( gl.isGLES2() && null != esDefaultPrecision ) { + if( gl.isGLES() && null != esDefaultPrecision ) { pos = insertShaderSource(0, pos, esDefaultPrecision); } else { pos = addDefaultShaderPrecision(gl, pos); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index c34e019c2..6f1dd4c64 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -105,7 +105,6 @@ import com.jogamp.opengl.util.TimeFrameI; * */ public interface TextureSequence { - public static final String GL_OES_EGL_image_external_Required_Prelude = "#extension GL_OES_EGL_image_external : enable\n"; public static final String samplerExternalOES = "samplerExternalOES"; public static final String sampler2D = "sampler2D"; -- cgit v1.2.3