|
From: <sp...@us...> - 2009-08-12 13:06:22
|
Revision: 3232
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3232&view=rev
Author: spasi
Date: 2009-08-12 13:06:11 +0000 (Wed, 12 Aug 2009)
Log Message:
-----------
Completed GL32 support.
Added Generator support for wrapping GL pointers.
Added support for passing command-line arguments to tests.
Added test for ARB_sync functionality.
Temp fix to NV_shader_buffer_load.
Modified Paths:
--------------
trunk/LWJGL/build.xml
trunk/LWJGL/src/java/org/lwjgl/test/opengl/VersionTest.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/GLTypeMap.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sync.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL32.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/GLSync.java
trunk/LWJGL/src/java/org/lwjgl/opengl/PointerWrapper.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/SyncTest.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/GLpointer.java
Modified: trunk/LWJGL/build.xml
===================================================================
--- trunk/LWJGL/build.xml 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/build.xml 2009-08-12 13:06:11 UTC (rev 3232)
@@ -389,6 +389,7 @@
<java classname="${test.mainclass}" classpath="res:${lwjgl.lib}/lwjgl.jar:${lwjgl.lib}/lwjgl_util.jar:${lwjgl.lib}/lwjgl_test.jar:${lwjgl.lib}/jinput.jar" fork="true">
<sysproperty key="org.lwjgl.util.Debug" value="true"/>
<sysproperty key="java.library.path" value="${native_path_expanded}"/>
+ <arg line="${args}"/>
</java>
</target>
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/GLSync.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/GLSync.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLSync.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+/**
+ * @author spasi <sp...@us...>
+ */
+public final class GLSync implements PointerWrapper {
+
+ private final long sync;
+
+ GLSync(final long sync) {
+ this.sync = sync;
+ }
+
+ public long getPointer() {
+ return sync;
+ }
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/PointerWrapper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/PointerWrapper.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/PointerWrapper.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+/** @author spasi <sp...@us...> */
+public interface PointerWrapper {
+
+ long getPointer();
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/test/opengl/SyncTest.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/SyncTest.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/SyncTest.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -0,0 +1,184 @@
+/*
+ * 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.test.opengl;
+
+import org.lwjgl.BufferUtils;
+import org.lwjgl.LWJGLException;
+import org.lwjgl.Sys;
+import org.lwjgl.opengl.*;
+
+import java.nio.IntBuffer;
+import java.util.Random;
+
+/**
+ * @author spasi <sp...@us...>
+ */
+public final class SyncTest {
+
+ private SyncTest() {
+ }
+
+ public static void main(String[] args) {
+ runTest(args);
+ cleanup();
+ System.exit(0);
+ }
+
+ private static void runTest(String[] args) {
+ if ( args.length < 2 )
+ argsError("Insufficient number of arguments.");
+
+ int clears = 1;
+ int timeout = 0;
+
+ try {
+ clears = Integer.parseInt(args[0]);
+ timeout = Integer.parseInt(args[1]);
+ } catch (NumberFormatException e) {
+ argsError("Invalid number format.");
+ }
+
+ ContextAttribs ca = new ContextAttribs();
+
+ try {
+ DisplayMode[] modes = Display.getAvailableDisplayModes();
+
+ DisplayMode displayMode = chooseMode(modes, 1024, 768);
+ if ( displayMode == null )
+ displayMode = chooseMode(modes, 800, 600);
+ if ( displayMode == null )
+ displayMode = chooseMode(modes, 640, 480);
+ if ( displayMode == null )
+ kill("Failed to set an appropriate display mode.");
+
+ System.out.println("Setting display mode to: " + displayMode);
+ Display.setDisplayMode(displayMode);
+ Display.create(new PixelFormat(8, 24, 0), ca);
+ } catch (LWJGLException e) {
+ kill(e.getMessage());
+ }
+
+ System.out.println("\n---------\n");
+
+ final String version = GL11.glGetString(GL11.GL_VERSION);
+
+ System.out.println("GL Version: " + version);
+ System.out.println("ARB_sync: " + GLContext.getCapabilities().GL_ARB_sync);
+
+ if ( !GLContext.getCapabilities().OpenGL32 && !GLContext.getCapabilities().GL_ARB_sync )
+ kill("OpenGL3.2 or ARB_sync support is required for this test.");
+
+ System.out.println("\n---------\n");
+
+ System.out.println("Clearing the framebuffer a gazillion times...");
+
+ Random rand = new Random(System.currentTimeMillis());
+ for ( int i = 0; i < clears; i++ ) {
+ GL11.glClearColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 1.0f);
+ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
+ }
+
+ GLSync sync = GL32.glFenceSync(GL32.GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+
+ System.out.println("\nWaiting on fence...");
+ long time = Sys.getTime();
+ int status = GL32.glClientWaitSync(sync, 0, timeout < 0 ? GL32.GL_TIMEOUT_IGNORED : timeout * 1000 * 1000);
+ System.out.println("\nFence sync complete after: " + ((Sys.getTime() - time) / (double)Sys.getTimerResolution()) + " seconds.");
+ System.out.print("\nWait Status: ");
+ switch ( status ) {
+ case GL32.GL_ALREADY_SIGNALED:
+ System.out.println("ALREADY_SIGNALED");
+ break;
+ case GL32.GL_CONDITION_SATISFIED:
+ System.out.println("CONDITION_SATISFIED");
+ break;
+ case GL32.GL_TIMEOUT_EXPIRED:
+ System.out.println("TIMEOUT_EXPIRED");
+ break;
+ case GL32.GL_WAIT_FAILED:
+ System.out.println("WAIT_FAILED");
+ break;
+ default:
+ System.out.println("Unexpected wait status: 0x" + Integer.toHexString(status));
+ }
+
+ IntBuffer property = BufferUtils.createIntBuffer(1);
+ GL32.glGetSynciv(sync, GL32.GL_SYNC_STATUS, null, property);
+ System.out.println("Sync Status: " + (property.get(0) == GL32.GL_UNSIGNALED ? "UNSIGNALED" : "SIGNALED"));
+
+ GL32.glDeleteSync(sync);
+
+ int error = GL11.glGetError();
+ if ( error != 0 )
+ System.out.println("\nTest failed with OpenGL error: " + error);
+ else
+ System.out.println("\nTest completed successfully.");
+ }
+
+ private static DisplayMode chooseMode(DisplayMode[] modes, int width, int height) {
+ DisplayMode bestMode = null;
+
+ for ( int i = 0; i < modes.length; i++ ) {
+ DisplayMode mode = modes[i];
+ if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) {
+ if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) )
+ bestMode = mode;
+ }
+ }
+
+ return bestMode;
+ }
+
+ private static void cleanup() {
+ if ( Display.isCreated() )
+ Display.destroy();
+ }
+
+ private static void argsError(final String msg) {
+ System.out.println("\nInvalid arguments error: " + msg);
+ System.out.println("\nUsage: SyncTest <clears> <timeout>:\n");
+ System.out.println("clears\t- Number of times to clear the framebuffer.");
+ System.out.println("timeout\t- WaitSync timeout in milliseconds.");
+
+ cleanup();
+ System.exit(-1);
+ }
+
+ static void kill(String reason) {
+ System.out.println("The SyncTest program was terminated because an error occured.\n");
+ System.out.println("Reason: " + (reason == null ? "Unknown" : reason));
+
+ cleanup();
+ System.exit(-1);
+ }
+
+}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/VersionTest.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/VersionTest.java 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/VersionTest.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -79,6 +79,10 @@
ca = ca.withDebug(true);
else if ( "fc".equalsIgnoreCase(args[i]) )
ca = ca.withForwardCompatible(true);
+ else if ( "core".equalsIgnoreCase(args[i]) )
+ ca = ca.withProfileCore(true);
+ else if ( "compatibility".equalsIgnoreCase(args[i]) )
+ ca = ca.withProfileCompatibility(true);
else
argsError("Unknown argument: \'" + args[i] + "\'");
}
@@ -108,8 +112,12 @@
final String version = GL11.glGetString(GL11.GL_VERSION);
- System.out.println("GL Version requested: " + majorInput + '.' + minorInput);
- System.out.println("GL Version returned : " + version);
+ System.out.print("GL Version requested: " + majorInput + '.' + minorInput);
+ if ( ca.isProfileCore() )
+ System.out.print(" - Core Profile");
+ else if ( ca.isProfileCompatibility() )
+ System.out.print(" - Compatibility Profile");
+ System.out.println("\nGL Version returned : " + version);
final StringTokenizer version_tokenizer = new StringTokenizer(version, ". ");
@@ -126,6 +134,9 @@
} else
System.out.println("\tThe requested version was returned. :)");
+ if ( ca.isProfileCompatibility() && !GLContext.getCapabilities().GL_ARB_compatibility )
+ System.out.println("\tThe driver does not support the Compatibility Profile.");
+
System.out.println("\n---------\n");
System.out.println("Debug mode: " + ca.isDebug());
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/GLTypeMap.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/GLTypeMap.java 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/GLTypeMap.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -41,6 +41,8 @@
* $Id$
*/
+import org.lwjgl.opengl.PointerWrapper;
+
import java.io.PrintWriter;
import java.nio.*;
import java.util.HashMap;
@@ -82,7 +84,6 @@
native_types_to_primitive.put(GLuint64EXT.class, PrimitiveType.Kind.LONG);
native_types_to_primitive.put(GLint64.class, PrimitiveType.Kind.LONG);
native_types_to_primitive.put(GLuint64.class, PrimitiveType.Kind.LONG);
- native_types_to_primitive.put(GLsync.class, PrimitiveType.Kind.LONG);
}
public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type) {
@@ -197,14 +198,14 @@
else if ( type.equals(DoubleBuffer.class) )
return new Class[] { GLclampd.class, GLdouble.class };
else if ( type.equals(LongBuffer.class) )
- return new Class[] { GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class, GLsync.class };
+ return new Class[] { GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class };
else
return new Class[] { };
}
private static Class[] getValidPrimitiveTypes(Class type) {
if ( type.equals(long.class) )
- return new Class[] { GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class, GLsync.class };
+ return new Class[] { GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class };
else if ( type.equals(int.class) )
return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class,
GLsizei.class };
@@ -240,6 +241,8 @@
valid_types = getValidPrimitiveTypes(type);
else if ( String.class.equals(type) )
valid_types = new Class[] { GLubyte.class };
+ else if ( PointerWrapper.class.isAssignableFrom(type) )
+ valid_types = new Class[] { GLpointer.class };
else
valid_types = new Class[] { };
return valid_types;
Added: trunk/LWJGL/src/java/org/lwjgl/util/generator/GLpointer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/GLpointer.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/GLpointer.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+/**
+ * @author spasi <sp...@us...>
+ */
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+public @interface GLpointer {
+ String value(); // The native pointer type.
+}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -41,6 +41,8 @@
* $Id$
*/
+import org.lwjgl.opengl.PointerWrapper;
+
import com.sun.mirror.apt.*;
import com.sun.mirror.declaration.*;
import com.sun.mirror.type.*;
@@ -82,7 +84,7 @@
Utils.printDocComment(writer, method);
writer.print("\tpublic static native ");
}
- printResultType(writer, method);
+ printResultType(writer, method, true);
writer.print(" " + Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
if (mode == Mode.BUFFEROBJECT)
writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
@@ -131,7 +133,7 @@
if (!first_parameter)
writer.print(", ");
first_parameter = false;
- printResultType(writer, method);
+ printResultType(writer, method, native_stub);
writer.print(" " + Utils.CACHED_BUFFER_NAME);
}
return first_parameter;
@@ -147,7 +149,10 @@
throw new RuntimeException("type of " + param + " is not a nio Buffer parameter but is annotated as buffer object");
writer.print("long " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
} else {
- writer.print(type_info.getType().getSimpleName());
+ if ( native_stub && param.getAnnotation(GLpointer.class) != null )
+ writer.print("long");
+ else
+ writer.print(type_info.getType().getSimpleName());
writer.print(" " + param.getSimpleName());
if (buffer_type != null && native_stub)
writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX);
@@ -179,7 +184,7 @@
private static void printMethodWithMultiType(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean generate_error_checks, boolean context_specific) {
Utils.printDocComment(writer, method);
writer.print("\tpublic static ");
- printResultType(writer, method);
+ printResultType(writer, method, false);
StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
String method_name = method.getSimpleName();
if (strip_annotation != null && mode == Mode.NORMAL)
@@ -204,8 +209,11 @@
writer.print("\t\t");
boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType());
if (has_result) {
- printResultType(writer, method);
+ printResultType(writer, method, false);
writer.print(" " + Utils.RESULT_VAR_NAME + " = ");
+
+ if ( method.getAnnotation(GLpointer.class) != null )
+ writer.print("new " + method.getReturnType() + "(");
}
writer.print(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
if (mode == Mode.BUFFEROBJECT)
@@ -217,6 +225,8 @@
writer.print(", ");
writer.print(Utils.FUNCTION_POINTER_VAR_NAME);
}
+ if ( has_result && method.getAnnotation(GLpointer.class) != null )
+ writer.print(")");
writer.println(");");
if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null)
writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";");
@@ -373,6 +383,8 @@
writer.print(" : 0");
} else
writer.print("0");
+ } else if ( param.getAnnotation(GLpointer.class) != null ) {
+ writer.print(".getPointer()");
}
}
}
@@ -492,7 +504,10 @@
writer.println("\t\tBufferChecks.checkNullTerminated(" + name + ");");
}
- private static void printResultType(PrintWriter writer, MethodDeclaration method) {
- writer.print(Utils.getMethodReturnType(method).toString());
+ private static void printResultType(PrintWriter writer, MethodDeclaration method, boolean native_stub) {
+ if ( native_stub && method.getAnnotation(GLpointer.class) != null )
+ writer.print("long");
+ else
+ writer.print(Utils.getMethodReturnType(method).toString());
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -71,6 +71,8 @@
writer.print(", ");
if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
writer.print("jlong " + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX);
+ } else if ( param.getAnnotation(GLpointer.class) != null ) {
+ writer.print("jlong " + param.getSimpleName());
} else {
JNITypeTranslator translator = new JNITypeTranslator();
param.getType().accept(translator);
@@ -81,14 +83,22 @@
}
private static void generateMethodStub(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, String interface_name, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) {
- TypeMirror result_type = Utils.getMethodReturnType(method);
- JNITypeTranslator translator = new JNITypeTranslator();
- result_type.accept(translator);
- if (!context_specific)
+ if ( !context_specific )
writer.print("static ");
else
writer.print("JNIEXPORT ");
- writer.print(translator.getSignature() + " JNICALL ");
+
+ TypeMirror result_type = Utils.getMethodReturnType(method);
+
+ if ( method.getAnnotation(GLpointer.class) != null ) {
+ writer.print("jlong");
+ } else {
+ JNITypeTranslator translator = new JNITypeTranslator();
+ result_type.accept(translator);
+ writer.print(translator.getSignature());
+ }
+ writer.print(" JNICALL ");
+
writer.print(Utils.getQualifiedNativeMethodName(interface_name, method, generate_error_checks, context_specific));
if (mode == Mode.BUFFEROBJECT)
writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
@@ -140,8 +150,11 @@
writer.print("safeNewBufferCached(env, ");
else
writer.print("safeNewBuffer(env, ");
- } else if (String.class.equals(java_result_type))
+ } else if (String.class.equals(java_result_type)) {
writer.print("NewStringNativeUnsigned(env, ");
+ } else if ( method.getAnnotation(GLpointer.class) != null ) {
+ writer.print("(jlong)");
+ }
writer.print(Utils.RESULT_VAR_NAME);
if (Buffer.class.isAssignableFrom(java_result_type)) {
writer.print(", ");
@@ -176,6 +189,8 @@
writer.print(translator.getSignature());
writer.print("*)");
}
+ if ( param.getAnnotation(GLpointer.class) != null )
+ writer.print("(" + param.getAnnotation(GLpointer.class).value() + ")");
if (param.getAnnotation(Result.class) != null || is_indirect)
writer.print("&");
if (param.getAnnotation(Result.class) != null) {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -42,6 +42,8 @@
* $Id$
*/
+import org.lwjgl.opengl.PointerWrapper;
+
import com.sun.mirror.declaration.*;
import com.sun.mirror.type.*;
import com.sun.mirror.util.*;
@@ -77,8 +79,14 @@
StringBuilder signature = new StringBuilder();
if (declaration.getAnnotation(Const.class) != null)
signature.append("const ");
- // Use the name of the native type annotation as the C type name
- signature.append(getAnnotationType().getSimpleName());
+
+ if ( declaration.getAnnotation(GLpointer.class) != null ) {
+ signature.append(declaration.getAnnotation(GLpointer.class).value());
+ } else {
+ // Use the name of the native type annotation as the C type name
+ signature.append(getAnnotationType().getSimpleName());
+ }
+
if (is_indirect)
signature.append(" *");
return signature.toString();
@@ -131,6 +139,8 @@
}
public void visitClassType(ClassType t) {
+ is_indirect = true;
+
Class<?> c = getClassFromType(t);
if (String.class.equals(c)) {
native_types = new ArrayList<Class>();
@@ -141,9 +151,13 @@
} else if (Buffer.class.isAssignableFrom(c)) {
PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
getNativeTypeFromAnnotatedPrimitiveType(kind);
+ } else if ( PointerWrapper.class.isAssignableFrom(c) ) {
+ native_types = new ArrayList<Class>();
+ native_types.add(GLpointer.class);
+
+ is_indirect = false;
} else
throw new RuntimeException(t + " is not allowed");
- is_indirect = true;
}
public void visitPrimitiveType(PrimitiveType t) {
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sync.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sync.java 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sync.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -70,22 +70,22 @@
int GL_CONDITION_SATISFIED = 0x911C;
int GL_WAIT_FAILED = 0x911D;
- @GLsync
- long glFenceSync(@GLenum int condition, @GLbitfield int flags);
+ @GLpointer("GLsync")
+ GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags);
- boolean glIsSync(@GLsync long sync);
+ boolean glIsSync(@GLpointer("GLsync") GLSync sync);
- void glDeleteSync(@GLsync long sync);
+ void glDeleteSync(@GLpointer("GLsync") GLSync sync);
@GLenum
- int glClientWaitSync(@GLsync long sync, @GLbitfield int flags, @GLuint64 long timeout);
+ int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
- void glWaitSync(@GLsync long sync, @GLbitfield int flags, @GLuint64 long timeout);
+ void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
@StripPostfix("params")
void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
- void glGetSynciv(@GLsync long sync, @GLenum int pname,
+ void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname,
@AutoSize("values") @GLsizei int bufSize,
@OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
@OutParameter IntBuffer values);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL32.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL32.java 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL32.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -35,8 +35,8 @@
import java.nio.Buffer;
import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
import java.nio.LongBuffer;
-import java.nio.IntBuffer;
public interface GL32 {
@@ -296,23 +296,24 @@
int GL_CONDITION_SATISFIED = 0x911C;
int GL_WAIT_FAILED = 0x911D;
- /*
- @GLsync long glFenceSync(@GLenum int condition, @GLbitfield int flags);
+ @GLpointer("GLsync")
+ GLSync glFenceSync(@GLenum int condition, @GLbitfield int flags);
- boolean glIsSync(@GLsync long sync);
+ boolean glIsSync(@GLpointer("GLsync") GLSync sync);
- void glDeleteSync(@GLsync long sync);
+ void glDeleteSync(@GLpointer("GLsync") GLSync sync);
- @GLenum int glClientWaitSync(@GLsync long sync, @GLbitfield int flags, @GLuint64 long timeout);
+ @GLenum
+ int glClientWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
- void glWaitSync(@GLsync long sync, @GLbitfield int flags, @GLuint64 long timeout);
+ void glWaitSync(@GLpointer("GLsync") GLSync sync, @GLbitfield int flags, @GLuint64 long timeout);
@StripPostfix("params")
void glGetInteger64v(@GLenum int pname, @OutParameter @Check("1") @GLint64 LongBuffer params);
- void glGetSynciv(@GLsync long sync, @GLenum int pname,
+ void glGetSynciv(@GLpointer("GLsync") GLSync sync, @GLenum int pname,
@AutoSize("values") @GLsizei int bufSize,
@OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length,
@OutParameter IntBuffer values);
- */
+
}
\ No newline at end of file
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java 2009-08-05 18:54:47 UTC (rev 3231)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_shader_buffer_load.java 2009-08-12 13:06:11 UTC (rev 3232)
@@ -55,10 +55,10 @@
boolean glIsBufferResidentNV(@GLenum int target);
- void glNamedMakeBufferResidentNV(@GLuint int buffer, @GLenum int access);
+ // TODO: These two are currently missing from the latest NV drivers, check again sometime.
+ //void glNamedMakeBufferResidentNV(@GLuint int buffer, @GLenum int access);
+ //void glNamedMakeBufferNonResidentNV(@GLuint int buffer);
- void glNamedMakeBufferNonResidentNV(@GLuint int buffer);
-
boolean glIsNamedBufferResidentNV(@GLuint int buffer);
@StripPostfix("params")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|