From ede27aaa21b15e0e42ee0340834bba9badde19b5 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Sun, 31 Jan 2010 16:40:51 +0000 Subject: [PATCH] Improved compatibility mode detection Removed support for indirect buffers as arguments to GL functions Added missing tokens in GL30 & GL32 Added support for AMD_seamless_cubemap_per_texture & AMD_shader_stencil_export Fixed AMD_vertex_shader_tessellator typo Added AMD extensions to the build process >.< --- platform_build/build-definitions.xml | 2 +- src/java/org/lwjgl/opengl/GLContext.java | 20 ++++++--- .../ContextCapabilitiesGenerator.java | 6 ++- .../ContextGeneratorProcessorFactory.java | 1 + .../util/generator/GeneratorVisitor.java | 3 +- .../util/generator/JavaMethodsGenerator.java | 5 ++- .../AMD_seamless_cubemap_per_texture.java | 42 +++++++++++++++++++ .../opengl/AMD_shader_stencil_export.java | 35 ++++++++++++++++ ...ava => AMD_vertex_shader_tessellator.java} | 2 +- src/templates/org/lwjgl/opengl/GL30.java | 6 +++ src/templates/org/lwjgl/opengl/GL32.java | 4 ++ 11 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 src/templates/org/lwjgl/opengl/AMD_seamless_cubemap_per_texture.java create mode 100644 src/templates/org/lwjgl/opengl/AMD_shader_stencil_export.java rename src/templates/org/lwjgl/opengl/{AMD_vertex_shader_tesselator.java => AMD_vertex_shader_tessellator.java} (95%) diff --git a/platform_build/build-definitions.xml b/platform_build/build-definitions.xml index 3a07d1ff..d4d25161 100644 --- a/platform_build/build-definitions.xml +++ b/platform_build/build-definitions.xml @@ -14,7 +14,7 @@ - + diff --git a/src/java/org/lwjgl/opengl/GLContext.java b/src/java/org/lwjgl/opengl/GLContext.java index 130aa0c8..d1b572c7 100644 --- a/src/java/org/lwjgl/opengl/GLContext.java +++ b/src/java/org/lwjgl/opengl/GLContext.java @@ -173,13 +173,13 @@ public final class GLContext { static native long getFunctionAddress(String name); /** - * Determine which extensions are available. Helper method to ContextCapabilities. + * Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities. * - * @return A Set containing all available extension strings. + * @param supported_extensions the Set to fill with the available extension names + * + * @return the context profile mask, will be 0 for any version < 3.2 */ - static Set getSupportedExtensions() { - final Set supported_extensions = new HashSet(); - + static int getSupportedExtensions(final Set supported_extensions) { // Detect OpenGL version first final String version = GL11.glGetString(GL11.GL_VERSION); @@ -225,6 +225,8 @@ public final class GLContext { if ( 1 < majorVersion || 1 <= minorVersion ) supported_extensions.add("OpenGL11"); + int profileMask = 0; + if ( majorVersion < 3 ) { // Parse EXTENSIONS string final String extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS); @@ -242,9 +244,15 @@ public final class GLContext { for ( int i = 0; i < extensionCount; i++ ) supported_extensions.add(GL30.glGetStringi(GL11.GL_EXTENSIONS, i)); + + // Get the context profile mask for versions >= 3.2 + if ( 3 < majorVersion || 2 <= minorVersion ) { + GL11.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK, buffer); + profileMask = buffer.get(0); + } } - return supported_extensions; + return profileMask; } /** diff --git a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java index b8e3307d..a23f5907 100644 --- a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java +++ b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java @@ -55,6 +55,7 @@ public class ContextCapabilitiesGenerator { private final static String ALL_INIT_METHOD_NAME = "initAllStubs"; private final static String POINTER_INITIALIZER_POSTFIX = "_initNativeFunctionAddresses"; private final static String CACHED_EXTS_VAR_NAME = "supported_extensions"; + private final static String PROFILE_MASK_VAR_NAME = "profileMask"; private final static String EXTENSION_PREFIX = "GL_"; private final static String CORE_PREFIX = "Open"; @@ -128,10 +129,11 @@ public class ContextCapabilitiesGenerator { // Get the supported extensions set. writer.println("\t\tGLContext.setCapabilities(this);"); - writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = GLContext.getSupportedExtensions();"); + writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = new HashSet(256);"); + writer.println("\t\tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");"); // Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available. - writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !supported_extensions.contains(\"GL_ARB_compatibility\") )"); + writer.println("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !(supported_extensions.contains(\"GL_ARB_compatibility\") || (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) )"); writer.println("\t\t\tforwardCompatible = true;"); if ( !context_specific ) { diff --git a/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java b/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java index 645027c0..8dbd0e38 100644 --- a/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java +++ b/src/java/org/lwjgl/util/generator/ContextGeneratorProcessorFactory.java @@ -117,6 +117,7 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact writer.println("import org.lwjgl.LWJGLUtil;"); writer.println("import org.lwjgl.BufferUtils;"); writer.println("import java.util.Set;"); + writer.println("import java.util.HashSet;"); writer.println("import java.nio.IntBuffer;"); writer.println(); ContextCapabilitiesGenerator.generateClassPrologue(writer, context_specific); diff --git a/src/java/org/lwjgl/util/generator/GeneratorVisitor.java b/src/java/org/lwjgl/util/generator/GeneratorVisitor.java index 7372b370..6c51d8b3 100644 --- a/src/java/org/lwjgl/util/generator/GeneratorVisitor.java +++ b/src/java/org/lwjgl/util/generator/GeneratorVisitor.java @@ -175,7 +175,8 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { java_writer.println(); java_writer.println("import org.lwjgl.LWJGLException;"); java_writer.println("import org.lwjgl.BufferChecks;"); - java_writer.println("import org.lwjgl.NondirectBufferWrapper;"); + // DISABLED: indirect buffer support + //java_writer.println("import org.lwjgl.NondirectBufferWrapper;"); java_writer.println("import java.nio.*;"); java_writer.println(); java_writer.print("public "); diff --git a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java index afc15e54..f05f3d24 100644 --- a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java +++ b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java @@ -238,7 +238,8 @@ public class JavaMethodsGenerator { writer.println(");"); if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";"); - printNondirectParameterCopies(writer, method, mode); + // DISABLED: indirect buffer support + //printNondirectParameterCopies(writer, method, mode); if (has_result) writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); writer.println("\t}"); @@ -491,7 +492,7 @@ public class JavaMethodsGenerator { } NullTerminated null_terminated = param.getAnnotation(NullTerminated.class); if (Buffer.class.isAssignableFrom(java_type)) { - boolean indirect_buffer_allowed = param.getAnnotation(CachedReference.class) == null; + boolean indirect_buffer_allowed = false && param.getAnnotation(CachedReference.class) == null; // DISABLED: indirect buffer support boolean out_parameter = param.getAnnotation(OutParameter.class) != null; TypeInfo typeinfo = typeinfos.get(param); printParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed, out_parameter); diff --git a/src/templates/org/lwjgl/opengl/AMD_seamless_cubemap_per_texture.java b/src/templates/org/lwjgl/opengl/AMD_seamless_cubemap_per_texture.java new file mode 100644 index 00000000..f0ce3605 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_seamless_cubemap_per_texture.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface AMD_seamless_cubemap_per_texture { + + /** + * Accepted by the <pname> parameter of TexParameterf, TexParameteri, + * TexParameterfv, TexParameteriv, GetTexParameterfv, and GetTexParameteriv: + */ + int GL_TEXTURE_CUBE_MAP_SEAMLESS = ARB_seamless_cube_map.GL_TEXTURE_CUBE_MAP_SEAMLESS; + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_shader_stencil_export.java b/src/templates/org/lwjgl/opengl/AMD_shader_stencil_export.java new file mode 100644 index 00000000..c7824fa9 --- /dev/null +++ b/src/templates/org/lwjgl/opengl/AMD_shader_stencil_export.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface AMD_shader_stencil_export { +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tesselator.java b/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java similarity index 95% rename from src/templates/org/lwjgl/opengl/AMD_vertex_shader_tesselator.java rename to src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java index 960ccfc2..5a596db9 100644 --- a/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tesselator.java +++ b/src/templates/org/lwjgl/opengl/AMD_vertex_shader_tessellator.java @@ -33,7 +33,7 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.GLenum; -public interface AMD_vertex_shader_tesselator { +public interface AMD_vertex_shader_tessellator { /** Returned by the <type> parameter of GetActiveUniform: */ int GL_SAMPLER_BUFFER_AMD = 0x9001; diff --git a/src/templates/org/lwjgl/opengl/GL30.java b/src/templates/org/lwjgl/opengl/GL30.java index 7d203814..5a79705d 100644 --- a/src/templates/org/lwjgl/opengl/GL30.java +++ b/src/templates/org/lwjgl/opengl/GL30.java @@ -62,11 +62,17 @@ public interface GL30 { int GL_CLIP_DISTANCE3 = GL11.GL_CLIP_PLANE3; int GL_CLIP_DISTANCE4 = GL11.GL_CLIP_PLANE4; int GL_CLIP_DISTANCE5 = GL11.GL_CLIP_PLANE5; + int GL_CLIP_DISTANCE6 = 0x3006; + int GL_CLIP_DISTANCE7 = 0x3007; int GL_MAX_CLIP_DISTANCES = GL11.GL_MAX_CLIP_PLANES; int GL_MAX_VARYING_COMPONENTS = GL20.GL_MAX_VARYING_FLOATS; + int GL_BUFFER_ACCESS_FLAGS = 0x911F; + int GL_BUFFER_MAP_LENGTH = 0x9120; + int GL_BUFFER_MAP_OFFSET = 0x9121; + String glGetStringi(@GLenum int name, @GLuint int index); @StripPostfix("value") diff --git a/src/templates/org/lwjgl/opengl/GL32.java b/src/templates/org/lwjgl/opengl/GL32.java index 75c3311c..adabb22e 100644 --- a/src/templates/org/lwjgl/opengl/GL32.java +++ b/src/templates/org/lwjgl/opengl/GL32.java @@ -44,6 +44,10 @@ public interface GL32 { // ----------------------[ OpenGL 3.2 ]---------------------- // ---------------------------------------------------------- + int GL_CONTEXT_PROFILE_MASK = 0x9126; + int GL_CONTEXT_CORE_PROFILE_BIT = 0x00000001; + int GL_CONTEXT_COMPATIBILITY_PROFILE_BIT = 0x00000002; + int GL_MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122; int GL_MAX_GEOMETRY_INPUT_COMPONENTS = 0x9123; int GL_MAX_GEOMETRY_OUTPUT_COMPONENTS = 0x9124;