diff --git a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java index a23f5907..cc98392b 100644 --- a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java +++ b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java @@ -197,12 +197,13 @@ public class ContextCapabilitiesGenerator { writer.print("\tprivate boolean " + getAddressesInitializerName(d.getSimpleName()) + "("); - DeprecatedGL deprecated = d.getAnnotation(DeprecatedGL.class); + boolean optional; + boolean deprecated = d.getAnnotation(DeprecatedGL.class) != null; Dependent dependent = d.getAnnotation(Dependent.class); - if ( deprecated != null ) + if ( deprecated ) writer.print("boolean forwardCompatible"); if ( dependent != null ) { - if ( deprecated != null ) + if ( deprecated ) writer.print(","); writer.print("Set supported_extensions"); } @@ -211,11 +212,14 @@ public class ContextCapabilitiesGenerator { writer.println("\t\treturn "); while ( methods.hasNext() ) { MethodDeclaration method = methods.next(); - deprecated = method.getAnnotation(DeprecatedGL.class); + optional = method.getAnnotation(Optional.class) != null; + deprecated = method.getAnnotation(DeprecatedGL.class) != null; dependent = method.getAnnotation(Dependent.class); writer.print("\t\t\t("); - if ( deprecated != null ) + if ( optional ) + writer.print('('); + if ( deprecated ) writer.print("forwardCompatible || "); if ( dependent != null ) { if ( dependent.value().indexOf(',') == -1 ) @@ -227,7 +231,7 @@ public class ContextCapabilitiesGenerator { writer.print(") || "); } } - if ( deprecated != null || dependent != null ) + if ( deprecated || dependent != null ) writer.print('('); writer.print(Utils.getFunctionAddressName(d, method) + " = "); PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class); @@ -253,8 +257,10 @@ public class ContextCapabilitiesGenerator { } else writer.print("GLContext.getFunctionAddress("); writer.print("\"" + method.getSimpleName() + "\")) != 0"); - if ( deprecated != null || dependent != null ) + if ( deprecated || dependent != null ) writer.print(')'); + if ( optional ) + writer.print(" || true)"); if ( methods.hasNext() ) writer.println(" &&"); } diff --git a/src/java/org/lwjgl/util/generator/Optional.java b/src/java/org/lwjgl/util/generator/Optional.java new file mode 100644 index 00000000..60f10638 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/Optional.java @@ -0,0 +1,47 @@ +/* + * 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.util.generator; + +/** + * A function annotated with @Optional will allow the extension to be available even if the driver does not expose that function. + * This is useful when certain buggy drivers miss some functionality. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +public @interface Optional { + String reason(); // No default value to force documentation +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL31.java b/src/templates/org/lwjgl/opengl/GL31.java index 1b1b8a46..4819ad5f 100644 --- a/src/templates/org/lwjgl/opengl/GL31.java +++ b/src/templates/org/lwjgl/opengl/GL31.java @@ -96,8 +96,6 @@ public interface GL31 { */ int GL_PRIMITIVE_RESTART_INDEX = 0x8F9E; - void glPrimitiveRestart(); - void glPrimitiveRestartIndex(@GLuint int index); // ------------------------------------------------------------------------- diff --git a/src/templates/org/lwjgl/opengl/GL32.java b/src/templates/org/lwjgl/opengl/GL32.java index adabb22e..8bc6ee53 100644 --- a/src/templates/org/lwjgl/opengl/GL32.java +++ b/src/templates/org/lwjgl/opengl/GL32.java @@ -63,6 +63,7 @@ public interface GL32 { // ----------------------[ ARB_draw_elements_base_vertex ]---------------------- // ----------------------------------------------------------------------------- + @Optional(reason = "AMD's 3.2 implementation does not expose this (last driver checked: 10.1)") void glDrawElementsBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, @BufferObject(BufferKind.ElementVBO) @Const @@ -70,6 +71,7 @@ public interface GL32 { @GLushort @GLuint Buffer indices, int basevertex); + @Optional(reason = "AMD's 3.2 implementation does not expose this (last driver checked: 10.1)") void glDrawRangeElementsBaseVertex(@GLenum int mode, @GLuint int start, @GLuint int end, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, @BufferObject(BufferKind.ElementVBO) @Const @@ -77,6 +79,7 @@ public interface GL32 { @GLushort @GLuint Buffer indices, int basevertex); + @Optional(reason = "AMD's 3.2 implementation does not expose this (last driver checked: 10.1)") void glDrawElementsInstancedBaseVertex(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, @BufferObject(BufferKind.ElementVBO) @Const