diff --git a/src/java/org/lwjgl/opengl/StringUtils.java b/src/java/org/lwjgl/opengl/StringUtils.java new file mode 100644 index 00000000..a29b2916 --- /dev/null +++ b/src/java/org/lwjgl/opengl/StringUtils.java @@ -0,0 +1,268 @@ +/* + * 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; + +import org.lwjgl.BufferUtils; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** @author spasi */ +final class StringUtils { + + private static final int INITIAL_BUFFER_SIZE = 256; + private static final int INITIAL_LENGTHS_SIZE = 4; + + private static final ThreadLocal arrayTL = new ThreadLocal() { + protected Object initialValue() { + return new char[INITIAL_BUFFER_SIZE]; + } + }; + + private static final ThreadLocal bufferTL = new ThreadLocal() { + protected Object initialValue() { + return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); + } + }; + + private static final ThreadLocal lengthsTL = new ThreadLocal() { + protected Object initialValue() { + return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); + } + }; + + private StringUtils() { + } + + private static char[] getArray(final int size) { + char[] array = (char[])arrayTL.get(); + + if ( array.length < size ) { + int sizeNew = array.length << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + array = new char[size]; + arrayTL.set(array); + } + + return array; + } + + static ByteBuffer getBuffer(final int size) { + ByteBuffer buffer = (ByteBuffer)bufferTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + buffer = BufferUtils.createByteBuffer(size); + bufferTL.set(buffer); + } + + buffer.clear(); + return buffer; + } + + private static ByteBuffer getBufferOffset(final int size) { + ByteBuffer buffer = (ByteBuffer)bufferTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size); + bufferNew.put(buffer); + bufferTL.set(buffer = bufferNew); + } else { + buffer.position(buffer.limit()); + buffer.limit(buffer.capacity()); + } + + return buffer; + } + + static IntBuffer getLengths(final int size) { + IntBuffer lengths = (IntBuffer)lengthsTL.get(); + + if ( lengths.capacity() < size ) { + int sizeNew = lengths.capacity(); + while ( sizeNew < size ) + sizeNew <<= 1; + + lengths = BufferUtils.createIntBuffer(size); + lengthsTL.set(lengths); + } + + lengths.clear(); + return lengths; + } + + /* + * Reads a byte string from the specified buffer. + * + * @param buffer + * + * @return the buffer as a String. + */ + + static String getString(final ByteBuffer buffer) { + final int length = buffer.remaining(); + final char[] charArray = getArray(length); + + for ( int i = buffer.position(); i < buffer.limit(); i++ ) + charArray[i - buffer.position()] = (char)buffer.get(i); + + return new String(charArray, 0, length); + } + + /** + * Returns a buffer containing the specified string as bytes. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence string) { + final ByteBuffer buffer = getBuffer(string.length()); + + for ( int i = 0; i < string.length(); i++ ) + buffer.put((byte)string.charAt(i)); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified string as bytes, starting at the specified offset. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBufferOffset(final CharSequence string, final int offset) { + final ByteBuffer buffer = getBufferOffset(offset + string.length()); + + for ( int i = 0; i < string.length(); i++ ) + buffer.put((byte)string.charAt(i)); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified string as bytes, including null-termination. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBufferNT(final CharSequence string) { + final ByteBuffer buffer = getBuffer(string.length() + 1); + + for ( int i = 0; i < string.length(); i++ ) + buffer.put((byte)string.charAt(i)); + + buffer.put((byte)0); + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified strings as bytes. + * + * @param strings + * + * @return the Strings as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence[] strings) { + int length = 0; + for ( int i = 0; i < strings.length; i++ ) + length += strings[i].length(); + + final ByteBuffer buffer = getBuffer(length); + + for ( int i = 0; i < strings.length; i++ ) { + final CharSequence string = strings[i]; + for ( int j = 0; j < string.length(); j++ ) + buffer.put((byte)string.charAt(i)); + } + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified strings as bytes, including null-termination. + * + * @param strings + * + * @return the Strings as a ByteBuffer + */ + static ByteBuffer getBufferNT(final CharSequence[] strings) { + int length = 0; + for ( int i = 0; i < strings.length; i++ ) + length += strings[i].length() + 1; + + final ByteBuffer buffer = getBuffer(length); + + for ( int i = 0; i < strings.length; i++ ) { + final CharSequence string = strings[i]; + for ( int j = 0; j < string.length(); j++ ) + buffer.put((byte)string.charAt(i)); + buffer.put((byte)0); + } + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the lengths of the specified strings. + * + * @param strings + * + * @return the String lengths in an IntBuffer + */ + static IntBuffer getLengths(final CharSequence[] strings) { + IntBuffer buffer = getLengths(strings.length); + + for ( int i = 0; i < strings.length; i++ ) + buffer.put(strings[i].length()); + + buffer.flip(); + return buffer; + } + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/Alternate.java b/src/java/org/lwjgl/util/generator/Alternate.java index e9fccbf3..3315066c 100644 --- a/src/java/org/lwjgl/util/generator/Alternate.java +++ b/src/java/org/lwjgl/util/generator/Alternate.java @@ -42,6 +42,10 @@ import java.lang.annotation.Target; */ @Target({ ElementType.METHOD }) public @interface Alternate { + /** This must match an existing GL method name. */ String value(); + + /** If true, an alternate Java->native call will be created. Useful when the alternate implementation uses different types. */ + boolean nativeAlt() default false; } \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java index cc98392b..d117fda5 100644 --- a/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java +++ b/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java @@ -210,8 +210,18 @@ public class ContextCapabilitiesGenerator { writer.println(") {"); writer.println("\t\treturn "); + + boolean first = true; while ( methods.hasNext() ) { MethodDeclaration method = methods.next(); + if ( method.getAnnotation(Alternate.class) != null ) + continue; + + if ( !first ) + writer.println(" &&"); + else + first = false; + optional = method.getAnnotation(Optional.class) != null; deprecated = method.getAnnotation(DeprecatedGL.class) != null; dependent = method.getAnnotation(Dependent.class); @@ -261,8 +271,6 @@ public class ContextCapabilitiesGenerator { writer.print(')'); if ( optional ) writer.print(" || true)"); - if ( methods.hasNext() ) - writer.println(" &&"); } writer.println(";"); writer.println("\t}"); @@ -271,7 +279,8 @@ public class ContextCapabilitiesGenerator { public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) { for ( MethodDeclaration method : d.getMethods() ) { - writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";"); + if ( method.getAnnotation(Alternate.class) == null ) + writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";"); } } diff --git a/src/java/org/lwjgl/util/generator/GLTypeMap.java b/src/java/org/lwjgl/util/generator/GLTypeMap.java index 29f375d8..a5f92735 100644 --- a/src/java/org/lwjgl/util/generator/GLTypeMap.java +++ b/src/java/org/lwjgl/util/generator/GLTypeMap.java @@ -220,7 +220,7 @@ public class GLTypeMap implements TypeMap { else if ( type.equals(boolean.class) ) return new Class[] { GLboolean.class }; else if ( type.equals(void.class) ) - return new Class[] { GLvoid.class }; + return new Class[] { GLvoid.class, GLstring.class }; else return new Class[] { }; } @@ -243,6 +243,8 @@ public class GLTypeMap implements TypeMap { valid_types = new Class[] { GLubyte.class }; else if ( PointerWrapper.class.isAssignableFrom(type) ) valid_types = new Class[] { GLpointer.class }; + else if (void.class.equals(type) ) + valid_types = new Class[] { GLstring.class }; else valid_types = new Class[] { }; return valid_types; diff --git a/src/java/org/lwjgl/util/generator/GLstring.java b/src/java/org/lwjgl/util/generator/GLstring.java new file mode 100644 index 00000000..9dd75c9d --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLstring.java @@ -0,0 +1,50 @@ +/* + * 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; + +/** + * Methods annotated with @GLstring will return a String instead of void. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.METHOD }) +public @interface GLstring { + /** The ByteBuffer argument that will be used to retrieve the String bytes. */ + String string(); + /** The argument that specifies the maximum number of bytes that may be read. */ + String maxLength(); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GLstringOffset.java b/src/java/org/lwjgl/util/generator/GLstringOffset.java new file mode 100644 index 00000000..0b46f835 --- /dev/null +++ b/src/java/org/lwjgl/util/generator/GLstringOffset.java @@ -0,0 +1,48 @@ +/* + * 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; + +/** + * This annotation must be used when there are more than one CharSequence arguments in a method. + * TODO: Add support for CharSequence[] if/when we need it. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.PARAMETER }) +public @interface GLstringOffset { + /** An expression that will specify the offset from which this String will be written to the ByteBuffer. */ + String value(); +} \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/GeneratorVisitor.java b/src/java/org/lwjgl/util/generator/GeneratorVisitor.java index 041b0c04..0f404e68 100644 --- a/src/java/org/lwjgl/util/generator/GeneratorVisitor.java +++ b/src/java/org/lwjgl/util/generator/GeneratorVisitor.java @@ -125,7 +125,8 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { private void validateParameters(MethodDeclaration method) { for (ParameterDeclaration param : method.getParameters()) { validateTypes(method, param.getAnnotationMirrors(), param.getType()); - if (Utils.getNIOBufferType(param.getType()) != null) { + Class param_type = Utils.getJavaType(param.getType()); + if (Utils.getNIOBufferType(param.getType()) != null && param_type != CharSequence.class && param_type != CharSequence[].class) { Check parameter_check_annotation = param.getAnnotation(Check.class); NullTerminated null_terminated_annotation = param.getAnnotation(NullTerminated.class); if (parameter_check_annotation == null && null_terminated_annotation == null) { @@ -138,7 +139,11 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { break; } } - if (!found_auto_size_param && param.getAnnotation(Result.class) == null && param.getAnnotation(Constant.class) == null) + if (!found_auto_size_param + && param.getAnnotation(Result.class) == null + && param.getAnnotation(Constant.class) == null + && !Utils.isReturnString(method, param) + ) throw new RuntimeException(param + " has no Check, Result nor Constant annotation and no other parameters has" + " an @AutoSize annotation on it in method " + method); } @@ -158,8 +163,10 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor { } private static void generateMethodsNativePointers(PrintWriter writer, Collection methods) { - for (MethodDeclaration method : methods) - generateMethodNativePointers(writer, method); + for (MethodDeclaration method : methods) { + if ( method.getAnnotation(Alternate.class) == null ) + generateMethodNativePointers(writer, method); + } } private static void generateMethodNativePointers(PrintWriter writer, MethodDeclaration method) { diff --git a/src/java/org/lwjgl/util/generator/JNITypeTranslator.java b/src/java/org/lwjgl/util/generator/JNITypeTranslator.java index bbced914..a43330b0 100644 --- a/src/java/org/lwjgl/util/generator/JNITypeTranslator.java +++ b/src/java/org/lwjgl/util/generator/JNITypeTranslator.java @@ -56,7 +56,10 @@ public class JNITypeTranslator implements TypeVisitor { } public void visitArrayType(ArrayType t) { - throw new RuntimeException(t + " is not allowed"); + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) + signature.append("jobject"); + else + throw new RuntimeException(t + " is not allowed"); } public void visitClassType(ClassType t) { diff --git a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java index 9deb5ed5..57a3411b 100644 --- a/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java +++ b/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java @@ -71,7 +71,8 @@ public class JavaMethodsGenerator { if ( method.getAnnotation(CachedResult.class) != null && !method.getAnnotation(CachedResult.class).isRange() ) { printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.CACHEDRESULT, generate_error_checks, context_specific); } - if ( method.getAnnotation(Alternate.class) == null ) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation == null || alt_annotation.nativeAlt() ) { printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific); if (Utils.hasMethodBufferObjectParameter(method)) { printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.BUFFEROBJECT, generate_error_checks, context_specific); @@ -119,8 +120,12 @@ public class JavaMethodsGenerator { writer.print("boolean " + TypeInfo.UNSIGNED_PARAMETER_NAME); } } - } else if (param.getAnnotation(Result.class) == null && (native_stub || param.getAnnotation(Constant.class) == null) && - (getAutoTypeParameter(method, param) == null || mode != Mode.AUTOS)) { + } else if ( + param.getAnnotation(Result.class) == null + && (native_stub || (param.getAnnotation(Constant.class) == null && !Utils.isReturnString(method, param))) + && (getAutoTypeParameter(method, param) == null || mode != Mode.AUTOS) + ) + { TypeInfo type_info = typeinfos_instance.get(param); first_parameter = generateParameterJava(writer, param, type_info, native_stub, first_parameter, mode); } @@ -161,10 +166,15 @@ public class JavaMethodsGenerator { } else { if ( native_stub && param.getAnnotation(GLpointer.class) != null ) writer.print("long"); - else - writer.print(type_info.getType().getSimpleName()); + else { + Class type = type_info.getType(); + if ( native_stub && (type == CharSequence.class || type == CharSequence[].class) ) + writer.print("ByteBuffer"); + else + writer.print(type_info.getType().getSimpleName()); + } writer.print(" " + param.getSimpleName()); - if (buffer_type != null && native_stub) + if ( native_stub && buffer_type != null ) writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX); } return false; @@ -208,7 +218,7 @@ public class JavaMethodsGenerator { if (context_specific) { writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();"); writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = caps."); - writer.println(Utils.getFunctionAddressName(interface_decl, method) + ";"); + writer.println(Utils.getFunctionAddressName(interface_decl, method, true) + ";"); writer.print("\t\tBufferChecks.checkFunctionAddress("); writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");"); } @@ -227,6 +237,13 @@ public class JavaMethodsGenerator { if ( method.getAnnotation(GLpointer.class) != null ) writer.print("new " + method.getReturnType() + "("); } + GLstring string_annotation = method.getAnnotation(GLstring.class); + if ( string_annotation != null ) { + has_result = true; + writer.println("IntBuffer " + string_annotation.string() + "_length = StringUtils.getLengths(1);"); + writer.println("\t\tByteBuffer " + string_annotation.string() + " = StringUtils.getBuffer(" + string_annotation.maxLength() + ");"); + writer.print("\t\t"); + } writer.print(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific)); if (mode == Mode.BUFFEROBJECT) writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); @@ -244,8 +261,14 @@ public class JavaMethodsGenerator { writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";"); // DISABLED: indirect buffer support //printNondirectParameterCopies(writer, method, mode); - if (has_result) - writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); + if (has_result) { + if ( string_annotation == null ) + writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); + else { + writer.println("\t\t" + string_annotation.string() + ".limit(" + string_annotation.string() + "_length.get(0));"); + writer.println("\t\treturn StringUtils.getString(" + string_annotation.string() + ");"); + } + } writer.println("\t}"); } @@ -383,8 +406,24 @@ public class JavaMethodsGenerator { boolean hide_buffer = mode == Mode.AUTOS && getAutoTypeParameter(method, param) != null; if (hide_buffer) writer.print("null"); - else - writer.print(param.getSimpleName()); + else { + Class type = typeinfos_instance.get(param).getType(); + if ( type == CharSequence.class || type == CharSequence[].class ) { + GLstringOffset offset_annotation = param.getAnnotation(GLstringOffset.class); + + writer.print("StringUtils.getBuffer"); + if ( offset_annotation != null ) + writer.print("Offset"); + if ( param.getAnnotation(NullTerminated.class) != null ) + writer.print("NT"); + writer.print("(" + param.getSimpleName()); + if ( offset_annotation != null ) + writer.print(", " + offset_annotation.value()); + writer.print(")"); + hide_buffer = true; + } else + writer.print(param.getSimpleName()); + } Class buffer_type = Utils.getNIOBufferType(param.getType()); if (buffer_type != null) { writer.print(", "); @@ -404,7 +443,9 @@ public class JavaMethodsGenerator { writer.print(" << " + shifting); if (check_annotation != null && check_annotation.canBeNull()) writer.print(" : 0"); - } else + } else if ( param.getAnnotation(GLstringOffset.class) != null ) + writer.print(param.getAnnotation(GLstringOffset.class).value()); + else writer.print("0"); } else if ( param.getAnnotation(GLpointer.class) != null ) { writer.print(".getPointer()"); @@ -489,7 +530,8 @@ public class JavaMethodsGenerator { if (Utils.isAddressableType(java_type) && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && - param.getAnnotation(Result.class) == null) { + param.getAnnotation(Result.class) == null && + !Utils.isReturnString(method, param) ) { String check_value = null; boolean can_be_null = false; Check check_annotation = param.getAnnotation(Check.class); @@ -547,6 +589,8 @@ public class JavaMethodsGenerator { private static void printResultType(PrintWriter writer, MethodDeclaration method, boolean native_stub) { if ( native_stub && method.getAnnotation(GLpointer.class) != null ) writer.print("long"); + else if ( !native_stub && method.getAnnotation(GLstring.class) != null ) + writer.print("String"); else writer.print(Utils.getMethodReturnType(method).toString()); } diff --git a/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java b/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java index 292282ab..ca01df56 100644 --- a/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java +++ b/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java @@ -56,7 +56,10 @@ public class JavaTypeTranslator implements TypeVisitor { } public void visitArrayType(ArrayType t) { - throw new RuntimeException(t + " is not allowed"); + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) + type = CharSequence[].class; + else + throw new RuntimeException(t + " is not allowed"); } public void visitPrimitiveType(PrimitiveType t) { diff --git a/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java b/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java index 19104a45..aae7a2f8 100644 --- a/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java +++ b/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java @@ -56,6 +56,9 @@ public class NativeMethodStubsGenerator { public static void generateNativeMethodStubs(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) { for (MethodDeclaration method : d.getMethods()) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation != null && !alt_annotation.nativeAlt() ) + continue; generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.NORMAL, generate_error_checks, context_specific); if (Utils.hasMethodBufferObjectParameter(method)) generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.BUFFEROBJECT, generate_error_checks, context_specific); @@ -117,9 +120,10 @@ public class NativeMethodStubsGenerator { } writer.println(") {"); generateBufferParameterAddresses(type_map, writer, method, mode); + Alternate alt_annotation = method.getAnnotation(Alternate.class); if (context_specific) { String typedef_name = Utils.getTypedefName(method); - writer.print("\t" + typedef_name + " " + method.getSimpleName()); + writer.print("\t" + typedef_name + " " + (alt_annotation == null ? method.getSimpleName() : alt_annotation.value())); writer.print(" = (" + typedef_name + ")((intptr_t)"); writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");"); } @@ -141,7 +145,7 @@ public class NativeMethodStubsGenerator { } else writer.print(" = "); } - writer.print(method.getSimpleName() + "("); + writer.print((alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + "("); generateCallParameters(writer, type_map, method.getParameters()); writer.print(")"); writer.println(";"); @@ -222,13 +226,13 @@ public class NativeMethodStubsGenerator { } private static void generateBufferParameterAddresses(TypeMap type_map, PrintWriter writer, MethodDeclaration method, Mode mode) { + boolean loopDeclared = false; for (ParameterDeclaration param : method.getParameters()) - if (Utils.isAddressableType(param.getType()) && - param.getAnnotation(Result.class) == null) - generateBufferParameterAddress(type_map, writer, method, param, mode); + if (Utils.isAddressableType(param.getType()) && param.getAnnotation(Result.class) == null) + loopDeclared = generateBufferParameterAddress(type_map, writer, method, param, mode, loopDeclared); } - private static void generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode) { + private static boolean generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode, boolean loopDeclared) { NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); param.getType().accept(translator); writer.print("\t" + translator.getSignature() + param.getSimpleName()); @@ -240,7 +244,7 @@ public class NativeMethodStubsGenerator { writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + "))"); } else { Class java_type = Utils.getJavaType(param.getType()); - if (Buffer.class.isAssignableFrom(java_type)) { + if (Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class)) { boolean explicitly_byte_sized = java_type.equals(Buffer.class) || translator.getAnnotationType().equals(type_map.getVoidType()); if (explicitly_byte_sized) @@ -262,30 +266,47 @@ public class NativeMethodStubsGenerator { writer.println(";"); if ( param.getAnnotation(StringList.class) != null ) { - if ( param.getAnnotation(GLchar.class) == null || - param.getAnnotation(NullTerminated.class) == null || - param.getAnnotation(NullTerminated.class).value().length() == 0 + if ( Utils.getJavaType(param.getType()) != CharSequence[].class && ( + param.getAnnotation(GLchar.class) == null || + param.getAnnotation(NullTerminated.class) == null || + param.getAnnotation(NullTerminated.class).value().length() == 0 + ) ) throw new RuntimeException("StringList annotation can only be applied on null-terminated GLchar buffers."); - // Declare string array and loop counters - writer.print("\tGLchar **" + param.getSimpleName() + STRING_LIST_POSTFIX + "; "); - writer.println("\tunsigned int " + param.getSimpleName() + "_i = 0;"); - writer.println("\tGLchar *" + param.getSimpleName() + "_next = (GLchar *)" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";"); + if ( "_str".equals(param.getSimpleName()) ) + throw new RuntimeException("The name '_str' is not valid for arguments annotated with StringList"); + + // Declare loop counters and allocate string array + if ( !loopDeclared ) { + writer.println("\tunsigned int _str_i;"); + writer.println("\tGLchar *_str_address;"); + loopDeclared = true; + } + writer.println("\tGLchar **" + param.getSimpleName() + STRING_LIST_POSTFIX + " = (GLchar **) malloc(" + param.getAnnotation(StringList.class).value() + "*sizeof(GLchar*));"); } + return loopDeclared; } private static void generateStringListInits(PrintWriter writer, Collection params) { for ( ParameterDeclaration param : params ) { StringList stringList_annotation = param.getAnnotation(StringList.class); if ( stringList_annotation != null ) { - // Allocate the string array - writer.println("\t" + param.getSimpleName() + STRING_LIST_POSTFIX + " = (GLchar **) malloc(" + stringList_annotation.value() + "*sizeof(GLchar*));"); + String lengths = stringList_annotation.lengths(); + + // Init vars + writer.println("\t_str_i = 0;"); + writer.println("\t_str_address = (GLchar *)" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";"); // Fill string array with the string pointers - writer.println("\tdo {"); - writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[" + param.getSimpleName() + "_i++] = " + param.getSimpleName() + "_next;"); - writer.println("\t\t" + param.getSimpleName() + "_next += strlen(" + param.getSimpleName() + "_next) + 1;"); - writer.println("\t} while ( " + param.getSimpleName() + "_i < " + stringList_annotation.value() + " );"); + writer.println("\twhile ( _str_i < " + stringList_annotation.value() + " ) {"); + if ( lengths.length() == 0 ) { + writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i++] = _str_address;"); + writer.println("\t\t_str_address += strlen(_str_address_next) + 1;"); + } else { + writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i] = _str_address;"); + writer.println("\t\t_str_address += " + lengths + BUFFER_ADDRESS_POSTFIX + "[_str_i++];"); + } + writer.println("\t}"); } } } diff --git a/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java b/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java index 24b20ed0..f751d02f 100644 --- a/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java +++ b/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java @@ -104,7 +104,12 @@ public class NativeTypeTranslator implements TypeVisitor { } public void visitArrayType(ArrayType t) { - throw new RuntimeException(t + " is not allowed"); + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) { + is_indirect = true; + native_types = new ArrayList(); + native_types.add(GLchar.class); + } else + throw new RuntimeException(t + " is not allowed"); } public static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) { diff --git a/src/java/org/lwjgl/util/generator/StringList.java b/src/java/org/lwjgl/util/generator/StringList.java index 3277cc67..0d9e20da 100644 --- a/src/java/org/lwjgl/util/generator/StringList.java +++ b/src/java/org/lwjgl/util/generator/StringList.java @@ -41,5 +41,8 @@ import java.lang.annotation.Target; @Target({ElementType.PARAMETER, ElementType.METHOD}) public @interface StringList { + /** Number of values in the string list (name of native-side parameter) */ String value(); + /** List of string lengths (name of native-side parameter) */ + String lengths() default ""; } \ No newline at end of file diff --git a/src/java/org/lwjgl/util/generator/TypedefsGenerator.java b/src/java/org/lwjgl/util/generator/TypedefsGenerator.java index e84c337a..2096a9fd 100644 --- a/src/java/org/lwjgl/util/generator/TypedefsGenerator.java +++ b/src/java/org/lwjgl/util/generator/TypedefsGenerator.java @@ -82,8 +82,10 @@ public class TypedefsGenerator { } public static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, Collection methods) { - for (MethodDeclaration method : methods) - generateNativeTypedefs(type_map, writer, method); + for (MethodDeclaration method : methods) { + if ( method.getAnnotation(Alternate.class) == null ) + generateNativeTypedefs(type_map, writer, method); + } } } diff --git a/src/java/org/lwjgl/util/generator/Utils.java b/src/java/org/lwjgl/util/generator/Utils.java index f4dc9114..4c0c8557 100644 --- a/src/java/org/lwjgl/util/generator/Utils.java +++ b/src/java/org/lwjgl/util/generator/Utils.java @@ -43,9 +43,16 @@ package org.lwjgl.util.generator; import com.sun.mirror.type.*; import java.nio.Buffer; import java.io.*; +import java.nio.ByteBuffer; import java.util.*; +import javax.lang.model.util.SimpleTypeVisitor6; + import com.sun.mirror.declaration.*; +import com.sun.mirror.type.PrimitiveType.Kind; +import com.sun.mirror.util.SimpleTypeVisitor; +import com.sun.mirror.util.TypeVisitor; +import com.sun.mirror.util.Types; public class Utils { public static final String TYPEDEF_POSTFIX = "PROC"; @@ -63,11 +70,20 @@ public class Utils { private static final String OVERLOADED_METHOD_PREFIX = "n"; public static String getTypedefName(MethodDeclaration method) { - return method.getSimpleName() + TYPEDEF_POSTFIX; + Alternate alt_annotation = method.getAnnotation(Alternate.class); + return (alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + TYPEDEF_POSTFIX; } public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method) { - return interface_decl.getSimpleName() + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX; + return getFunctionAddressName(interface_decl, method, false); + } + + public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method, boolean forceAlt) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) ) + return interface_decl.getSimpleName() + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX; + else + return interface_decl.getSimpleName() + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX; } public static boolean isFinal(InterfaceDeclaration d) { @@ -103,7 +119,7 @@ public class Utils { } public static boolean isAddressableType(Class type) { - return Buffer.class.isAssignableFrom(type) || String.class.equals(type); + return Buffer.class.isAssignableFrom(type) || String.class.equals(type) || CharSequence.class.equals(type) || CharSequence[].class.equals(type); } public static Class getJavaType(TypeMirror type_mirror) { @@ -248,6 +264,8 @@ public class Utils { Class param_type = getJavaType(t); if (Buffer.class.isAssignableFrom(param_type)) return param_type; + else if ( param_type == CharSequence.class || param_type == CharSequence[].class ) + return ByteBuffer.class; else return null; } @@ -255,10 +273,15 @@ public class Utils { public static String getSimpleNativeMethodName(MethodDeclaration method, boolean generate_error_checks, boolean context_specific) { String method_name; Alternate alt_annotation = method.getAnnotation(Alternate.class); - method_name = alt_annotation == null ? method.getSimpleName() : alt_annotation.value(); + method_name = alt_annotation == null || alt_annotation.nativeAlt() ? method.getSimpleName() : alt_annotation.value(); if (isMethodIndirect(generate_error_checks, context_specific, method)) method_name = OVERLOADED_METHOD_PREFIX + method_name; return method_name; } + static boolean isReturnString(MethodDeclaration method, ParameterDeclaration param) { + GLstring string_annotation = method.getAnnotation(GLstring.class); + return string_annotation != null && string_annotation.string().equals(param.getSimpleName()); + } + } diff --git a/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java b/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java index 53cf59e2..5750aec9 100644 --- a/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java +++ b/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java @@ -68,13 +68,24 @@ public interface AMD_performance_monitor { void glGetPerfMonitorGroupStringAMD(@GLuint int group, @AutoSize("groupString") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer groupString); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer groupString); - void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, - @AutoSize("counterString") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer counterString); + @Alternate("glGetPerfMonitorGroupStringAMD") + @GLstring(string = "groupString", maxLength = "bufSize") + void glGetPerfMonitorGroupStringAMD2(@GLuint int group, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("groupString_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer groupString); + + void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, @AutoSize("counterString") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer counterString); + + @Alternate("glGetPerfMonitorCounterStringAMD") + @GLstring(string = "counterString", maxLength = "bufSize") + void glGetPerfMonitorCounterStringAMD2(@GLuint int group, @GLuint int counter, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("counterString_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer counterString); void glGetPerfMonitorCounterInfoAMD(@GLuint int group, @GLuint int counter, @GLenum int pname, @Check(value = "16") @GLvoid ByteBuffer data); diff --git a/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java b/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java index 9ac91efb..ab6b007e 100644 --- a/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java +++ b/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java @@ -31,10 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.Const; -import org.lwjgl.util.generator.GLchar; -import org.lwjgl.util.generator.GLuint; -import org.lwjgl.util.generator.NullTerminated; +import org.lwjgl.util.generator.*; import java.nio.ByteBuffer; @@ -58,6 +55,12 @@ public interface ARB_blend_func_extended { void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glBindFragDataLocationIndexed") + void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name); + int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glGetFragDataIndex") + int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name); + } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_shader_objects.java b/src/templates/org/lwjgl/opengl/ARB_shader_objects.java index 159f491a..03d80324 100644 --- a/src/templates/org/lwjgl/opengl/ARB_shader_objects.java +++ b/src/templates/org/lwjgl/opengl/ARB_shader_objects.java @@ -105,14 +105,16 @@ public interface ARB_shader_objects { * This method uses just a single string, that should NOT be null-terminated. */ void glShaderSourceARB(@GLhandleARB int shader, @Constant("1") @GLsizei int count, - @Indirect - @Check - @Const - @GLcharARB ByteBuffer string, - @AutoSize("string") - @Indirect - @Const - @GLint int length); + @Indirect @Const @GLcharARB @Check ByteBuffer string, + @AutoSize("string") @Indirect @Const @GLint int length); + + @Alternate("glShaderSourceARB") + void glShaderSourceARB2(@GLhandleARB int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length); + + @Alternate(value = "glShaderSourceARB", nativeAlt = true) + void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count, + @Const @StringList(value = "count", lengths = "length") CharSequence[] strings, + @Constant("StringUtils.getLengths(strings), 0") @Const IntBuffer length); void glCompileShaderARB(@GLhandleARB int shaderObj); @@ -183,18 +185,18 @@ public interface ARB_shader_objects { void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check IntBuffer params); void glGetInfoLogARB(@GLhandleARB int obj, @AutoSize("infoLog") @GLsizei int maxLength, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @OutParameter - @GLcharARB ByteBuffer infoLog); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLcharARB ByteBuffer infoLog); + + @Alternate("glGetInfoLogARB") + @GLstring(string = "infoLog", maxLength = "maxLength") + void glGetInfoLogARB2(@GLhandleARB int obj, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length, + @OutParameter @GLcharARB ByteBuffer infoLog); void glGetAttachedObjectsARB(@GLhandleARB int containerObj, @AutoSize("obj") @GLsizei int maxCount, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer count, - @OutParameter - @GLhandleARB IntBuffer obj); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer count, + @OutParameter @GLhandleARB IntBuffer obj); /** * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a null-terminated string. @@ -204,15 +206,22 @@ public interface ARB_shader_objects { */ int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); + @Alternate("glGetUniformLocationARB") + int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated CharSequence name); + void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @Check("1") IntBuffer size, - @Check("1") - @GLenum IntBuffer type, - @OutParameter - @GLcharARB ByteBuffer name); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); + + @Alternate("glGetActiveUniformARB") + @GLstring(string = "name", maxLength = "maxLength") + void glGetActiveUniformARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); @StripPostfix("params") void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params); @@ -221,9 +230,13 @@ public interface ARB_shader_objects { void glGetUniformivARB(@GLhandleARB int programObj, int location, @OutParameter @Check IntBuffer params); void glGetShaderSourceARB(@GLhandleARB int obj, @AutoSize("source") @GLsizei int maxLength, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @OutParameter - @GLcharARB ByteBuffer source); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLcharARB ByteBuffer source); + + @Alternate("glGetShaderSourceARB") + @GLstring(string = "source", maxLength = "maxLength") + void glGetShaderSourceARB2(@GLhandleARB int obj, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length, + @OutParameter @GLcharARB ByteBuffer source); + } diff --git a/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java b/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java index db57f94c..a2083255 100644 --- a/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java +++ b/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java @@ -45,29 +45,50 @@ public interface ARB_shading_language_include { int GL_NAMED_STRING_LENGTH_ARB = 0x8DE9; int GL_NAMED_STRING_TYPE_ARB = 0x8DEA; - void glNamedStringARB(@GLenum int type, @AutoSize("name") int namelen, @Const ByteBuffer name, @AutoSize("string") int stringlen, @Const ByteBuffer string); + void glNamedStringARB(@GLenum int type, + @AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, + @AutoSize("string") int stringlen, @Const @GLchar ByteBuffer string); - void glDeleteNamedStringARB(@AutoSize("name") int namelen, @Const ByteBuffer name); + @Alternate("glNamedStringARB") + void glNamedStringARB(@GLenum int type, + @Constant("name.length()") int namelen, CharSequence name, + @Constant("string.length()") int stringlen, @GLstringOffset("name.length()") CharSequence string); + + void glDeleteNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name); + + @Alternate("glDeleteNamedStringARB") + void glDeleteNamedStringARB(@Constant("name.length()") int namelen, CharSequence name); void glCompileShaderIncludeARB(@GLuint int shader, @GLsizei int count, @Const @NullTerminated("count") @StringList("count") @GLchar ByteBuffer path, @Constant("null, 0") @Const IntBuffer length); - /* TODO: Implement @Check - @Alternate("glCompileShaderIncludeARB") - void glCompileShaderIncludeARB2(@GLuint int shader, @AutoSize("length") @GLsizei int count, - @Const @Check("...") @StringList("count") @GLchar ByteBuffer path, - @Const IntBuffer length); - */ + @Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true) + void glCompileShaderIncludeARB2(@GLuint int shader, @Constant("path.length") @GLsizei int count, + @Const @StringList(value = "count", lengths = "length") CharSequence[] path, + @Constant("StringUtils.getLengths(path), 0") @Const IntBuffer length); - boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const ByteBuffer name); + boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name); - void glGetNamedStringARB(@AutoSize("name") int namelen, @Const ByteBuffer name, + @Alternate("glIsNamedStringARB") + boolean glIsNamedStringARB(@Constant("name.length()") int namelen, CharSequence name); + + void glGetNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, + @AutoSize("string") @GLsizei int bufSize, + @OutParameter @Check(value = "1", canBeNull = true) IntBuffer stringlen, + @OutParameter ByteBuffer string); + + @Alternate("glGetNamedStringARB") + void glGetNamedStringARB(@Constant("name.length()") int namelen, CharSequence name, @AutoSize("string") @GLsizei int bufSize, @OutParameter @Check(value = "1", canBeNull = true) IntBuffer stringlen, @OutParameter ByteBuffer string); @StripPostfix("params") - void glGetNamedStringivARB(@AutoSize("name") int namelen, @Const ByteBuffer name, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); + void glGetNamedStringivARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); + + @StripPostfix("params") + @Alternate("glGetNamedStringivARB") + void glGetNamedStringivARB2(@Constant("name.length()") int namelen, CharSequence name, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java index 9d428894..6c3cbf70 100644 --- a/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java +++ b/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java @@ -102,26 +102,46 @@ public interface ARB_uniform_buffer_object { @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames, @OutParameter @GLuint IntBuffer uniformIndices); + @Alternate(value = "glGetUniformIndices") + void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount, + @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames, + @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices); + @StripPostfix("params") void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, @Const @GLuint IntBuffer uniformIndices, - @GLenum int pname, - @Check(value = "1") @GLint IntBuffer params); // TODO: We need to AutoSize "params" using "uniformCount" + @GLenum int pname, @Check("uniformIndices.remaining()") @GLint IntBuffer params); void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer uniformName); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformName); + + @Alternate("glGetActiveUniformName") + @GLstring(string = "uniformName", maxLength = "bufSize") + void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformName); @GLuint int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName); + @Alternate("glGetUniformBlockIndex") + @GLuint + int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName); + @StripPostfix("params") void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, @OutParameter @Check(value = "16") @GLint IntBuffer params); void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer uniformBlockName); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformBlockName); + + @Alternate("glGetActiveUniformBlockName") + @GLstring(string = "uniformBlockName", maxLength = "bufSize") + void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformBlockName); void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size); diff --git a/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java b/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java index 7c622695..2462649f 100644 --- a/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java +++ b/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java @@ -141,22 +141,28 @@ public interface ARB_vertex_shader { void glBindAttribLocationARB(@GLhandleARB int programObj, @GLuint int index, @NullTerminated @Const @GLcharARB ByteBuffer name); - void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, - @AutoSize("name") - @GLsizei int maxLength, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @OutParameter - @Check("1") IntBuffer size, - @OutParameter - @Check("1") - @GLenum IntBuffer type, - @OutParameter - @GLcharARB ByteBuffer name); + @Alternate("glBindAttribLocationARB") + void glBindAttribLocationARB(@GLhandleARB int programObj, @GLuint int index, @NullTerminated CharSequence name); + + void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); + + @Alternate("glGetActiveAttribARB") + @GLstring(string = "name", maxLength = "maxLength") + void glGetActiveAttribARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); + @Alternate("glGetAttribLocationARB") + int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated CharSequence name); + @StripPostfix("params") void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check FloatBuffer params); diff --git a/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java b/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java index d2cb6a32..939579c3 100644 --- a/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java +++ b/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java @@ -178,6 +178,12 @@ public interface EXT_gpu_shader4 { void glBindFragDataLocationEXT(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glBindFragDataLocationEXT") + void glBindFragDataLocationEXT(@GLuint int program, @GLuint int colorNumber, @NullTerminated CharSequence name); + int glGetFragDataLocationEXT(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glGetFragDataLocationEXT") + int glGetFragDataLocationEXT(@GLuint int program, @NullTerminated CharSequence name); + } diff --git a/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java b/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java index 723b1b60..152d4b11 100644 --- a/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java +++ b/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java @@ -46,4 +46,8 @@ public interface EXT_separate_shader_objects { @GLuint int glCreateShaderProgramEXT(@GLenum int type, @NullTerminated @Const @GLchar ByteBuffer string); + @Alternate("glCreateShaderProgramEXT") + @GLuint + int glCreateShaderProgramEXT(@GLenum int type, @NullTerminated CharSequence string); + } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java b/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java index 1f1152a4..71bfc50d 100644 --- a/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java +++ b/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java @@ -105,11 +105,23 @@ public interface EXT_transform_feedback { @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings, @GLenum int bufferMode); - void glGetTransformFeedbackVaryingEXT(@GLuint int program, @GLuint int index, - @AutoSize("name") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer size, - @OutParameter @Check(value = "1", canBeNull = true) @GLenum IntBuffer type, + @Alternate("glTransformFeedbackVaryingsEXT") + void glTransformFeedbackVaryingsEXT(@GLuint int program, @Constant("varyings.length") @GLsizei int count, + @Const @NullTerminated @StringList("count") CharSequence[] varyings, + @GLenum int bufferMode); + + void glGetTransformFeedbackVaryingEXT(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, @GLchar ByteBuffer name); + @Alternate("glGetTransformFeedbackVaryingEXT") + @GLstring(string = "name", maxLength = "bufSize") + void glGetTransformFeedbackVaryingEXT2(@GLuint int program, @GLuint int index, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @GLchar ByteBuffer name); + } \ No newline at end of file diff --git a/src/templates/org/lwjgl/opengl/GL20.java b/src/templates/org/lwjgl/opengl/GL20.java index 7709843c..a998f087 100644 --- a/src/templates/org/lwjgl/opengl/GL20.java +++ b/src/templates/org/lwjgl/opengl/GL20.java @@ -40,23 +40,17 @@ public interface GL20 { // -------------------[ ARB_shading_language_100 ]------------------- // ------------------------------------------------------------------ - /** - * Accepted by the <name> parameter of GetString: - */ + /** Accepted by the <name> parameter of GetString: */ int GL_SHADING_LANGUAGE_VERSION = 0x8B8C; // ------------------------------------------------------------------ // ----------------------[ ARB_shader_objects ]---------------------- // ------------------------------------------------------------------ - /** - * Accepted by the <pname> argument of GetInteger: - */ + /** Accepted by the <pname> argument of GetInteger: */ int GL_CURRENT_PROGRAM = 0x8B8D; - /** - * Accepted by the <pname> parameter of GetObjectParameter{fi}vARB: - */ + /** Accepted by the <pname> parameter of GetObjectParameter{fi}vARB: */ int GL_SHADER_TYPE = 0x8B4F; int GL_DELETE_STATUS = 0x8B80; int GL_COMPILE_STATUS = 0x8B81; @@ -70,14 +64,10 @@ public interface GL20 { int GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A; int GL_SHADER_SOURCE_LENGTH = 0x8B88; - /** - * Returned by the <params> parameter of GetObjectParameter{fi}vARB: - */ + /** Returned by the <params> parameter of GetObjectParameter{fi}vARB: */ int GL_SHADER_OBJECT = 0x8B48; - /** - * Returned by the <type> parameter of GetActiveUniformARB: - */ + /** Returned by the <type> parameter of GetActiveUniformARB: */ int GL_FLOAT_VEC2 = 0x8B50; int GL_FLOAT_VEC3 = 0x8B51; int GL_FLOAT_VEC4 = 0x8B52; @@ -107,14 +97,16 @@ public interface GL20 { * @param string */ void glShaderSource(@GLuint int shader, @Constant("1") @GLsizei int count, - @Indirect - @Check - @Const - @GLchar ByteBuffer string, - @AutoSize("string") - @Indirect - @Const - @GLint int length); + @Indirect @Const @GLchar @Check ByteBuffer string, + @AutoSize("string") @Indirect @Const @GLint int length); + + @Alternate("glShaderSource") + void glShaderSource2(@GLuint int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length); + + @Alternate(value = "glShaderSource", nativeAlt = true) + void glShaderSource3(@GLuint int shader, @Constant("strings.length") @GLsizei int count, + @Const @StringList(value = "count", lengths = "length") CharSequence[] strings, + @Constant("StringUtils.getLengths(strings), 0") @Const IntBuffer length); int glCreateShader(@GLuint int type); @@ -199,25 +191,28 @@ public interface GL20 { void glGetProgramiv(@GLuint int program, @GLenum int pname, @OutParameter @Check IntBuffer params); void glGetShaderInfoLog(@GLuint int shader, @AutoSize("infoLog") @GLsizei int maxLength, - @OutParameter - @GLsizei - @Check(value = "1", canBeNull = true) IntBuffer length, - @OutParameter - @GLchar ByteBuffer infoLog); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer infoLog); + + @Alternate("glGetShaderInfoLog") + @GLstring(string = "infoLog", maxLength = "maxLength") + void glGetShaderInfoLog2(@GLuint int shader, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer infoLog); void glGetProgramInfoLog(@GLuint int program, @AutoSize("infoLog") @GLsizei int maxLength, - @OutParameter - @GLsizei - @Check(value = "1", canBeNull = true) IntBuffer length, - @OutParameter - @GLchar ByteBuffer infoLog); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer infoLog); + + @Alternate("glGetProgramInfoLog") + @GLstring(string = "infoLog", maxLength = "maxLength") + void glGetProgramInfoLog2(@GLuint int program, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer infoLog); void glGetAttachedShaders(@GLuint int program, @AutoSize("shaders") @GLsizei int maxCount, - @OutParameter - @GLsizei - @Check(value = "1", canBeNull = true) IntBuffer count, - @OutParameter - @GLuint IntBuffer shaders); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer count, + @OutParameter @GLuint IntBuffer shaders); /** * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a @@ -225,19 +220,26 @@ public interface GL20 { * * @param program * @param name - * */ int glGetUniformLocation(@GLuint int program, @NullTerminated @Check("1") @Const @GLchar ByteBuffer name); + @Alternate("glGetUniformLocation") + int glGetUniformLocation(@GLuint int program, @NullTerminated CharSequence name); + void glGetActiveUniform(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, - @Check(value = "1", canBeNull = true) - @OutParameter @GLsizei IntBuffer length, - @Check - @OutParameter @GLsizei IntBuffer size, - @Check - @OutParameter @GLenum IntBuffer type, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, @OutParameter @GLchar ByteBuffer name); + @Alternate("glGetActiveUniform") + @GLstring(string = "name", maxLength = "maxLength") + void glGetActiveUniform2(@GLuint int program, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + @StripPostfix("params") void glGetUniformfv(@GLuint int program, int location, @OutParameter @Check FloatBuffer params); @@ -245,10 +247,14 @@ public interface GL20 { void glGetUniformiv(@GLuint int program, int location, @OutParameter @Check IntBuffer params); void glGetShaderSource(@GLuint int shader, @AutoSize("source") @GLsizei int maxLength, - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @OutParameter - @GLchar ByteBuffer source); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer source); + + @Alternate("glGetShaderSource") + @GLstring(string = "source", maxLength = "maxLength") + void glGetShaderSource2(@GLuint int shader, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer source); // ------------------------------------------------------------------ // ----------------------[ ARB_vertex_program ]---------------------- @@ -281,7 +287,7 @@ public interface GL20 { void glVertexAttrib4Nub(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); void glVertexAttribPointer(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride, - @CachedReference(index="index",name="glVertexAttribPointer_buffer") + @CachedReference(index = "index", name = "glVertexAttribPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @Check @Const @@ -340,9 +346,7 @@ public interface GL20 { int GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642; int GL_VERTEX_PROGRAM_TWO_SIDE = 0x8643; - /** - * Accepted by the <pname> parameter of GetVertexAttrib{dfi}vARB: - */ + /** Accepted by the <pname> parameter of GetVertexAttrib{dfi}vARB: */ int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622; int GL_VERTEX_ATTRIB_ARRAY_SIZE = 0x8623; int GL_VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624; @@ -350,24 +354,33 @@ public interface GL20 { int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A; int GL_CURRENT_VERTEX_ATTRIB = 0x8626; - /** - * Accepted by the <pname> parameter of GetVertexAttribPointervARB: - */ + /** Accepted by the <pname> parameter of GetVertexAttribPointervARB: */ int GL_VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; void glBindAttribLocation(@GLuint int program, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glBindAttribLocation") + void glBindAttribLocation(@GLuint int program, @GLuint int index, @NullTerminated CharSequence name); + void glGetActiveAttrib(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @Check("1") IntBuffer size, - @Check("1") @GLenum IntBuffer type, - @OutParameter - @GLchar ByteBuffer name); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + @Alternate("glGetActiveAttrib") + @GLstring(string = "name", maxLength = "maxLength") + void glGetActiveAttrib2(@GLuint int program, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); int glGetAttribLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glGetAttribLocation") + int glGetAttribLocation(@GLuint int program, @NullTerminated CharSequence name); + // ------------------------------------------------------------------- // ----------------------[ ARB_fragment_shader ]---------------------- // ------------------------------------------------------------------- @@ -443,9 +456,7 @@ public interface GL20 { */ int GL_POINT_SPRITE_COORD_ORIGIN = 0x8CA0; - /** - * Accepted by the <param> parameter of PointParameter{if}vARB: - */ + /** Accepted by the <param> parameter of PointParameter{if}vARB: */ int GL_LOWER_LEFT = 0x8CA1; int GL_UPPER_LEFT = 0x8CA2; diff --git a/src/templates/org/lwjgl/opengl/GL30.java b/src/templates/org/lwjgl/opengl/GL30.java index 5a79705d..b50eb2ca 100644 --- a/src/templates/org/lwjgl/opengl/GL30.java +++ b/src/templates/org/lwjgl/opengl/GL30.java @@ -76,14 +76,14 @@ public interface GL30 { String glGetStringi(@GLenum int name, @GLuint int index); @StripPostfix("value") - void glClearBufferfv(@GLenum int buffer, int drawbuffer, @Const @Check("4")FloatBuffer value); + void glClearBufferfv(@GLenum int buffer, int drawbuffer, @Const @Check("4") FloatBuffer value); @StripPostfix("value") - void glClearBufferiv(@GLenum int buffer, int drawbuffer, @Const @Check("4")IntBuffer value); + void glClearBufferiv(@GLenum int buffer, int drawbuffer, @Const @Check("4") IntBuffer value); @StripPostfix("value") - void glClearBufferuiv(@GLenum int buffer, int drawbuffer, @Const @Check("4")IntBuffer value); - + void glClearBufferuiv(@GLenum int buffer, int drawbuffer, @Const @Check("4") IntBuffer value); + void glClearBufferfi(@GLenum int buffer, int drawbuffer, float depth, int stencil); // --------------------------------------------------------------- @@ -194,7 +194,7 @@ public interface GL30 { @GLuint Buffer buffer); @StripPostfix("params") - void glGetVertexAttribIiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + void glGetVertexAttribIiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") void glGetVertexAttribIuiv(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); @@ -224,8 +224,14 @@ public interface GL30 { void glBindFragDataLocation(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glBindFragDataLocation") + void glBindFragDataLocation(@GLuint int program, @GLuint int colorNumber, @NullTerminated CharSequence name); + int glGetFragDataLocation(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glGetFragDataLocation") + int glGetFragDataLocation(@GLuint int program, @NullTerminated CharSequence name); + // --------------------------------------------------------------------- // ----------------------[ NV_conditional_render ]---------------------- // --------------------------------------------------------------------- @@ -262,7 +268,7 @@ public interface GL30 { *

* Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. * - * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. * * @return A ByteBuffer representing the mapped buffer memory. */ @@ -480,22 +486,22 @@ public interface GL30 { void glBindRenderbuffer(@GLenum int target, @GLuint int renderbuffer); - void glDeleteRenderbuffers(@AutoSize("renderbuffers")int n, @Const @GLuint IntBuffer renderbuffers); + void glDeleteRenderbuffers(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers); - void glGenRenderbuffers(@AutoSize("renderbuffers")int n, @OutParameter @GLuint IntBuffer renderbuffers); + void glGenRenderbuffers(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers); void glRenderbufferStorage(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); @StripPostfix("params") - void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + void glGetRenderbufferParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); boolean glIsFramebuffer(@GLuint int framebuffer); void glBindFramebuffer(@GLenum int target, @GLuint int framebuffer); - void glDeleteFramebuffers(@AutoSize("framebuffers")int n, @Const @GLuint IntBuffer framebuffers); + void glDeleteFramebuffers(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers); - void glGenFramebuffers(@AutoSize("framebuffers")int n, @OutParameter @GLuint IntBuffer framebuffers); + void glGenFramebuffers(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers); @GLenum int glCheckFramebufferStatus(@GLenum int target); @@ -509,7 +515,7 @@ public interface GL30 { void glFramebufferRenderbuffer(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); @StripPostfix("params") - void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + void glGetFramebufferAttachmentParameteriv(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glGenerateMipmap(@GLenum int target); @@ -648,13 +654,13 @@ public interface GL30 { int GL_BGRA_INTEGER = 0x8D9B; @StripPostfix("params") - void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Check("4")IntBuffer params); + void glTexParameterIiv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); @StripPostfix("params") void glTexParameterIuiv(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); @StripPostfix("params") - void glGetTexParameterIiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); + void glGetTexParameterIiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") void glGetTexParameterIuiv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); @@ -755,7 +761,7 @@ public interface GL30 { void glGetBooleani_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data); @StripPostfix("data") - void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4")IntBuffer data); + void glGetIntegeri_v(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data); void glEnablei(@GLenum int target, @GLuint int index); @@ -894,13 +900,25 @@ public interface GL30 { @Const @NullTerminated("count") @GLchar @StringList("count") ByteBuffer varyings, @GLenum int bufferMode); - void glGetTransformFeedbackVarying(@GLuint int program, @GLuint int index, - @AutoSize("name") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer size, - @OutParameter @Check(value = "1", canBeNull = true) @GLenum IntBuffer type, + @Alternate("glTransformFeedbackVaryings") + void glTransformFeedbackVaryings(@GLuint int program, @Constant("varyings.length") @GLsizei int count, + @Const @NullTerminated @StringList("count") CharSequence[] varyings, + @GLenum int bufferMode); + + void glGetTransformFeedbackVarying(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, @GLchar ByteBuffer name); + @Alternate("glGetTransformFeedbackVarying") + @GLstring(string = "name", maxLength = "bufSize") + void glGetTransformFeedbackVarying2(@GLuint int program, @GLuint int index, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @GLchar ByteBuffer name); + // ----------------------------------------------------------------------- // ----------------------[ ARB_vertex_array_object ]---------------------- // ----------------------------------------------------------------------- diff --git a/src/templates/org/lwjgl/opengl/GL31.java b/src/templates/org/lwjgl/opengl/GL31.java index 4819ad5f..70463a6a 100644 --- a/src/templates/org/lwjgl/opengl/GL31.java +++ b/src/templates/org/lwjgl/opengl/GL31.java @@ -64,11 +64,11 @@ public interface GL31 { void glDrawArraysInstanced(@GLenum int mode, int first, @GLsizei int count, @GLsizei int primcount); void glDrawElementsInstanced(@GLenum int mode, @AutoSize("indices") @GLsizei int count, @AutoType("indices") @GLenum int type, - @BufferObject(BufferKind.ElementVBO) - @Const - @GLubyte - @GLushort - @GLuint Buffer indices, @GLsizei int primcount); + @BufferObject(BufferKind.ElementVBO) + @Const + @GLubyte + @GLushort + @GLuint Buffer indices, @GLsizei int primcount); // --------------------------------------------------------------- // ----------------------[ EXT_copy_buffer ]---------------------- @@ -232,29 +232,49 @@ public interface GL31 { int GL_INVALID_INDEX = 0xFFFFFFFF; void glGetUniformIndices(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, - @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames, - @OutParameter @GLuint IntBuffer uniformIndices); + @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames, + @OutParameter @GLuint IntBuffer uniformIndices); + + @Alternate("glGetUniformIndices") + void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount, + @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames, + @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices); @StripPostfix("params") void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, - @Const @GLuint IntBuffer uniformIndices, - @GLenum int pname, - @Check(value = "1") @GLint IntBuffer params); // TODO: We need to AutoSize "params" using "uniformCount" + @Const @GLuint IntBuffer uniformIndices, + @GLenum int pname, @Check("uniformIndices.remaining()") @GLint IntBuffer params); void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer uniformName); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @GLchar ByteBuffer uniformName); + + @Alternate("glGetActiveUniformName") + @GLstring(string = "uniformName", maxLength = "bufSize") + void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length, + @GLchar ByteBuffer uniformName); @GLuint int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName); + @Alternate("glGetUniformBlockIndex") + @GLuint + int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName); + @StripPostfix("params") void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, - @OutParameter @Check(value = "16") @GLint IntBuffer params); + @OutParameter @Check(value = "16") @GLint IntBuffer params); void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer uniformBlockName); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @GLchar ByteBuffer uniformBlockName); + + @Alternate("glGetActiveUniformBlockName") + @GLstring(string = "uniformBlockName", maxLength = "bufSize") + void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length, + @GLchar ByteBuffer uniformBlockName); void glUniformBlockBinding(@GLuint int program, @GLuint int uniformBlockIndex, @GLuint int uniformBlockBinding); diff --git a/src/templates/org/lwjgl/opengl/GL33.java b/src/templates/org/lwjgl/opengl/GL33.java index d8247e18..48e753eb 100644 --- a/src/templates/org/lwjgl/opengl/GL33.java +++ b/src/templates/org/lwjgl/opengl/GL33.java @@ -63,8 +63,14 @@ public interface GL33 { void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glBindFragDataLocationIndexed") + void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name); + int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glGetFragDataIndex") + int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name); + // -------------------------------------------------------------------- // ----------------------[ ARB_occlusion_query2 ]---------------------- // -------------------------------------------------------------------- diff --git a/src/templates/org/lwjgl/opengl/NV_transform_feedback.java b/src/templates/org/lwjgl/opengl/NV_transform_feedback.java index bc8f195d..17418e83 100644 --- a/src/templates/org/lwjgl/opengl/NV_transform_feedback.java +++ b/src/templates/org/lwjgl/opengl/NV_transform_feedback.java @@ -33,8 +33,8 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; -import java.nio.IntBuffer; import java.nio.ByteBuffer; +import java.nio.IntBuffer; public interface NV_transform_feedback { @@ -128,13 +128,28 @@ public interface NV_transform_feedback { int glGetVaryingLocationNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glGetVaryingLocationNV") + int glGetVaryingLocationNV(@GLuint int program, @NullTerminated CharSequence name); + void glGetActiveVaryingNV(@GLuint int program, @GLuint int index, @AutoSize("name") @GLsizei int bufSize, - @OutParameter @Check("1") @GLsizei IntBuffer length, - @OutParameter @Check("1") @GLsizei IntBuffer size, - @OutParameter @Check("1") @GLenum IntBuffer type, @GLchar ByteBuffer name); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); + + @Alternate("glGetActiveVaryingNV") + @GLstring(string = "name", maxLength = "bufSize") + void glGetActiveVaryingNV2(@GLuint int program, @GLuint int index, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @GLsizei @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLchar ByteBuffer name); void glActiveVaryingNV(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glActiveVaryingNV") + void glActiveVaryingNV(@GLuint int program, @NullTerminated CharSequence name); + void glGetTransformFeedbackVaryingNV(@GLuint int program, @GLuint int index, @OutParameter @Check("1") IntBuffer location); }