You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
1
|
2
(1) |
|
3
|
4
|
5
|
6
|
7
|
8
(1) |
9
(2) |
|
10
(8) |
11
(3) |
12
(13) |
13
(4) |
14
(2) |
15
|
16
(6) |
|
17
(1) |
18
|
19
|
20
|
21
(1) |
22
(2) |
23
(2) |
|
24
(1) |
25
|
26
|
27
|
28
|
29
(1) |
30
|
|
31
|
|
|
|
|
|
|
|
From: <sp...@us...> - 2011-07-29 11:30:22
|
Revision: 3602
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3602&view=rev
Author: spasi
Date: 2011-07-29 11:30:14 +0000 (Fri, 29 Jul 2011)
Log Message:
-----------
Added support for NV_path_rendering.
Made MappedObjectUnsafe package private.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/AutoSize.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java
Added Paths:
-----------
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_path_rendering.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java 2011-07-24 09:38:46 UTC (rev 3601)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -31,11 +31,12 @@
*/
package org.lwjgl.opengl;
-import java.nio.Buffer;
-
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLUtil;
+import java.nio.Buffer;
+import java.nio.FloatBuffer;
+
import static org.lwjgl.opengl.ARBBufferObject.*;
import static org.lwjgl.opengl.ATIVertexArrayObject.*;
import static org.lwjgl.opengl.EXTAbgr.*;
@@ -43,6 +44,7 @@
import static org.lwjgl.opengl.EXTDirectStateAccess.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
+import static org.lwjgl.opengl.NVPathRendering.*;
/**
* A class to check buffer boundaries in GL methods. Many GL
@@ -55,7 +57,7 @@
*
* @author cix_foo <ci...@us...>
* @version $Revision$
- * $Id$
+ * $Id$
*/
class GLChecks {
@@ -81,25 +83,25 @@
/** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
static void ensureArrayVBOdisabled(ContextCapabilities caps) {
- if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
+ if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
}
/** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
static void ensureArrayVBOenabled(ContextCapabilities caps) {
- if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 )
+ if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 )
throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
}
/** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
static void ensureElementVBOdisabled(ContextCapabilities caps) {
- if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 )
+ if ( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 )
throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
}
/** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
static void ensureElementVBOenabled(ContextCapabilities caps) {
- if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 )
+ if ( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 )
throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
}
@@ -209,10 +211,10 @@
case GL_FLOAT:
bpe = 4;
break;
- default :
+ default:
// TODO: Add more types (like the GL12 types GL_UNSIGNED_INT_8_8_8_8
return 0;
- // throw new IllegalArgumentException("Unknown type " + type);
+ // throw new IllegalArgumentException("Unknown type " + type);
}
int epp;
switch ( format ) {
@@ -233,7 +235,7 @@
case GL_BGRA_EXT:
epp = 4;
break;
- default :
+ default:
// TODO: Add more formats. Assuming 4 is too wasteful on buffer sizes where e.g. 1 is enough (like GL_DEPTH_COMPONENT)
return 0;
/* // Assume 4 elements per pixel
@@ -242,4 +244,116 @@
return bpe * epp;
}
-}
+
+ // NV_path_rendering checks
+
+ static int calculateBytesPerCharCode(int type) {
+ switch ( type ) {
+ case GL_UNSIGNED_BYTE:
+ case GL_UTF8_NV:
+ return 1;
+ case GL_UNSIGNED_SHORT:
+ case GL_2_BYTES:
+ case GL_UTF16_NV:
+ return 2;
+ case GL_3_BYTES:
+ return 3;
+ case GL_4_BYTES:
+ return 4;
+ default:
+ throw new IllegalArgumentException("Unsupported charcode type: " + type);
+ }
+ }
+
+ static int calculateBytesPerPathName(int pathNameType) {
+ switch ( pathNameType ) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_UTF8_NV:
+ return 1;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_2_BYTES:
+ case GL_UTF16_NV:
+ return 2;
+ case GL_3_BYTES:
+ return 3;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_4_BYTES:
+ return 4;
+ default:
+ throw new IllegalArgumentException("Unsupported path name type: " + pathNameType);
+ }
+ }
+
+ static int calculateTransformPathValues(int transformType) {
+ switch ( transformType ) {
+ case GL_NONE:
+ return 0;
+ case GL_TRANSLATE_X_NV:
+ case GL_TRANSLATE_Y_NV:
+ return 1;
+ case GL_TRANSLATE_2D_NV:
+ return 2;
+ case GL_TRANSLATE_3D_NV:
+ return 3;
+ case GL_AFFINE_2D_NV:
+ case GL_TRANSPOSE_AFFINE_2D_NV:
+ return 6;
+ case GL_AFFINE_3D_NV:
+ case GL_TRANSPOSE_AFFINE_3D_NV:
+ return 12;
+ default:
+ throw new IllegalArgumentException("Unsupported transform type: " + transformType);
+ }
+ }
+
+ static int calculatePathColorGenCoeffsCount(int genMode, int colorFormat) {
+ final int coeffsPerComponent = calculatePathGenCoeffsPerComponent(genMode);
+
+ switch ( colorFormat ) {
+ case GL_RGB:
+ return 3 * coeffsPerComponent;
+ case GL_RGBA:
+ return 4 * coeffsPerComponent;
+ default:
+ return coeffsPerComponent;
+ }
+ }
+
+ static int calculatePathTextGenCoeffsPerComponent(FloatBuffer coeffs, int genMode) {
+ if ( genMode == GL_NONE )
+ return 0;
+
+ return coeffs.remaining() / calculatePathGenCoeffsPerComponent(genMode);
+ }
+
+ private static int calculatePathGenCoeffsPerComponent(int genMode) {
+ switch ( genMode ) {
+ case GL_NONE:
+ return 0;
+ case GL_OBJECT_LINEAR:
+ case GL_PATH_OBJECT_BOUNDING_BOX_NV:
+ return 3;
+ case GL_EYE_LINEAR:
+ return 4;
+ default:
+ throw new IllegalArgumentException("Unsupported gen mode: " + genMode);
+ }
+ }
+
+ static int calculateMetricsSize(int metricQueryMask, int stride) {
+ if ( LWJGLUtil.DEBUG && (stride < 0 || (stride % 4) != 0) )
+ throw new IllegalArgumentException("Invalid stride value: " + stride);
+
+ final int metrics = Integer.bitCount(metricQueryMask);
+
+ if ( LWJGLUtil.DEBUG && (stride >> 2) < metrics )
+ throw new IllegalArgumentException("The queried metrics do not fit in the specified stride: " + stride);
+
+ return stride == 0 ? metrics : (stride >> 2);
+ }
+
+}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-24 09:38:46 UTC (rev 3601)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -32,7 +32,6 @@
package org.lwjgl.test.mapped;
import org.lwjgl.MemoryUtil;
-import org.lwjgl.util.mapped.MappedObjectUnsafe;
import java.nio.ByteBuffer;
import java.util.Arrays;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-24 09:38:46 UTC (rev 3601)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -33,7 +33,6 @@
import org.lwjgl.MemoryUtil;
import org.lwjgl.util.mapped.MappedHelper;
-import org.lwjgl.util.mapped.MappedObjectUnsafe;
import java.nio.ByteBuffer;
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/AutoSize.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/AutoSize.java 2011-07-24 09:38:46 UTC (rev 3601)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/AutoSize.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -49,6 +49,7 @@
public @interface AutoSize {
String value(); // The name of the Buffer parameter
String expression() default ""; // This value is added after the argument
+ boolean useExpression() default false; // When this is true, the expression result will be used directly.
boolean canBeNull() default false; // When this is true and the Buffer parameter is null, 0 will be used.
boolean isNative() default false; // When this is true, auto-sizing will be performed in native code.
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-24 09:38:46 UTC (rev 3601)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -458,25 +458,27 @@
writer.print(auto_type);
} else if (AutoSize.class.equals(param_type)) {
final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
- final String auto_parameter_name = auto_size_annotation.value();
- final ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
- final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
- final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
- int shifting = 0;
- if ( shift_remaining ) {
- shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
- if ( shifting > 0 )
- writer.print("(");
+ if ( !auto_size_annotation.useExpression() ) {
+ final String auto_parameter_name = auto_size_annotation.value();
+ final ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
+ final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
+ final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
+ int shifting = 0;
+ if ( shift_remaining ) {
+ shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
+ if ( shifting > 0 )
+ writer.print("(");
+ }
+ if ( auto_size_annotation.canBeNull() )
+ writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())");
+ else
+ writer.print(auto_parameter_name + ".remaining()");
+ // Shift the remaining if the target parameter is multityped and there's no AutoType to track type
+ if (shift_remaining && shifting > 0) {
+ writer.print(" << " + shifting);
+ writer.print(")");
+ }
}
- if ( auto_size_annotation.canBeNull() )
- writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())");
- else
- writer.print(auto_parameter_name + ".remaining()");
- // Shift the remaining if the target parameter is multityped and there's no AutoType to track type
- if (shift_remaining && shifting > 0) {
- writer.print(" << " + shifting);
- writer.print(")");
- }
writer.print(auto_size_annotation.expression());
} else
throw new RuntimeException("Unknown auto annotation " + param_type);
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-24 09:38:46 UTC (rev 3601)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -36,6 +36,8 @@
import java.nio.ByteBuffer;
+import static org.lwjgl.util.mapped.MappedObjectUnsafe.*;
+
/**
* [INTERNAL USE ONLY]
* <p/>
@@ -122,7 +124,7 @@
dst.checkRange(bytes);
}
- MappedObjectUnsafe.INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes);
+ INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes);
}
public static ByteBuffer newBuffer(long address, int capacity) {
@@ -134,257 +136,257 @@
// byte
public static void bput(byte value, long addr) {
- MappedObjectUnsafe.INSTANCE.putByte(addr, value);
+ INSTANCE.putByte(addr, value);
}
public static void bput(MappedObject mapped, byte value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putByte(mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putByte(mapped.viewAddress + fieldOffset, value);
}
public static byte bget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getByte(addr);
+ return INSTANCE.getByte(addr);
}
public static byte bget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getByte(mapped.viewAddress + fieldOffset);
+ return INSTANCE.getByte(mapped.viewAddress + fieldOffset);
}
public static void bvput(byte value, long addr) {
- MappedObjectUnsafe.INSTANCE.putByteVolatile(null, addr, value);
+ INSTANCE.putByteVolatile(null, addr, value);
}
public static void bvput(MappedObject mapped, byte value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value);
}
public static byte bvget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, addr);
+ return INSTANCE.getByteVolatile(null, addr);
}
public static byte bvget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset);
+ return INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset);
}
// short
public static void sput(short value, long addr) {
- MappedObjectUnsafe.INSTANCE.putShort(addr, value);
+ INSTANCE.putShort(addr, value);
}
public static void sput(MappedObject mapped, short value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putShort(mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putShort(mapped.viewAddress + fieldOffset, value);
}
public static short sget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getShort(addr);
+ return INSTANCE.getShort(addr);
}
public static short sget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getShort(mapped.viewAddress + fieldOffset);
+ return INSTANCE.getShort(mapped.viewAddress + fieldOffset);
}
public static void svput(short value, long addr) {
- MappedObjectUnsafe.INSTANCE.putShortVolatile(null, addr, value);
+ INSTANCE.putShortVolatile(null, addr, value);
}
public static void svput(MappedObject mapped, short value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value);
}
public static short svget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, addr);
+ return INSTANCE.getShortVolatile(null, addr);
}
public static short svget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset);
+ return INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset);
}
// char
public static void cput(char value, long addr) {
- MappedObjectUnsafe.INSTANCE.putChar(addr, value);
+ INSTANCE.putChar(addr, value);
}
public static void cput(MappedObject mapped, char value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putChar(mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putChar(mapped.viewAddress + fieldOffset, value);
}
public static char cget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getChar(addr);
+ return INSTANCE.getChar(addr);
}
public static char cget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getChar(mapped.viewAddress + fieldOffset);
+ return INSTANCE.getChar(mapped.viewAddress + fieldOffset);
}
public static void cvput(char value, long addr) {
- MappedObjectUnsafe.INSTANCE.putCharVolatile(null, addr, value);
+ INSTANCE.putCharVolatile(null, addr, value);
}
public static void cvput(MappedObject mapped, char value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value);
}
public static char cvget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, addr);
+ return INSTANCE.getCharVolatile(null, addr);
}
public static char cvget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset);
+ return INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset);
}
// int
public static void iput(int value, long addr) {
- MappedObjectUnsafe.INSTANCE.putInt(addr, value);
+ INSTANCE.putInt(addr, value);
}
public static void iput(MappedObject mapped, int value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putInt(mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putInt(mapped.viewAddress + fieldOffset, value);
}
public static int iget(long address) {
- return MappedObjectUnsafe.INSTANCE.getInt(address);
+ return INSTANCE.getInt(address);
}
public static int iget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getInt(mapped.viewAddress + fieldOffset);
+ return INSTANCE.getInt(mapped.viewAddress + fieldOffset);
}
public static void ivput(int value, long addr) {
- MappedObjectUnsafe.INSTANCE.putIntVolatile(null, addr, value);
+ INSTANCE.putIntVolatile(null, addr, value);
}
public static void ivput(MappedObject mapped, int value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value);
}
public static int ivget(long address) {
- return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, address);
+ return INSTANCE.getIntVolatile(null, address);
}
public static int ivget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset);
+ return INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset);
}
// float
public static void fput(float value, long addr) {
- MappedObjectUnsafe.INSTANCE.putFloat(addr, value);
+ INSTANCE.putFloat(addr, value);
}
public static void fput(MappedObject mapped, float value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value);
}
public static float fget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getFloat(addr);
+ return INSTANCE.getFloat(addr);
}
public static float fget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getFloat(mapped.viewAddress + fieldOffset);
+ return INSTANCE.getFloat(mapped.viewAddress + fieldOffset);
}
public static void fvput(float value, long addr) {
- MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, addr, value);
+ INSTANCE.putFloatVolatile(null, addr, value);
}
public static void fvput(MappedObject mapped, float value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value);
}
public static float fvget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, addr);
+ return INSTANCE.getFloatVolatile(null, addr);
}
public static float fvget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset);
+ return INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset);
}
// long
public static void jput(long value, long addr) {
- MappedObjectUnsafe.INSTANCE.putLong(addr, value);
+ INSTANCE.putLong(addr, value);
}
public static void jput(MappedObject mapped, long value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putLong(mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putLong(mapped.viewAddress + fieldOffset, value);
}
public static long jget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getLong(addr);
+ return INSTANCE.getLong(addr);
}
public static long lget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset);
+ return INSTANCE.getLong(mapped.viewAddress + fieldOffset);
}
public static void jvput(long value, long addr) {
- MappedObjectUnsafe.INSTANCE.putLongVolatile(null, addr, value);
+ INSTANCE.putLongVolatile(null, addr, value);
}
public static void jvput(MappedObject mapped, long value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value);
}
public static long jvget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, addr);
+ return INSTANCE.getLongVolatile(null, addr);
}
public static long lvget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset);
+ return INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset);
}
// address
public static void aput(long value, long addr) {
- MappedObjectUnsafe.INSTANCE.putAddress(addr, value);
+ INSTANCE.putAddress(addr, value);
}
public static void aput(MappedObject mapped, long value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value);
}
public static long aget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getAddress(addr);
+ return INSTANCE.getAddress(addr);
}
public static long aget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getAddress(mapped.viewAddress + fieldOffset);
+ return INSTANCE.getAddress(mapped.viewAddress + fieldOffset);
}
// double
public static void dput(double value, long addr) {
- MappedObjectUnsafe.INSTANCE.putDouble(addr, value);
+ INSTANCE.putDouble(addr, value);
}
public static void dput(MappedObject mapped, double value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value);
}
public static double dget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getDouble(addr);
+ return INSTANCE.getDouble(addr);
}
public static double dget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getDouble(mapped.viewAddress + fieldOffset);
+ return INSTANCE.getDouble(mapped.viewAddress + fieldOffset);
}
public static void dvput(double value, long addr) {
- MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, addr, value);
+ INSTANCE.putDoubleVolatile(null, addr, value);
}
public static void dvput(MappedObject mapped, double value, int fieldOffset) {
- MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value);
+ INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value);
}
public static double dvget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, addr);
+ return INSTANCE.getDoubleVolatile(null, addr);
}
public static double dvget(MappedObject mapped, int fieldOffset) {
- return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset);
+ return INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset);
}
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-24 09:38:46 UTC (rev 3601)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -549,10 +549,10 @@
final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>();
/*
- We need this map because we insert/remove instructions from the stream and we need a way
- to match each original instruction with the corresponding frame.
- TODO: Can we keep track of everything more efficiently without a map?
- */
+ We need this map because we insert/remove instructions from the stream and we need a way
+ to match each original instruction with the corresponding frame.
+ TODO: Can we keep track of everything more efficiently without a map?
+ */
final Map<AbstractInsnNode, Frame<BasicValue>> frameMap = new HashMap<AbstractInsnNode, Frame<BasicValue>>();
for ( int i = 0; i < frames.length; i++ )
frameMap.put(instructions.get(i), frames[i]);
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java 2011-07-24 09:38:46 UTC (rev 3601)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -42,9 +42,9 @@
*
* @author Riven
*/
-public class MappedObjectUnsafe {
+final class MappedObjectUnsafe {
- public static final Unsafe INSTANCE = getUnsafeInstance();
+ static final Unsafe INSTANCE = getUnsafeInstance();
private static final long BUFFER_ADDRESS_OFFSET = getObjectFieldOffset(ByteBuffer.class, "address");
private static final long BUFFER_CAPACITY_OFFSET = getObjectFieldOffset(ByteBuffer.class, "capacity");
Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_path_rendering.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_path_rendering.java (rev 0)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_path_rendering.java 2011-07-29 11:30:14 UTC (rev 3602)
@@ -0,0 +1,515 @@
+/*
+ * Copyright (c) 2002-2011 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.util.generator.*;
+import org.lwjgl.util.generator.opengl.*;
+
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+
+public interface NV_path_rendering {
+
+ /**
+ * Accepted in elements of the <commands> array parameter of
+ * PathCommandsNV and PathSubCommandsNV:
+ */
+ int GL_CLOSE_PATH_NV = 0x00,
+ GL_MOVE_TO_NV = 0x02,
+ GL_RELATIVE_MOVE_TO_NV = 0x03,
+ GL_LINE_TO_NV = 0x04,
+ GL_RELATIVE_LINE_TO_NV = 0x05,
+ GL_HORIZONTAL_LINE_TO_NV = 0x06,
+ GL_RELATIVE_HORIZONTAL_LINE_TO_NV = 0x07,
+ GL_VERTICAL_LINE_TO_NV = 0x08,
+ GL_RELATIVE_VERTICAL_LINE_TO_NV = 0x09,
+ GL_QUADRATIC_CURVE_TO_NV = 0x0A,
+ GL_RELATIVE_QUADRATIC_CURVE_TO_NV = 0x0B,
+ GL_CUBIC_CURVE_TO_NV = 0x0C,
+ GL_RELATIVE_CUBIC_CURVE_TO_NV = 0x0D,
+ GL_SMOOTH_QUADRATIC_CURVE_TO_NV = 0x0E,
+ GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV = 0x0F,
+ GL_SMOOTH_CUBIC_CURVE_TO_NV = 0x10,
+ GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV = 0x11,
+ GL_SMALL_CCW_ARC_TO_NV = 0x12,
+ GL_RELATIVE_SMALL_CCW_ARC_TO_NV = 0x13,
+ GL_SMALL_CW_ARC_TO_NV = 0x14,
+ GL_RELATIVE_SMALL_CW_ARC_TO_NV = 0x15,
+ GL_LARGE_CCW_ARC_TO_NV = 0x16,
+ GL_RELATIVE_LARGE_CCW_ARC_TO_NV = 0x17,
+ GL_LARGE_CW_ARC_TO_NV = 0x18,
+ GL_RELATIVE_LARGE_CW_ARC_TO_NV = 0x19,
+ GL_CIRCULAR_CCW_ARC_TO_NV = 0xF8,
+ GL_CIRCULAR_CW_ARC_TO_NV = 0xFA,
+ GL_CIRCULAR_TANGENT_ARC_TO_NV = 0xFC,
+ GL_ARC_TO_NV = 0xFE,
+ GL_RELATIVE_ARC_TO_NV = 0xFF;
+
+ /** Accepted by the <format> parameter of PathStringNV: */
+ int GL_PATH_FORMAT_SVG_NV = 0x9070,
+ GL_PATH_FORMAT_PS_NV = 0x9071;
+
+ /**
+ * Accepted by the <fontTarget> parameter of PathGlyphsNV and
+ * PathGlyphRangeNV:
+ */
+ int GL_STANDARD_FONT_NAME_NV = 0x9072,
+ GL_SYSTEM_FONT_NAME_NV = 0x9073,
+ GL_FILE_NAME_NV = 0x9074;
+
+ /**
+ * Accepted by the <handleMissingGlyph> parameter of PathGlyphsNV and
+ * PathGlyphRangeNV:
+ */
+ int GL_SKIP_MISSING_GLYPH_NV = 0x90A9,
+ GL_USE_MISSING_GLYPH_NV = 0x90AA;
+
+ /**
+ * Accepted by the <pname> parameter of PathParameterfNV,
+ * PathParameterfvNV, GetPathParameterfvNV, PathParameteriNV,
+ * PathParameterivNV, and GetPathParameterivNV:
+ */
+ int GL_PATH_STROKE_WIDTH_NV = 0x9075,
+ GL_PATH_INITIAL_END_CAP_NV = 0x9077,
+ GL_PATH_TERMINAL_END_CAP_NV = 0x9078,
+ GL_PATH_JOIN_STYLE_NV = 0x9079,
+ GL_PATH_MITER_LIMIT_NV = 0x907A,
+ GL_PATH_INITIAL_DASH_CAP_NV = 0x907C,
+ GL_PATH_TERMINAL_DASH_CAP_NV = 0x907D,
+ GL_PATH_DASH_OFFSET_NV = 0x907E,
+ GL_PATH_CLIENT_LENGTH_NV = 0x907F,
+ GL_PATH_DASH_OFFSET_RESET_NV = 0x90B4,
+
+ GL_PATH_FILL_MODE_NV = 0x9080,
+ GL_PATH_FILL_MASK_NV = 0x9081,
+ GL_PATH_FILL_COVER_MODE_NV = 0x9082,
+ GL_PATH_STROKE_COVER_MODE_NV = 0x9083,
+ GL_PATH_STROKE_MASK_NV = 0x9084;
+
+ /**
+ * Accepted by the <pname> parameter of PathParameterfNV and
+ * PathParameterfvNV:
+ */
+ int GL_PATH_END_CAPS_NV = 0x9076,
+ GL_PATH_DASH_CAPS_NV = 0x907B;
+
+ /**
+ * Accepted by the <fillMode> parameter of StencilFillPathNV and
+ * StencilFillPathInstancedNV:
+ */
+ int GL_COUNT_UP_NV = 0x9088,
+ GL_COUNT_DOWN_NV = 0x9089;
+
+ /**
+ * Accepted by the <color> parameter of PathColorGenNV,
+ * GetPathColorGenivNV, and GetPathColorGenfvNV:
+ */
+ int GL_PRIMARY_COLOR = 0x8577, // from OpenGL 1.3
+ GL_PRIMARY_COLOR_NV = 0x852C, // from NV_register_combiners
+ GL_SECONDARY_COLOR_NV = 0x852D; // from NV_register_combiners
+
+ /**
+ * Accepted by the <genMode> parameter of PathColorGenNV and
+ * PathTexGenNV:
+ */
+ int GL_PATH_OBJECT_BOUNDING_BOX_NV = 0x908A;
+
+ /**
+ * Accepted by the <coverMode> parameter of CoverFillPathNV and
+ * CoverFillPathInstancedNV:
+ */
+ int GL_CONVEX_HULL_NV = 0x908B,
+ GL_BOUNDING_BOX_NV = 0x908D;
+
+ /**
+ * Accepted by the <transformType> parameter of
+ * StencilFillPathInstancedNV, StencilStrokePathInstancedNV,
+ * CoverFillPathInstancedNV, and CoverStrokePathInstancedNV:
+ */
+ int GL_TRANSLATE_X_NV = 0x908E,
+ GL_TRANSLATE_Y_NV = 0x908F,
+ GL_TRANSLATE_2D_NV = 0x9090,
+ GL_TRANSLATE_3D_NV = 0x9091,
+ GL_AFFINE_2D_NV = 0x9092,
+ GL_AFFINE_3D_NV = 0x9094,
+ GL_TRANSPOSE_AFFINE_2D_NV = 0x9096,
+ GL_TRANSPOSE_AFFINE_3D_NV = 0x9098;
+
+ /**
+ * Accepted by the <type> or <pathNameType> parameter of CallLists,
+ * StencilFillPathInstancedNV, StencilStrokePathInstancedNV,
+ * CoverFillPathInstancedNV, CoverStrokePathInstancedNV,
+ * GetPathMetricsNV, and GetPathSpacingNV:
+ */
+ int GL_UTF8_NV = 0x909A,
+ GL_UTF16_NV = 0x909B;
+
+ /** Accepted by the <coverMode> parameter of CoverFillPathInstancedNV: */
+ int GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV = 0x909C;
+
+ /**
+ * Accepted by the <pname> parameter of GetPathParameterfvNV and
+ * GetPathParameterivNV:
+ */
+ int GL_PATH_COMMAND_COUNT_NV = 0x909D,
+ GL_PATH_COORD_COUNT_NV = 0x909E,
+ GL_PATH_DASH_ARRAY_COUNT_NV = 0x909F,
+ GL_PATH_COMPUTED_LENGTH_NV = 0x90A0,
+ GL_PATH_FILL_BOUNDING_BOX_NV = 0x90A1,
+ GL_PATH_STROKE_BOUNDING_BOX_NV = 0x90A2;
+
+ /**
+ * Accepted by the <value> parameter of PathParameterfNV,
+ * PathParameterfvNV, PathParameteriNV, and PathParameterivNV
+ * when <pname> is one of PATH_END_CAPS_NV, PATH_INTIAL_END_CAP_NV,
+ * PATH_TERMINAL_END_CAP_NV, PATH_DASH_CAPS_NV, PATH_INITIAL_DASH_CAP_NV,
+ * and PATH_TERMINAL_DASH_CAP_NV:
+ */
+ int GL_SQUARE_NV = 0x90A3,
+ GL_ROUND_NV = 0x90A4,
+ GL_TRIANGULAR_NV = 0x90A5;
+
+ /**
+ * Accepted by the <value> parameter of PathParameterfNV,
+ * PathParameterfvNV, PathParameteriNV, and PathParameterivNV
+ * when <pname> is PATH_JOIN_STYLE_NV:
+ */
+ int GL_BEVEL_NV = 0x90A6,
+ GL_MITER_REVERT_NV = 0x90A7,
+ GL_MITER_TRUNCATE_NV = 0x90A8;
+
+ /**
+ * Accepted by the <value> parameter of PathParameterfNV,
+ * PathParameterfvNV, PathParameteriNV, and PathParameterivNV when
+ * <pname> is PATH_DASH_OFFSET_RESET_NV
+ */
+ int GL_MOVE_TO_RESETS_NV = 0x90B5,
+ GL_MOVE_TO_CONTINUES_NV = 0x90B6;
+
+ /** Accepted by the <fontStyle> parameter of PathStringNV: */
+ int GL_BOLD_BIT_NV = 0x01,
+ GL_ITALIC_BIT_NV = 0x02;
+
+ /**
+ * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
+ * GetInteger64v, GetFloatv, and GetDoublev:
+ */
+ int GL_PATH_ERROR_POSITION_NV = 0x90AB,
+
+ GL_PATH_FOG_GEN_MODE_NV = 0x90AC,
+
+ GL_PATH_STENCIL_FUNC_NV = 0x90B7,
+ GL_PATH_STENCIL_REF_NV = 0x90B8,
+ GL_PATH_STENCIL_VALUE_MASK_NV = 0x90B9,
+
+ GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV = 0x90BD,
+ GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV = 0x90BE,
+
+ GL_PATH_COVER_DEPTH_FUNC_NV = 0x90BF;
+
+ /**
+ * Accepted as a bit within the <metricQueryMask> parameter of
+ * GetPathMetricRangeNV or GetPathMetricsNV:
+ */
+
+ int GL_GLYPH_WIDTH_BIT_NV = 0x01, // per-glyph metrics
+ GL_GLYPH_HEIGHT_BIT_NV = 0x02,
+ GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV = 0x04,
+ GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV = 0x08,
+ GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV = 0x10,
+ GL_GLYPH_VERTICAL_BEARING_X_BIT_NV = 0x20,
+ GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV = 0x40,
+ GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV = 0x80,
+ GL_GLYPH_HAS_KERNING_NV = 0x100,
+ GL_FONT_X_MIN_BOUNDS_NV = 0x00010000, // per-font face metrics
+ GL_FONT_Y_MIN_BOUNDS_NV = 0x00020000,
+ GL_FONT_X_MAX_BOUNDS_NV = 0x00040000,
+ GL_FONT_Y_MAX_BOUNDS_NV = 0x00080000,
+ GL_FONT_UNITS_PER_EM_NV = 0x00100000,
+ GL_FONT_ASCENDER_NV = 0x00200000,
+ GL_FONT_DESCENDER_NV = 0x00400000,
+ GL_FONT_HEIGHT_NV = 0x00800000,
+ GL_FONT_MAX_ADVANCE_WIDTH_NV = 0x01000000,
+ GL_FONT_MAX_ADVANCE_HEIGHT_NV = 0x02000000,
+ GL_FONT_UNDERLINE_POSITION_NV = 0x04000000,
+ GL_FONT_UNDERLINE_THICKNESS_NV = 0x08000000,
+ GL_FONT_HAS_KERNING_NV = 0x10000000;
+
+ /** Accepted by the <pathListMode> parameter of GetPathSpacingNV: */
+ int GL_ACCUM_ADJACENT_PAIRS_NV = 0x90AD,
+ GL_ADJACENT_PAIRS_NV = 0x90AE,
+ GL_FIRST_TO_REST_NV = 0x90AF;
+
+ /**
+ * Accepted by the <pname> parameter of GetPathColorGenivNV,
+ * GetPathColorGenfvNV, GetPathTexGenivNV and GetPathTexGenfvNV:
+ */
+ int GL_PATH_GEN_MODE_NV = 0x90B0,
+ GL_PATH_GEN_COEFF_NV = 0x90B1,
+ GL_PATH_GEN_COLOR_FORMAT_NV = 0x90B2,
+ GL_PATH_GEN_COMPONENTS_NV = 0x90B3;
+
+ void glPathCommandsNV(@GLuint int path,
+ @AutoSize("commands") @GLsizei int numCommands, @Const @GLubyte ByteBuffer commands,
+ @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType,
+ @Const @GLvoid ByteBuffer coords);
+
+ void glPathCoordsNV(@GLuint int path,
+ @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType,
+ @Const @GLvoid ByteBuffer coords);
+
+ void glPathSubCommandsNV(@GLuint int path,
+ @GLsizei int commandStart, @GLsizei int commandsToDelete,
+ @AutoSize("commands") @GLsizei int numCommands, @Const @GLubyte ByteBuffer commands,
+ @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType,
+ @Const @GLvoid ByteBuffer coords);
+
+ void glPathSubCoordsNV(@GLuint int path,
+ @GLsizei int coordStart,
+ @AutoSize("coords") @GLsizei int numCoords, @GLenum int coordType,
+ @Const @GLvoid ByteBuffer coords);
+
+ void glPathStringNV(@GLuint int path, @GLenum int format,
+ @AutoSize("pathString") @GLsizei int length, @Const @GLvoid ByteBuffer pathString);
+
+ void glPathGlyphsNV(@GLuint int firstPathName,
+ @GLenum int fontTarget,
+ @NullTerminated @Const @GLvoid ByteBuffer fontName,
+ @GLbitfield int fontStyle,
+ @AutoSize(value = "charcodes", expression = " / GLChecks.calculateBytesPerCharCode(type)") @GLsizei int numGlyphs, @GLenum int type,
+ @Const @GLvoid ByteBuffer charcodes,
+ @GLenum int handleMissingGlyphs,
+ @GLuint int pathParameterTemplate,
+ float emScale);
+
+ void glPathGlyphRangeNV(@GLuint int firstPathName,
+ @GLenum int fontTarget,
+ @NullTerminated @Const @GLvoid ByteBuffer fontName,
+ @GLbitfield int fontStyle,
+ @GLuint int firstGlyph,
+ @GLsizei int numGlyphs,
+ @GLenum int handleMissingGlyphs,
+ @GLuint int pathParameterTemplate,
+ float emScale);
+
+ void glWeightPathsNV(@GLuint int resultPath,
+ @AutoSize("paths") @GLsizei int numPaths,
+ @Const @GLuint IntBuffer paths, @Check("paths.remaining()") @Const FloatBuffer weights);
+
+ void glCopyPathNV(@GLuint int resultPath, @GLuint int srcPath);
+
+ void glInterpolatePathsNV(@GLuint int resultPath,
+ @GLuint int pathA, @GLuint int pathB,
+ float weight);
+
+ void glTransformPathNV(@GLuint int resultPath,
+ @GLuint int srcPath,
+ @GLenum int transformType,
+ @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
+
+ @StripPostfix("value")
+ void glPathParameterivNV(@GLuint int path, @GLenum int pname, @Check("4") @Const IntBuffer value);
+
+ void glPathParameteriNV(@GLuint int path, @GLenum int pname, int value);
+
+ @StripPostfix("value")
+ void glPathParameterfvNV(@GLuint int path, @GLenum int pname, @Check("4") @Const IntBuffer value);
+
+ void glPathParameterfNV(@GLuint int path, @GLenum int pname, float value);
+
+ void glPathDashArrayNV(@GLuint int path,
+ @AutoSize("dashArray") @GLsizei int dashCount, @Const FloatBuffer dashArray);
+
+ // PATH NAME MANAGEMENT
+
+ @GLuint
+ int glGenPathsNV(@GLsizei int range);
+
+ void glDeletePathsNV(@GLuint int path, @GLsizei int range);
+
+ boolean glIsPathNV(@GLuint int path);
+
+ // PATH STENCILING
+
+ void glPathStencilFuncNV(@GLenum int func, int ref, @GLuint int mask);
+
+ void glPathStencilDepthOffsetNV(float factor, int units);
+
+ void glStencilFillPathNV(@GLuint int path,
+ @GLenum int fillMode, @GLuint int mask);
+
+ void glStencilStrokePathNV(@GLuint int path,
+ int reference, @GLuint int mask);
+
+ void glStencilFillPathInstancedNV(@AutoSize(value="paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
+ @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
+ @Constant("0") @GLuint int pathBase,
+ @GLenum int fillMode, @GLuint int mask,
+ @GLenum int transformType,
+ @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
+
+ void glStencilStrokePathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
+ @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
+ @Constant("0") @GLuint int pathBase,
+ int reference, @GLuint int mask,
+ @GLenum int transformType,
+ @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
+
+ // PATH COVERING
+
+ void glPathCoverDepthFuncNV(@GLenum int zfunc);
+
+ void glPathColorGenNV(@GLenum int color,
+ @GLenum int genMode,
+ @GLenum int colorFormat, @Check(value = "GLChecks.calculatePathColorGenCoeffsCount(genMode, colorFormat)", canBeNull = true) @Const FloatBuffer coeffs);
+
+ void glPathTexGenNV(@GLenum int texCoordSet,
+ @GLenum int genMode,
+ @AutoSize(value="coeffs", expression="GLChecks.calculatePathTextGenCoeffsPerComponent(coeffs, genMode)", useExpression = true, canBeNull = true) int components, @Check(canBeNull = true) @Const FloatBuffer coeffs);
+
+ void glPathFogGenNV(@GLenum int genMode);
+
+ void glCoverFillPathNV(@GLuint int path, @GLenum int coverMode);
+
+ void glCoverStrokePathNV(@GLuint int name, @GLenum int coverMode);
+
+ void glCoverFillPathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
+ @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
+ @Constant("0") @GLuint int pathBase,
+ @GLenum int coverMode,
+ @GLenum int transformType,
+ @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
+
+ void glCoverStrokePathInstancedNV(@AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
+ @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
+ @Constant("0") @GLuint int pathBase,
+ @GLenum int coverMode,
+ @GLenum int transformType,
+ @Check(value = "GLChecks.calculateTransformPathValues(transformType)", canBeNull = true) @Const FloatBuffer transformValues);
+
+ // PATH QUERIES
+
+ @StripPostfix("value")
+ void glGetPathParameterivNV(@GLuint int name, @GLenum int param, @Check("4") @OutParameter IntBuffer value);
+
+ @Alternate("glGetPathParameterivNV")
+ @GLreturn("value")
+ @StripPostfix(value = "value", postfix = "v")
+ void glGetPathParameterivNV2(@GLuint int name, @GLenum int param, @OutParameter IntBuffer value);
+
+ void glGetPathParameterfvNV(@GLuint int name, @GLenum int param, @Check("4") @OutParameter FloatBuffer value);
+
+ @Alternate("glGetPathParameterfvNV")
+ @GLreturn("value")
+ @StripPostfix(value = "value", postfix = "v")
+ void glGetPathParameterfvNV2(@GLuint int name, @GLenum int param, @OutParameter FloatBuffer value);
+
+ void glGetPathCommandsNV(@GLuint int name, @Check @OutParameter @GLubyte ByteBuffer commands);
+
+ void glGetPathCoordsNV(@GLuint int name, @Check @OutParameter FloatBuffer coords);
+
+ void glGetPathDashArrayNV(@GLuint int name, @Check @OutParameter FloatBuffer dashArray);
+
+ void glGetPathMetricsNV(@GLbitfield int metricQueryMask,
+ @AutoSize(value = "paths", expression = " / GLChecks.calculateBytesPerPathName(pathNameType)") @GLsizei int numPaths,
+ @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
+ @Constant("0") @GLuint int pathBase,
+ @GLsizei int stride,
+ @Check("GLChecks.calculateMetricsSize(metricQueryMask, stride)") @OutParameter FloatBuffer metrics);
+
+ void glGetPathMetricRangeNV(@GLbitfield int metricQueryMask,
+ @GLuint int fistPathName,
+ @GLsizei int numPaths,
+ @GLsizei int stride,
+ @Check("GLChecks.calculateMetricsSize(metricQueryMask, stride)") @OutParameter FloatBuffer metrics);
+
+ @Code("\t\tint numPaths = paths.remaining() / GLChecks.calculateBytesPerPathName(pathNameType);")
+ void glGetPathSpacingNV(@GLenum int pathListMode,
+ @AutoSize(value = "paths", expression = "numPaths", useExpression = true) @GLsizei int numPaths,
+ @GLenum int pathNameType, @Const @GLvoid ByteBuffer paths,
+ @Constant("0") @GLuint int pathBase,
+ float advanceScale,
+ float kerningScale,
+ @GLenum int transformType,
+ @Check("numPaths - 1") @OutParameter FloatBuffer returnedSpacing);
+
+ @StripPostfix("value")
+ void glGetPathColorGenivNV(@GLenum int color, @GLenum int pname, @Check("16") @OutParameter IntBuffer value);
+
+ @Alternate("glGetPathColorGenivNV")
+ @GLreturn("value")
+ @StripPostfix(value = "value", postfix = "v")
+ void glGetPathColorGenivNV2(@GLenum int color, @GLenum int pname, @OutParameter IntBuffer value);
+
+ @StripPostfix("value")
+ void glGetPathColorGenfvNV(@GLenum int color, @GLenum int pname, @Check("16") @OutParameter FloatBuffer value);
+
+ @Alternate("glGetPathColorGenfvNV")
+ @GLreturn("value")
+ @StripPostfix(value = "value", postfix = "v")
+ void glGetPathColorGenfvNV2(@GLenum int color, @GLenum int pname, @OutParameter FloatBuffer value);
+
+ @StripPostfix("value")
+ void glGetPathTexGenivNV(@GLenum int texCoordSet, @GLenum int pname, @Check("16") @OutParameter IntBuffer value);
+
+ @Alternate("glGetPathTexGenivNV")
+ @GLreturn("value")
+ @StripPostfix(value = "value", postfix = "v")
+ void glGetPathTexGenivNV2(@GLenum int texCoordSet, @GLenum int pname, @OutParameter IntBuffer value);
+
+ @StripPostfix("value")
+ void glGetPathTexGenfvNV(@GLenum int texCoordSet, @GLenum int pname, @Check("16") @OutParameter FloatBuffer value);
+
+ @Alternate("glGetPathTexGenfvNV")
+ @GLreturn("value")
+ @StripPostfix(value = "value", postfix = "v")
+ void glGetPathTexGenfvNV2(@GLenum int texCoordSet, @GLenum int pname, @OutParameter FloatBuffer value);
+
+ boolean glIsPointInFillPathNV(@GLuint int path,
+ @GLuint int mask, float x, float y);
+
+ boolean glIsPointInStrokePathNV(@GLuint int path,
+ float x, float y);
+
+ float glGetPathLengthNV(@GLuint int path,
+ @GLsizei int startSegment, @GLsizei int numSegments);
+
+ boolean glPointAlongPathNV(@GLuint int path,
+ @GLsizei int startSegment, @GLsizei int numSegments,
+ float distance,
+ @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer x,
+ @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer y,
+ @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer tangentX,
+ @Check(value = "1", canBeNull = true) @OutParameter FloatBuffer tangentY);
+
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-24 09:38:53
|
Revision: 3601
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3601&view=rev
Author: spasi
Date: 2011-07-24 09:38:46 +0000 (Sun, 24 Jul 2011)
Log Message:
-----------
@MappedType is now optional.
copyTo now only copies (SIZEOF - padding) bytes.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -32,10 +32,8 @@
package org.lwjgl.test.mapped;
import org.lwjgl.util.mapped.MappedObject;
-import org.lwjgl.util.mapped.MappedType;
/** @author Riven */
-@MappedType
public class MappedFloat extends MappedObject {
public MappedFloat() {
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -35,7 +35,6 @@
import org.lwjgl.util.mapped.MappedObject;
import org.lwjgl.util.mapped.MappedSet;
import org.lwjgl.util.mapped.MappedSet2;
-import org.lwjgl.util.mapped.MappedType;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -82,7 +81,6 @@
System.out.println("current.view=" + some.view + ", not " + elementCount + ", as you might expect");
}
- @MappedType
public static class Xyz extends MappedObject {
int x, y, z;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -35,7 +35,6 @@
import org.lwjgl.PointerBuffer;
import org.lwjgl.opengl.Display;
import org.lwjgl.util.mapped.MappedObject;
-import org.lwjgl.util.mapped.MappedType;
import org.lwjgl.util.mapped.Pointer;
import java.io.File;
@@ -116,7 +115,6 @@
}
}
- @MappedType
public static class MappedPointer extends MappedObject {
int foo;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -33,12 +33,10 @@
import org.lwjgl.util.mapped.MappedField;
import org.lwjgl.util.mapped.MappedObject;
-import org.lwjgl.util.mapped.MappedType;
import java.nio.ByteBuffer;
/** @author Riven */
-@MappedType
public class MappedSomething extends MappedObject {
@MappedField(byteOffset = 0)
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -32,10 +32,8 @@
package org.lwjgl.test.mapped;
import org.lwjgl.util.mapped.MappedObject;
-import org.lwjgl.util.mapped.MappedType;
/** @author Riven */
-@MappedType
public class MappedVec2 extends MappedObject {
public float x;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -32,10 +32,8 @@
package org.lwjgl.test.mapped;
import org.lwjgl.util.mapped.MappedObject;
-import org.lwjgl.util.mapped.MappedType;
/** @author Riven */
-@MappedType
public class MappedVec3 extends MappedObject {
public float x;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -204,7 +204,6 @@
return texID;
}
- @MappedType
public static class Pixel4b extends MappedObject {
public byte r, g, b, a;
@@ -413,7 +412,6 @@
Display.destroy();
}
- @MappedType
public static class Sprite extends MappedObject {
public float x, dx;
@@ -421,7 +419,6 @@
}
- @MappedType
public static class SpriteRender extends MappedObject {
public float x, y;
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -37,7 +37,7 @@
import java.lang.annotation.Target;
/**
- * This annotation can be used on fields of {@link MappedType} classes,
+ * This annotation can be used on fields of {@link MappedObject} subclasses,
* to manually specify byte offsets and lengths. This is useful when the
* mapped fields require custom alignment. {@link java.nio.ByteBuffer}
* fields are required to have this annotation with a hardcoded byte length.
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -39,8 +39,8 @@
/**
* Base superclass of all mapped objects. Classes that require
- * data mapping should extend this class and also be annotated
- * with {@link MappedType}.
+ * data mapping should extend this class and registered with
+ * {@link MappedObjectTransformer#register(Class)}.
* <p/>
* Subclasses may only specify the default constructor. Any code
* inside that constructor is optional, but will not run when the
@@ -215,7 +215,7 @@
}
/**
- * Copies and amount of <code>SIZEOF</code> bytes, from the current
+ * Copies and amount of <code>SIZEOF - padding</code> bytes, from the current
* mapped object, to the specified mapped object.
*/
@SuppressWarnings("unused")
@@ -225,8 +225,9 @@
}
/**
- * Copies and amount of <code>SIZEOF*instances<c/ode> bytes, from the
- * current mapped object, to the specified mapped object.
+ * Copies and amount of <code>SIZEOF * instances</code> bytes, from the
+ * current mapped object, to the specified mapped object. Note that
+ * this includes any padding bytes that are part of SIZEOF.
*/
@SuppressWarnings("unused")
public final <T extends MappedObject> void copyRange(T target, int instances) {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -113,7 +113,7 @@
// => IADD
// => PUTFIELD MyMappedType.view
//
- className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1));
+ className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1, -1));
}
final String vmName = System.getProperty("java.vm.name");
@@ -128,15 +128,13 @@
*
* @param type the mapped object class.
*/
- public static void register(Class<?> type) {
+ public static void register(Class<? extends MappedObject> type) {
if ( MappedObjectClassLoader.FORKED )
return;
final MappedType mapped = type.getAnnotation(MappedType.class);
- if ( mapped == null )
- throw new ClassFormatError("missing " + MappedType.class.getName() + " annotation");
- if ( mapped.padding() < 0 )
+ if ( mapped != null && mapped.padding() < 0 )
throw new ClassFormatError("Invalid mapped type padding: " + mapped.padding());
if ( type.getEnclosingClass() != null && !Modifier.isStatic(type.getModifiers()) )
@@ -148,7 +146,7 @@
int advancingOffset = 0;
long sizeof = 0;
for ( Field field : type.getDeclaredFields() ) {
- FieldInfo fieldInfo = registerField(mapped, className, advancingOffset, field);
+ FieldInfo fieldInfo = registerField(mapped == null || mapped.autoGenerateOffsets(), className, advancingOffset, field);
if ( fieldInfo == null )
continue;
@@ -158,14 +156,17 @@
sizeof = Math.max(sizeof, fieldInfo.offset + fieldInfo.length);
}
- sizeof += mapped.padding();
+ final int align = mapped == null ? 4 : mapped.align();
+ final int padding = mapped == null ? 0 : mapped.padding();
- final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, mapped.align());
+ sizeof += padding;
+
+ final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, align, padding);
if ( className_to_subtype.put(className, mappedType) != null )
throw new InternalError("duplicate mapped type: " + mappedType.className);
}
- private static FieldInfo registerField(final MappedType mapped, final String className, int advancingOffset, final Field field) {
+ private static FieldInfo registerField(final boolean autoGenerateOffsets, final String className, int advancingOffset, final Field field) {
if ( Modifier.isStatic(field.getModifiers()) ) // static fields are never mapped
return null;
@@ -174,7 +175,7 @@
throw new ClassFormatError("field '" + className + "." + field.getName() + "' not supported: " + field.getType());
MappedField meta = field.getAnnotation(MappedField.class);
- if ( meta == null && !mapped.autoGenerateOffsets() )
+ if ( meta == null && !autoGenerateOffsets )
throw new ClassFormatError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className);
Pointer pointer = field.getAnnotation(Pointer.class);
@@ -688,7 +689,7 @@
final InsnList list = new InsnList();
// stack: target, this
- list.add(getIntNode(mappedType.sizeof));
+ list.add(getIntNode(mappedType.sizeof - mappedType.padding));
// stack: sizeof, target, this
list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "copy", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";I)V"));
// stack: -
@@ -1073,10 +1074,11 @@
final int sizeof;
final int sizeof_shift;
final int align;
+ final int padding;
final Map<String, FieldInfo> fields;
- MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align) {
+ MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align, int padding) {
this.className = className;
this.sizeof = sizeof;
@@ -1085,6 +1087,7 @@
else
this.sizeof_shift = 0;
this.align = align;
+ this.padding = padding;
this.fields = fields;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java 2011-07-23 22:28:57 UTC (rev 3600)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java 2011-07-24 09:38:46 UTC (rev 3601)
@@ -37,7 +37,7 @@
import java.lang.annotation.Target;
/**
- * This annotation can be used on long fields of {@link MappedType} classes,
+ * This annotation can be used on long fields of {@link MappedObject} subclasses,
* to specify that the long value should be interpreted as a pointer. This
* will determine the actual byte size of the field at runtime (4 or 8 bytes).
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-23 22:29:03
|
Revision: 3600
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3600&view=rev
Author: spasi
Date: 2011-07-23 22:28:57 +0000 (Sat, 23 Jul 2011)
Log Message:
-----------
Added support for volatile keyword.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-23 22:02:01 UTC (rev 3599)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-23 22:28:57 UTC (rev 3600)
@@ -149,6 +149,22 @@
return MappedObjectUnsafe.INSTANCE.getByte(mapped.viewAddress + fieldOffset);
}
+ public static void bvput(byte value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putByteVolatile(null, addr, value);
+ }
+
+ public static void bvput(MappedObject mapped, byte value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value);
+ }
+
+ public static byte bvget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, addr);
+ }
+
+ public static byte bvget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset);
+ }
+
// short
public static void sput(short value, long addr) {
@@ -167,6 +183,22 @@
return MappedObjectUnsafe.INSTANCE.getShort(mapped.viewAddress + fieldOffset);
}
+ public static void svput(short value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putShortVolatile(null, addr, value);
+ }
+
+ public static void svput(MappedObject mapped, short value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value);
+ }
+
+ public static short svget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, addr);
+ }
+
+ public static short svget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset);
+ }
+
// char
public static void cput(char value, long addr) {
@@ -185,6 +217,22 @@
return MappedObjectUnsafe.INSTANCE.getChar(mapped.viewAddress + fieldOffset);
}
+ public static void cvput(char value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putCharVolatile(null, addr, value);
+ }
+
+ public static void cvput(MappedObject mapped, char value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value);
+ }
+
+ public static char cvget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, addr);
+ }
+
+ public static char cvget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset);
+ }
+
// int
public static void iput(int value, long addr) {
@@ -203,6 +251,22 @@
return MappedObjectUnsafe.INSTANCE.getInt(mapped.viewAddress + fieldOffset);
}
+ public static void ivput(int value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putIntVolatile(null, addr, value);
+ }
+
+ public static void ivput(MappedObject mapped, int value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value);
+ }
+
+ public static int ivget(long address) {
+ return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, address);
+ }
+
+ public static int ivget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset);
+ }
+
// float
public static void fput(float value, long addr) {
@@ -221,6 +285,22 @@
return MappedObjectUnsafe.INSTANCE.getFloat(mapped.viewAddress + fieldOffset);
}
+ public static void fvput(float value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, addr, value);
+ }
+
+ public static void fvput(MappedObject mapped, float value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value);
+ }
+
+ public static float fvget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, addr);
+ }
+
+ public static float fvget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset);
+ }
+
// long
public static void jput(long value, long addr) {
@@ -239,6 +319,22 @@
return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset);
}
+ public static void jvput(long value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putLongVolatile(null, addr, value);
+ }
+
+ public static void jvput(MappedObject mapped, long value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value);
+ }
+
+ public static long jvget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, addr);
+ }
+
+ public static long lvget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset);
+ }
+
// address
public static void aput(long value, long addr) {
@@ -275,4 +371,20 @@
return MappedObjectUnsafe.INSTANCE.getDouble(mapped.viewAddress + fieldOffset);
}
+ public static void dvput(double value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, addr, value);
+ }
+
+ public static void dvput(MappedObject mapped, double value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value);
+ }
+
+ public static double dvget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, addr);
+ }
+
+ public static double dvget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset);
+ }
+
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-23 22:02:01 UTC (rev 3599)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-23 22:28:57 UTC (rev 3600)
@@ -179,7 +179,11 @@
Pointer pointer = field.getAnnotation(Pointer.class);
if ( pointer != null && field.getType() != long.class )
- throw new ClassFormatError("The @Pointer annotation can only be used on long fields. Field found: " + className + "." + field.getName() + ": " + field.getType());
+ throw new ClassFormatError("The @Pointer annotation can only be used on long fields. @Pointer field found: " + className + "." + field.getName() + ": " + field.getType());
+
+ if ( Modifier.isVolatile(field.getModifiers()) && (pointer != null || field.getType() == ByteBuffer.class) )
+ throw new ClassFormatError("The volatile keyword is not supported for @Pointer or ByteBuffer fields. Volatile field found: " + className + "." + field.getName() + ": " + field.getType());
+
// quick hack
long byteOffset = meta == null ? advancingOffset : meta.byteOffset();
long byteLength;
@@ -209,7 +213,7 @@
if ( PRINT_ACTIVITY )
LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]");
- return new FieldInfo(byteOffset, byteLength, Type.getType(field.getType()), pointer != null);
+ return new FieldInfo(byteOffset, byteLength, Type.getType(field.getType()), Modifier.isVolatile(field.getModifiers()), pointer != null);
}
/** Removes final from methods that will be overriden by subclasses. */
@@ -395,7 +399,7 @@
visitIntNode(mv, (int)field.offset);
mv.visitInsn(I2L);
mv.visitInsn(LADD);
- mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.isPointer ? "a" : field.type.getDescriptor().toLowerCase() + "get", "(J)" + field.type.getDescriptor());
+ mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "get", "(J)" + field.type.getDescriptor());
mv.visitInsn(field.type.getOpcode(IRETURN));
mv.visitMaxs(3, 2);
mv.visitEnd();
@@ -430,7 +434,7 @@
visitIntNode(mv, (int)field.offset);
mv.visitInsn(I2L);
mv.visitInsn(LADD);
- mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.isPointer ? "a" : field.type.getDescriptor().toLowerCase() + "put", "(" + field.type.getDescriptor() + "J)V");
+ mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "put", "(" + field.type.getDescriptor() + "J)V");
mv.visitInsn(RETURN);
mv.visitMaxs(4, 4);
mv.visitEnd();
@@ -933,13 +937,11 @@
private static InsnList generateFieldInstructions(final FieldInsnNode fieldInsn, final FieldInfo field) {
final InsnList list = new InsnList();
- final String dataType = field.isPointer ? "a" : fieldInsn.desc.toLowerCase();
-
if ( fieldInsn.getOpcode() == PUTFIELD ) {
// stack: value, ref
list.add(getIntNode((int)field.offset));
// stack: fieldOffset, value, ref
- list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, dataType + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V"));
+ list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V"));
// stack -
return list;
}
@@ -948,7 +950,7 @@
// stack: ref
list.add(getIntNode((int)field.offset));
// stack: fieldOffset, ref
- list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, dataType + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc));
+ list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, field.getAccessType() + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc));
// stack: -
return list;
}
@@ -1047,15 +1049,21 @@
final long offset;
final long length;
final Type type;
+ final boolean isVolatile;
final boolean isPointer;
- FieldInfo(final long offset, final long length, final Type type, final boolean isPointer) {
+ FieldInfo(final long offset, final long length, final Type type, final boolean isVolatile, final boolean isPointer) {
this.offset = offset;
this.length = length;
this.type = type;
+ this.isVolatile = isVolatile;
this.isPointer = isPointer;
}
+ String getAccessType() {
+ return isPointer ? "a" : type.getDescriptor().toLowerCase() + (isVolatile ? "v" : "");
+ }
+
}
private static class MappedSubtypeInfo {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-23 22:02:08
|
Revision: 3599
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3599&view=rev
Author: spasi
Date: 2011-07-23 22:02:01 +0000 (Sat, 23 Jul 2011)
Log Message:
-----------
Removed sizeof from @MappedType, it's calculated automatically now.
Added padding to @MappedType, defaults to 0.
Added support for @Pointer long fields for easier interaction with pointer data.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java
Modified: trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -462,7 +462,7 @@
*
* @param msg Message to print
*/
- public static void log(String msg) {
+ public static void log(CharSequence msg) {
if (DEBUG) {
System.err.println("[LWJGL] " + msg);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -35,7 +35,7 @@
import org.lwjgl.util.mapped.MappedType;
/** @author Riven */
-@MappedType(sizeof = 4)
+@MappedType
public class MappedFloat extends MappedObject {
public MappedFloat() {
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -82,7 +82,7 @@
System.out.println("current.view=" + some.view + ", not " + elementCount + ", as you might expect");
}
- @MappedType(sizeof = 12)
+ @MappedType
public static class Xyz extends MappedObject {
int x, y, z;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -32,7 +32,11 @@
package org.lwjgl.test.mapped;
import org.lwjgl.MemoryUtil;
+import org.lwjgl.PointerBuffer;
import org.lwjgl.opengl.Display;
+import org.lwjgl.util.mapped.MappedObject;
+import org.lwjgl.util.mapped.MappedType;
+import org.lwjgl.util.mapped.Pointer;
import java.io.File;
import java.nio.ByteBuffer;
@@ -112,4 +116,35 @@
}
}
+ @MappedType
+ public static class MappedPointer extends MappedObject {
+
+ int foo;
+ @Pointer long pointer;
+ int bar;
+
+ }
+
+ public static void testPointer() {
+ MappedPointer data = MappedPointer.malloc(100);
+
+ assert (data.backingByteBuffer().capacity() == 100 * (4 + 4 + PointerBuffer.getPointerSize()));
+
+ for ( int i = 0; i < 100; i++ ) {
+ data.view = i;
+
+ data.foo = i;
+ data.pointer = i * 1000;
+ data.bar = i * 2;
+ }
+
+ for ( int i = 0; i < 100; i++ ) {
+ data.view = i;
+
+ assert (data.foo == i);
+ assert (data.pointer == i * 1000);
+ assert (data.bar == i * 2);
+ }
+ }
+
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -38,7 +38,7 @@
import java.nio.ByteBuffer;
/** @author Riven */
-@MappedType(sizeof = 64)
+@MappedType
public class MappedSomething extends MappedObject {
@MappedField(byteOffset = 0)
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -35,7 +35,7 @@
import org.lwjgl.util.mapped.MappedType;
/** @author Riven */
-@MappedType(sizeof = 8)
+@MappedType
public class MappedVec2 extends MappedObject {
public float x;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -35,7 +35,7 @@
import org.lwjgl.util.mapped.MappedType;
/** @author Riven */
-@MappedType(sizeof = 12)
+@MappedType
public class MappedVec3 extends MappedObject {
public float x;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -51,6 +51,7 @@
MappedObjectTransformer.register(MappedVec3.class);
MappedObjectTransformer.register(MappedSomething.class);
MappedObjectTransformer.register(MappedObjectTests3.Xyz.class);
+ MappedObjectTransformer.register(MappedObjectTests4.MappedPointer.class);
if ( MappedObjectClassLoader.fork(TestMappedObject.class, args) ) {
return;
@@ -72,10 +73,9 @@
MappedObjectTests3.testMappedSet();
MappedObjectTests4.testLocalView();
-
//MappedObjectTests4.testLWJGL();
+ MappedObjectTests4.testPointer();
-
System.out.println("done");
}
Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -204,14 +204,14 @@
return texID;
}
- @MappedType(sizeof = 4)
+ @MappedType
public static class Pixel4b extends MappedObject {
public byte r, g, b, a;
}
- @MappedType(sizeof = 3, align = 3)
+ @MappedType(align = 3)
public static class Pixel3b extends MappedObject {
public byte r, g, b;
@@ -413,15 +413,15 @@
Display.destroy();
}
- @MappedType(sizeof = 4 * 4)
+ @MappedType
public static class Sprite extends MappedObject {
- public float x, y;
- public float dx, dy;
+ public float x, dx;
+ public float y, dy;
}
- @MappedType(sizeof = 2 * 4)
+ @MappedType
public static class SpriteRender extends MappedObject {
public float x, y;
@@ -536,12 +536,15 @@
x += dx * delta;
if ( x < ballRadius ) {
x = ballRadius;
- sprites[b].dx = -dx;
+ dx = -dx;
} else if ( x > boundW ) {
x = boundW;
- sprites[b].dx = -dx;
+ dx = -dx;
}
+
sprites[b].x = x;
+ sprites[b].dx = dx;
+ spritesRender[r].x = x;
float y = sprites[b].y;
float dy = sprites[b].dy;
@@ -549,14 +552,14 @@
y += dy * delta;
if ( y < ballRadius ) {
y = ballRadius;
- sprites[b].dy = -dy;
+ dy = -dy;
} else if ( y > boundH ) {
y = boundH;
- sprites[b].dy = -dy;
+ dy = -dy;
}
+
sprites[b].y = y;
-
- spritesRender[r].x = x;
+ sprites[b].dy = dy;
spritesRender[r].y = y;
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -239,6 +239,24 @@
return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset);
}
+ // address
+
+ public static void aput(long value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putAddress(addr, value);
+ }
+
+ public static void aput(MappedObject mapped, long value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value);
+ }
+
+ public static long aget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getAddress(addr);
+ }
+
+ public static long aget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getAddress(mapped.viewAddress + fieldOffset);
+ }
+
// double
public static void dput(double value, long addr) {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -96,9 +96,6 @@
final String name = MappedObject.class.getName();
String className = name.replace('.', '/');
- if ( MappedObjectTransformer.PRINT_ACTIVITY )
- LWJGLUtil.log(MappedObjectClassLoader.class.getSimpleName() + ": " + className);
-
byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class")));
long t0 = System.nanoTime();
@@ -106,8 +103,8 @@
long t1 = System.nanoTime();
total_time_transforming += (t1 - t0);
- if ( MappedObjectTransformer.PRINT_TIMING )
- LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)");
+ if ( MappedObjectTransformer.PRINT_ACTIVITY )
+ printActivity(className, t0, t1);
Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length);
resolveClass(clazz);
@@ -128,25 +125,29 @@
if ( name.startsWith("sunw.") )
return super.loadClass(name, resolve);
- if ( name.equals(MappedObjectClassLoader.class.getName()) )
+ if ( name.startsWith("org.objectweb.asm.") )
return super.loadClass(name, resolve);
+ if ( name.equals(MappedObjectClassLoader.class.getName()) || name.equals((MappedObjectTransformer.class.getName())) )
+ return super.loadClass(name, resolve);
+
String className = name.replace('.', '/');
- if ( MappedObjectTransformer.PRINT_ACTIVITY )
- LWJGLUtil.log(MappedObjectClassLoader.class.getSimpleName() + ": " + className);
-
byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class")));
// Classes in this package do not get transformed, but need to go through here because we have transformed MappedObject.
if ( !(name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX) && name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1) ) {
long t0 = System.nanoTime();
- bytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode);
+ final byte[] newBytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode);
long t1 = System.nanoTime();
total_time_transforming += (t1 - t0);
- if ( MappedObjectTransformer.PRINT_TIMING )
- LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)");
+
+ if ( bytecode != newBytecode ) {
+ bytecode = newBytecode;
+ if ( MappedObjectTransformer.PRINT_ACTIVITY )
+ printActivity(className, t0, t1);
+ }
}
Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length);
@@ -155,6 +156,15 @@
return clazz;
}
+ private static void printActivity(final String className, final long t0, final long t1) {
+ final StringBuilder msg = new StringBuilder(MappedObjectClassLoader.class.getSimpleName() + ": " + className);
+
+ if ( MappedObjectTransformer.PRINT_TIMING )
+ msg.append("\n\ttransforming took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)");
+
+ LWJGLUtil.log(msg);
+ }
+
private static byte[] readStream(InputStream in) {
byte[] bytecode = new byte[256];
int len = 0;
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -63,8 +63,8 @@
*/
public class MappedObjectTransformer {
- static final boolean PRINT_TIMING = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintTiming");
static final boolean PRINT_ACTIVITY = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintActivity");
+ static final boolean PRINT_TIMING = PRINT_ACTIVITY && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintTiming");
static final boolean PRINT_BYTECODE = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode");
static final Map<String, MappedSubtypeInfo> className_to_subtype;
@@ -113,7 +113,7 @@
// => IADD
// => PUTFIELD MyMappedType.view
//
- className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, -1, -1));
+ className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, null, -1, -1));
}
final String vmName = System.getProperty("java.vm.name");
@@ -129,39 +129,66 @@
* @param type the mapped object class.
*/
public static void register(Class<?> type) {
+ if ( MappedObjectClassLoader.FORKED )
+ return;
+
final MappedType mapped = type.getAnnotation(MappedType.class);
if ( mapped == null )
- throw new InternalError("missing " + MappedType.class.getName() + " annotation");
+ throw new ClassFormatError("missing " + MappedType.class.getName() + " annotation");
+ if ( mapped.padding() < 0 )
+ throw new ClassFormatError("Invalid mapped type padding: " + mapped.padding());
+
if ( type.getEnclosingClass() != null && !Modifier.isStatic(type.getModifiers()) )
throw new InternalError("only top-level or static inner classes are allowed");
- final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(jvmClassName(type), mapped.sizeof(), mapped.align());
+ final String className = jvmClassName(type);
+ final Map<String, FieldInfo> fields = new HashMap<String, FieldInfo>();
int advancingOffset = 0;
- for ( Field field : type.getDeclaredFields() )
- advancingOffset += registerField(mapped, mappedType.className, mappedType, advancingOffset, field);
+ long sizeof = 0;
+ for ( Field field : type.getDeclaredFields() ) {
+ FieldInfo fieldInfo = registerField(mapped, className, advancingOffset, field);
+ if ( fieldInfo == null )
+ continue;
- if ( className_to_subtype.put(mappedType.className, mappedType) != null )
+ fields.put(field.getName(), fieldInfo);
+
+ advancingOffset += fieldInfo.length;
+ sizeof = Math.max(sizeof, fieldInfo.offset + fieldInfo.length);
+ }
+
+ sizeof += mapped.padding();
+
+ final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, fields, (int)sizeof, mapped.align());
+ if ( className_to_subtype.put(className, mappedType) != null )
throw new InternalError("duplicate mapped type: " + mappedType.className);
}
- private static int registerField(final MappedType mapped, final String className, final MappedSubtypeInfo mappedType, int advancingOffset, final Field field) {
+ private static FieldInfo registerField(final MappedType mapped, final String className, int advancingOffset, final Field field) {
if ( Modifier.isStatic(field.getModifiers()) ) // static fields are never mapped
- return 0;
+ return null;
// we only support primitives and ByteBuffers
if ( !field.getType().isPrimitive() && field.getType() != ByteBuffer.class )
- throw new InternalError("field '" + className + "." + field.getName() + "' not supported: " + field.getType());
+ throw new ClassFormatError("field '" + className + "." + field.getName() + "' not supported: " + field.getType());
MappedField meta = field.getAnnotation(MappedField.class);
if ( meta == null && !mapped.autoGenerateOffsets() )
- throw new InternalError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className);
+ throw new ClassFormatError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className);
+ Pointer pointer = field.getAnnotation(Pointer.class);
+ if ( pointer != null && field.getType() != long.class )
+ throw new ClassFormatError("The @Pointer annotation can only be used on long fields. Field found: " + className + "." + field.getName() + ": " + field.getType());
// quick hack
long byteOffset = meta == null ? advancingOffset : meta.byteOffset();
long byteLength;
- if ( field.getType() == long.class || field.getType() == double.class )
+ if ( field.getType() == long.class || field.getType() == double.class ) {
+ if ( pointer == null )
+ byteLength = 8;
+ else
+ byteLength = MappedObjectUnsafe.INSTANCE.addressSize();
+ } else if ( field.getType() == double.class )
byteLength = 8;
else if ( field.getType() == int.class || field.getType() == float.class )
byteLength = 4;
@@ -174,7 +201,7 @@
if ( byteLength < 0 )
throw new IllegalStateException("invalid byte length for mapped ByteBuffer field: " + className + "." + field.getName() + " [length=" + byteLength + "]");
} else
- throw new InternalError(field.getType().getName());
+ throw new ClassFormatError(field.getType().getName());
if ( field.getType() != ByteBuffer.class && (advancingOffset % byteLength) != 0 )
throw new IllegalStateException("misaligned mapped type: " + className + "." + field.getName());
@@ -182,11 +209,7 @@
if ( PRINT_ACTIVITY )
LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]");
- mappedType.fieldToOffset.put(field.getName(), byteOffset);
- mappedType.fieldToLength.put(field.getName(), byteLength);
- mappedType.fieldToType.put(field.getName(), Type.getType(field.getType()));
-
- return (int)byteLength;
+ return new FieldInfo(byteOffset, byteLength, Type.getType(field.getType()), pointer != null);
}
/** Removes final from methods that will be overriden by subclasses. */
@@ -231,13 +254,18 @@
};
- ClassVisitor cv = getTransformationAdapter(className, cw);
+ final TransformationAdapter ta = new TransformationAdapter(cw, className);
+
+ ClassVisitor cv = ta;
if ( className_to_subtype.containsKey(className) ) // Do a first pass to generate address getters
cv = getMethodGenAdapter(className, cv);
new ClassReader(bytecode).accept(cv, ClassReader.SKIP_FRAMES);
+
+ if ( !ta.transformed )
+ return bytecode;
+
bytecode = cw.toByteArray();
-
if ( PRINT_BYTECODE )
printBytecode(bytecode);
@@ -257,14 +285,14 @@
generateSizeofGetter();
generateNext();
- for ( String fieldName : mappedSubtype.fieldToOffset.keySet() ) {
- final Type type = mappedSubtype.fieldToType.get(fieldName);
+ for ( String fieldName : mappedSubtype.fields.keySet() ) {
+ final FieldInfo field = mappedSubtype.fields.get(fieldName);
- if ( type.getDescriptor().length() > 1 ) { // ByteBuffer, getter only
- generateByteBufferGetter(mappedSubtype, fieldName, type);
+ if ( field.type.getDescriptor().length() > 1 ) { // ByteBuffer, getter only
+ generateByteBufferGetter(fieldName, field);
} else {
- generateFieldGetter(mappedSubtype, fieldName, type);
- generateFieldSetter(mappedSubtype, fieldName, type);
+ generateFieldGetter(fieldName, field);
+ generateFieldSetter(fieldName, field);
}
}
@@ -342,42 +370,42 @@
mv.visitEnd();
}
- private void generateByteBufferGetter(final MappedSubtypeInfo mappedSubtype, final String fieldName, final Type type) {
- MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + type.getDescriptor(), null, null);
+ private void generateByteBufferGetter(final String fieldName, final FieldInfo field) {
+ MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + field.type.getDescriptor(), null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
- visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue());
+ visitIntNode(mv, (int)field.offset);
mv.visitInsn(I2L);
mv.visitInsn(LADD);
- visitIntNode(mv, mappedSubtype.fieldToLength.get(fieldName).intValue());
+ visitIntNode(mv, (int)field.length);
mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";");
mv.visitInsn(ARETURN);
- mv.visitMaxs(4, 2);
+ mv.visitMaxs(3, 2);
mv.visitEnd();
}
- private void generateFieldGetter(final MappedSubtypeInfo mappedSubtype, final String fieldName, final Type type) {
- MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + type.getDescriptor(), null, null);
+ private void generateFieldGetter(final String fieldName, final FieldInfo field) {
+ MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + field.type.getDescriptor(), null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
- visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue());
+ visitIntNode(mv, (int)field.offset);
mv.visitInsn(I2L);
mv.visitInsn(LADD);
- mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, type.getDescriptor().toLowerCase() + "get", "(J)" + type.getDescriptor());
- mv.visitInsn(type.getOpcode(IRETURN));
+ mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.isPointer ? "a" : field.type.getDescriptor().toLowerCase() + "get", "(J)" + field.type.getDescriptor());
+ mv.visitInsn(field.type.getOpcode(IRETURN));
mv.visitMaxs(3, 2);
mv.visitEnd();
}
- private void generateFieldSetter(final MappedSubtypeInfo mappedSubtype, final String fieldName, final Type type) {
- MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, setterName(fieldName), "(L" + className + ";I" + type.getDescriptor() + ")V", null, null);
+ private void generateFieldSetter(final String fieldName, final FieldInfo field) {
+ MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, setterName(fieldName), "(L" + className + ";I" + field.type.getDescriptor() + ")V", null, null);
mv.visitCode();
int load = 0;
- switch ( type.getSort() ) {
+ switch ( field.type.getSort() ) {
case Type.BOOLEAN:
case Type.CHAR:
case Type.BYTE:
@@ -399,156 +427,164 @@
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
- visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue());
+ visitIntNode(mv, (int)field.offset);
mv.visitInsn(I2L);
mv.visitInsn(LADD);
- mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, type.getDescriptor().toLowerCase() + "put", "(" + type.getDescriptor() + "J)V");
+ mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, field.isPointer ? "a" : field.type.getDescriptor().toLowerCase() + "put", "(" + field.type.getDescriptor() + "J)V");
mv.visitInsn(RETURN);
- mv.visitMaxs(4, 3);
+ mv.visitMaxs(4, 4);
mv.visitEnd();
}
};
}
- private static ClassAdapter getTransformationAdapter(final String className, final ClassWriter cw) {
- return new ClassAdapter(cw) {
+ private static class TransformationAdapter extends ClassAdapter {
- @Override
- public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
- // remove redirected fields
- final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
- if ( mappedSubtype != null && mappedSubtype.fieldToOffset.containsKey(name) ) {
- if ( PRINT_ACTIVITY )
- LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": discarding field: " + className + "." + name + ":" + desc);
- return null;
- }
+ final String className;
- return super.visitField(access, name, desc, signature, value);
+ boolean transformed;
+
+ TransformationAdapter(final ClassVisitor cv, final String className) {
+ super(cv);
+ this.className = className;
+ }
+
+ @Override
+ public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
+ // remove redirected fields
+ final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
+ if ( mappedSubtype != null && mappedSubtype.fields.containsKey(name) ) {
+ if ( PRINT_ACTIVITY )
+ LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": discarding field: " + className + "." + name + ":" + desc);
+ return null;
}
- @Override
- public MethodVisitor visitMethod(final int access, String name, final String desc, final String signature, final String[] exceptions) {
- // Move MappedSubtype constructors to another method
- if ( "<init>".equals(name) ) {
- final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
- if ( mappedSubtype != null ) {
- if ( !"()V".equals(desc) )
- throw new ClassFormatError(className + " can only have a default constructor, found: " + desc);
+ return super.visitField(access, name, desc, signature, value);
+ }
- final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, MAPPED_OBJECT_JVM, "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
+ @Override
+ public MethodVisitor visitMethod(final int access, String name, final String desc, final String signature, final String[] exceptions) {
+ // Move MappedSubtype constructors to another method
+ if ( "<init>".equals(name) ) {
+ final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
+ if ( mappedSubtype != null ) {
+ if ( !"()V".equals(desc) )
+ throw new ClassFormatError(className + " can only have a default constructor, found: " + desc);
- // put the method body in another method
- name = VIEW_CONSTRUCTOR_NAME;
- }
+ final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, MAPPED_OBJECT_JVM, "<init>", "()V");
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(0, 0);
+
+ // put the method body in another method
+ name = VIEW_CONSTRUCTOR_NAME;
}
+ }
- final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
- return new MethodNode(access, name, desc, signature, exceptions) {
+ final MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
+ return new MethodNode(access, name, desc, signature, exceptions) {
- /** When true, the method has touched a mapped object and needs to be transformed. We track this
- * so we can skip the expensive frame analysis and tree API usage. */
- boolean needsTransformation;
+ /** When true, the method has touched a mapped object and needs to be transformed. We track this
+ * so we can skip the expensive frame analysis and tree API usage. */
+ boolean needsTransformation;
- @Override
- public void visitMaxs(int a, int b) {
- try {
- is_currently_computing_frames = true;
- super.visitMaxs(a, b);
- } finally {
- is_currently_computing_frames = false;
- }
+ @Override
+ public void visitMaxs(int a, int b) {
+ try {
+ is_currently_computing_frames = true;
+ super.visitMaxs(a, b);
+ } finally {
+ is_currently_computing_frames = false;
}
+ }
- @Override
- public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
- if ( className_to_subtype.containsKey(owner) || owner.startsWith(MAPPEDSET_PREFIX) )
- needsTransformation = true;
+ @Override
+ public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
+ if ( className_to_subtype.containsKey(owner) || owner.startsWith(MAPPEDSET_PREFIX) )
+ needsTransformation = true;
- super.visitFieldInsn(opcode, owner, name, desc);
- }
+ super.visitFieldInsn(opcode, owner, name, desc);
+ }
- @Override
- public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {
- if ( className_to_subtype.containsKey(owner) )
- needsTransformation = true;
+ @Override
+ public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {
+ if ( className_to_subtype.containsKey(owner) )
+ needsTransformation = true;
- super.visitMethodInsn(opcode, owner, name, desc);
- }
+ super.visitMethodInsn(opcode, owner, name, desc);
+ }
- @Override
- public void visitEnd() {
- if ( needsTransformation ) { // Early-out for methods that do not touch a mapped object.
- //System.err.println("\nTRANSFORMING: " + className + "." + name + desc);
- try {
- transformMethod(analyse());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ @Override
+ public void visitEnd() {
+ if ( needsTransformation ) { // Early-out for methods that do not touch a mapped object.
+ //System.err.println("\nTRANSFORMING: " + className + "." + name + desc);
+ transformed = true;
+ try {
+ transformMethod(analyse());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
-
- // Pass the instruction stream to the adapter's MethodVisitor
- accept(mv);
}
- private Frame<BasicValue>[] analyse() throws AnalyzerException {
- final Analyzer<BasicValue> a = new Analyzer<BasicValue>(new SimpleVerifier());
- a.analyze(className, this);
- return a.getFrames();
- }
+ // Pass the instruction stream to the adapter's MethodVisitor
+ accept(mv);
+ }
- private void transformMethod(final Frame<BasicValue>[] frames) {
- final InsnList instructions = this.instructions;
+ private Frame<BasicValue>[] analyse() throws AnalyzerException {
+ final Analyzer<BasicValue> a = new Analyzer<BasicValue>(new SimpleVerifier());
+ a.analyze(className, this);
+ return a.getFrames();
+ }
- final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>();
+ private void transformMethod(final Frame<BasicValue>[] frames) {
+ final InsnList instructions = this.instructions;
- /*
- We need this map because we insert/remove instructions from the stream and we need a way
- to match each original instruction with the corresponding frame.
- TODO: Can we keep track of everything more efficiently without a map?
- */
- final Map<AbstractInsnNode, Frame<BasicValue>> frameMap = new HashMap<AbstractInsnNode, Frame<BasicValue>>();
- for ( int i = 0; i < frames.length; i++ )
- frameMap.put(instructions.get(i), frames[i]);
+ final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>();
- for ( int i = 0; i < instructions.size(); i++ ) { // f is a separate cursor for frames
- final AbstractInsnNode instruction = instructions.get(i);
+ /*
+ We need this map because we insert/remove instructions from the stream and we need a way
+ to match each original instruction with the corresponding frame.
+ TODO: Can we keep track of everything more efficiently without a map?
+ */
+ final Map<AbstractInsnNode, Frame<BasicValue>> frameMap = new HashMap<AbstractInsnNode, Frame<BasicValue>>();
+ for ( int i = 0; i < frames.length; i++ )
+ frameMap.put(instructions.get(i), frames[i]);
- //System.out.println("MAIN LOOP #" + i + " - " + getOpcodeName(instruction));
+ for ( int i = 0; i < instructions.size(); i++ ) { // f is a separate cursor for frames
+ final AbstractInsnNode instruction = instructions.get(i);
- switch ( instruction.getType() ) {
- case AbstractInsnNode.VAR_INSN:
- if ( instruction.getOpcode() == ALOAD ) {
- VarInsnNode varInsn = (VarInsnNode)instruction;
- final MappedSubtypeInfo mappedSubtype = arrayVars.get(varInsn.var);
- if ( mappedSubtype != null )
- i = transformArrayAccess(instructions, i, frameMap, varInsn, mappedSubtype, varInsn.var);
- }
- break;
- case AbstractInsnNode.FIELD_INSN:
- FieldInsnNode fieldInsn = (FieldInsnNode)instruction;
+ //System.out.println("MAIN LOOP #" + i + " - " + getOpcodeName(instruction));
- final InsnList list = transformFieldAccess(fieldInsn);
- if ( list != null )
- i = replace(instructions, i, instruction, list);
+ switch ( instruction.getType() ) {
+ case AbstractInsnNode.VAR_INSN:
+ if ( instruction.getOpcode() == ALOAD ) {
+ VarInsnNode varInsn = (VarInsnNode)instruction;
+ final MappedSubtypeInfo mappedSubtype = arrayVars.get(varInsn.var);
+ if ( mappedSubtype != null )
+ i = transformArrayAccess(instructions, i, frameMap, varInsn, mappedSubtype, varInsn.var);
+ }
+ break;
+ case AbstractInsnNode.FIELD_INSN:
+ FieldInsnNode fieldInsn = (FieldInsnNode)instruction;
- break;
- case AbstractInsnNode.METHOD_INSN:
- MethodInsnNode methodInsn = (MethodInsnNode)instruction;
- final MappedSubtypeInfo mappedType = className_to_subtype.get(methodInsn.owner);
- if ( mappedType != null )
- i = transformMethodCall(instructions, i, frameMap, methodInsn, mappedType, arrayVars);
- break;
- }
+ final InsnList list = transformFieldAccess(fieldInsn);
+ if ( list != null )
+ i = replace(instructions, i, instruction, list);
+
+ break;
+ case AbstractInsnNode.METHOD_INSN:
+ MethodInsnNode methodInsn = (MethodInsnNode)instruction;
+ final MappedSubtypeInfo mappedType = className_to_subtype.get(methodInsn.owner);
+ if ( mappedType != null )
+ i = transformMethodCall(instructions, i, frameMap, methodInsn, mappedType, arrayVars);
+ break;
}
}
- };
- }
- };
+ }
+ };
+ }
}
static int transformMethodCall(final InsnList instructions, int i, final Map<AbstractInsnNode, Frame<BasicValue>> frameMap, final MethodInsnNode methodInsn, final MappedSubtypeInfo mappedType, final Map<Integer, MappedSubtypeInfo> arrayVars) {
@@ -760,16 +796,16 @@
return generateAddressInstructions(fieldInsn);
}
- final Long fieldOffset = mappedSubtype.fieldToOffset.get(fieldInsn.name);
- if ( fieldOffset == null ) // early out
+ final FieldInfo field = mappedSubtype.fields.get(fieldInsn.name);
+ if ( field == null ) // early out
return null;
// now we're going to transform ByteBuffer-typed field access
if ( fieldInsn.desc.equals("L" + jvmClassName(ByteBuffer.class) + ";") )
- return generateByteBufferInstructions(fieldInsn, mappedSubtype, fieldOffset);
+ return generateByteBufferInstructions(fieldInsn, mappedSubtype, field.offset);
// we're now going to transform the field access
- return generateFieldInstructions(fieldInsn, fieldOffset);
+ return generateFieldInstructions(fieldInsn, field);
}
private static InsnList generateSetViewInstructions(final FieldInsnNode fieldInsn) {
@@ -867,13 +903,11 @@
throw new InternalError();
}
- private static InsnList generateByteBufferInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype, final Long fieldOffset) {
+ private static InsnList generateByteBufferInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype, final long fieldOffset) {
if ( fieldInsn.getOpcode() == PUTFIELD )
throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
if ( fieldInsn.getOpcode() == GETFIELD ) {
- final Long fieldLength = mappedSubtype.fieldToLength.get(fieldInsn.name);
-
final InsnList list = new InsnList();
// stack: ref
@@ -883,7 +917,7 @@
// stack: long, long
list.add(new InsnNode(LADD));
// stack: long
- list.add(new LdcInsnNode(fieldLength));
+ list.add(new LdcInsnNode(mappedSubtype.fields.get(fieldInsn.name).length));
// stack: long, long
list.add(new InsnNode(L2I));
// stack: int, long
@@ -896,23 +930,25 @@
throw new InternalError();
}
- private static InsnList generateFieldInstructions(final FieldInsnNode fieldInsn, final Long fieldOffset) {
+ private static InsnList generateFieldInstructions(final FieldInsnNode fieldInsn, final FieldInfo field) {
final InsnList list = new InsnList();
+ final String dataType = field.isPointer ? "a" : fieldInsn.desc.toLowerCase();
+
if ( fieldInsn.getOpcode() == PUTFIELD ) {
// stack: value, ref
- list.add(getIntNode(fieldOffset.intValue()));
+ list.add(getIntNode((int)field.offset));
// stack: fieldOffset, value, ref
- list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, fieldInsn.desc.toLowerCase() + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V"));
+ list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, dataType + "put", "(L" + MAPPED_OBJECT_JVM + ";" + fieldInsn.desc + "I)V"));
// stack -
return list;
}
if ( fieldInsn.getOpcode() == GETFIELD ) {
// stack: ref
- list.add(getIntNode(fieldOffset.intValue()));
+ list.add(getIntNode((int)field.offset));
// stack: fieldOffset, ref
- list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, fieldInsn.desc.toLowerCase() + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc));
+ list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, dataType + "get", "(L" + MAPPED_OBJECT_JVM + ";I)" + fieldInsn.desc));
// stack: -
return list;
}
@@ -1006,29 +1042,43 @@
}
}
+ private static class FieldInfo {
+
+ final long offset;
+ final long length;
+ final Type type;
+ final boolean isPointer;
+
+ FieldInfo(final long offset, final long length, final Type type, final boolean isPointer) {
+ this.offset = offset;
+ this.length = length;
+ this.type = type;
+ this.isPointer = isPointer;
+ }
+
+ }
+
private static class MappedSubtypeInfo {
- public final String className;
+ final String className;
- public int sizeof;
- public int sizeof_shift;
- public int align;
+ final int sizeof;
+ final int sizeof_shift;
+ final int align;
- public Map<String, Long> fieldToOffset;
- public Map<String, Long> fieldToLength;
- public Map<String, Type> fieldToType;
+ final Map<String, FieldInfo> fields;
- MappedSubtypeInfo(String className, int sizeof, int align) {
+ MappedSubtypeInfo(String className, Map<String, FieldInfo> fields, int sizeof, int align) {
this.className = className;
this.sizeof = sizeof;
if ( ((sizeof - 1) & sizeof) == 0 )
this.sizeof_shift = getPoT(sizeof);
+ else
+ this.sizeof_shift = 0;
this.align = align;
- this.fieldToOffset = new HashMap<String, Long>();
- this.fieldToLength = new HashMap<String, Long>();
- this.fieldToType = new HashMap<String, Type>();
+ this.fields = fields;
}
private static int getPoT(int value) {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java 2011-07-22 20:09:01 UTC (rev 3598)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -60,11 +60,12 @@
public @interface MappedType {
/**
- * The total size of the mapped object, in bytes.
+ * The number of bytes to add to the total byte size.
+ * SIZEOF will be calculated as <code>SIZEOF = max(field_offset + field_length) + padding</code>
*
- * @return the byte size
+ * @return the padding amount
*/
- int sizeof();
+ int padding() default 0;
/**
* The mapped data memory alignment, in bytes.
Added: trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/Pointer.java 2011-07-23 22:02:01 UTC (rev 3599)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2002-2011 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.mapped;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation can be used on long fields of {@link MappedType} classes,
+ * to specify that the long value should be interpreted as a pointer. This
+ * will determine the actual byte size of the field at runtime (4 or 8 bytes).
+ *
+ * @author Spasi
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Pointer {
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-22 20:09:08
|
Revision: 3598
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3598&view=rev
Author: spasi
Date: 2011-07-22 20:09:01 +0000 (Fri, 22 Jul 2011)
Log Message:
-----------
Converted sizeof and align to methods.
Override more methods in MappedObject subclasses, foreach is now 4 times faster.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -60,8 +60,8 @@
{
MappedFloat vecs1 = MappedFloat.malloc(1234);
- assert (vecs1.sizeof == MappedFloat.SIZEOF);
- assert (vecs1.sizeof * 1234 == vecs1.backingByteBuffer().capacity());
+ assert (vecs1.getSizeof() == MappedFloat.SIZEOF);
+ assert (vecs1.getSizeof() * 1234 == vecs1.backingByteBuffer().capacity());
assert (MappedFloat.SIZEOF * 1234 == vecs1.backingByteBuffer().capacity());
}
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -44,7 +44,7 @@
System.out.println(vecs.viewAddress); // test read-access
- System.out.println(vecs.align); // test read-access
+ System.out.println(vecs.getAlign()); // test read-access
System.out.println(MappedVec3.SIZEOF); // test read-access
}
@@ -91,7 +91,7 @@
vecs.view = 1;
long a2 = vecs.viewAddress;
assert (a2 - a1 == MappedVec3.SIZEOF);
- assert (a2 - a1 == vecs.sizeof);
+ assert (a2 - a1 == vecs.getSizeof());
vecs.view = 0;
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -58,7 +58,7 @@
}
public T next() {
- MappedHelper.put_view(mapped, this.index++, mapped.sizeof);
+ mapped.setViewAddress(mapped.getViewAddress(this.index++));
return mapped;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -55,11 +55,9 @@
if ( LWJGLUtil.CHECKS && align <= 0 )
throw new IllegalArgumentException("invalid alignment");
- mo.align = align;
if ( LWJGLUtil.CHECKS && (sizeof <= 0 || sizeof % align != 0) )
throw new IllegalStateException("sizeof not a multiple of alignment");
- mo.sizeof = sizeof;
long addr = MemoryUtil.getAddress(buffer);
if ( LWJGLUtil.CHECKS && addr % align != 0 )
@@ -107,8 +105,6 @@
public static MappedObject dup(MappedObject src, MappedObject dst) {
dst.baseAddress = src.baseAddress;
dst.viewAddress = src.viewAddress;
- dst.align = src.align;
- dst.sizeof = src.sizeof;
dst.preventGC = src.preventGC;
return dst;
}
@@ -116,8 +112,6 @@
public static MappedObject slice(MappedObject src, MappedObject dst) {
dst.baseAddress = src.viewAddress; // !
dst.viewAddress = src.viewAddress;
- dst.align = src.align;
- dst.sizeof = src.sizeof;
dst.preventGC = src.preventGC;
return dst;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -50,11 +50,11 @@
*
* @author Riven
*/
-public class MappedObject {
+public abstract class MappedObject {
static final boolean CHECKS = LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.Checks");
- public MappedObject() {
+ protected MappedObject() {
//
}
@@ -64,12 +64,9 @@
/** The mapped object view memory address, in bytes. Read-only. */
public long viewAddress;
- /** The mapped object memory alignment, in bytes. Read-only. */
- public int align;
+ /** The mapped buffer. */
+ ByteBuffer preventGC;
- /** The mapped object memory sizeof, in bytes. Read-only. */
- public int sizeof;
-
/**
* Holds the value of sizeof of the sub-type of this MappedObject<br>
* <br>
@@ -87,6 +84,12 @@
*/
public int view;
+ protected final long getViewAddress(final int view) {
+ // No call-site modification for this, we override in every subclass instead,
+ // so that we can use it in MappedForeach.
+ throw new InternalError("type not registered");
+ }
+
public final void setViewAddress(final long address) {
if ( CHECKS )
checkAddress(address);
@@ -96,8 +99,8 @@
final void checkAddress(final long address) {
final long base = MemoryUtil.getAddress0(preventGC);
final int offset = (int)(address - base);
- if ( address < base || preventGC.capacity() < (offset + this.sizeof) )
- throw new IndexOutOfBoundsException(Integer.toString(offset / sizeof));
+ if ( address < base || preventGC.capacity() < (offset + getSizeof()) )
+ throw new IndexOutOfBoundsException(Integer.toString(offset / getSizeof()));
}
final void checkRange(final int bytes) {
@@ -108,7 +111,28 @@
throw new BufferOverflowException();
}
+ /** The mapped object memory alignment, in bytes. Read-only. */
/**
+ * Returns the mapped object memory alignment, in bytes.
+ *
+ * @return the memory alignment
+ */
+ public final int getAlign() {
+ // No call-site modification for this, we override in every subclass instead.
+ throw new InternalError("type not registered");
+ }
+
+ /**
+ * Returns the mapped object memory sizeof, in bytes.
+ *
+ * @return the sizeof value
+ */
+ public final int getSizeof() {
+ // No call-site modification for this, we override in every subclass instead.
+ throw new InternalError("type not registered");
+ }
+
+ /**
* Creates a MappedObject instance, mapping the memory region of the specified direct ByteBuffer.
* <p/>
* The behavior of this (transformed) method does not follow the normal Java behavior.<br>
@@ -178,22 +202,18 @@
* Any code in the default constructor will not run automatically. This method
* can be used to run execute that code on the current view.
*/
- public final <T extends MappedObject> void runViewConstructor() {
+ public final void runViewConstructor() {
// any method that calls this method will have its call-site modified
throw new InternalError("type not registered");
}
/** Moves the current view to the next element. */
public final void next() {
- // any method that calls this method will have its call-site modified
+ // No call-site modification for this, we override in every subclass instead,
+ // so that we can use it in MappedSetX.
throw new InternalError("type not registered");
}
- /** Moves the current view to the next element. Non-transformed implementation for MappedSets. */
- final void nextSet() {
- setViewAddress(viewAddress + sizeof);
- }
-
/**
* Copies and amount of <code>SIZEOF</code> bytes, from the current
* mapped object, to the specified mapped object.
@@ -232,14 +252,12 @@
throw new InternalError("type not registered");
}
- ByteBuffer preventGC;
-
/**
* Returns the {@link java.nio.ByteBuffer} that backs this mapped object.
*
* @return the backing buffer
*/
- public ByteBuffer backingByteBuffer() {
+ public final ByteBuffer backingByteBuffer() {
return this.preventGC;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -73,7 +73,9 @@
FORKED = true;
try {
- URLClassLoader loader = new MappedObjectClassLoader(mainClass);
+ MappedObjectClassLoader loader = new MappedObjectClassLoader(mainClass);
+ loader.loadMappedObject();
+
Class<?> replacedMainClass = loader.loadClass(mainClass.getName());
Method mainMethod = replacedMainClass.getMethod("main", String[].class);
mainMethod.invoke(null, new Object[] { args });
@@ -90,6 +92,28 @@
super(((URLClassLoader)mainClass.getClassLoader()).getURLs());
}
+ protected synchronized Class<?> loadMappedObject() throws ClassNotFoundException {
+ final String name = MappedObject.class.getName();
+ String className = name.replace('.', '/');
+
+ if ( MappedObjectTransformer.PRINT_ACTIVITY )
+ LWJGLUtil.log(MappedObjectClassLoader.class.getSimpleName() + ": " + className);
+
+ byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class")));
+
+ long t0 = System.nanoTime();
+ bytecode = MappedObjectTransformer.transformMappedObject(bytecode);
+ long t1 = System.nanoTime();
+ total_time_transforming += (t1 - t0);
+
+ if ( MappedObjectTransformer.PRINT_TIMING )
+ LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)");
+
+ Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length);
+ resolveClass(clazz);
+ return clazz;
+ }
+
private static long total_time_transforming;
@Override
@@ -104,10 +128,8 @@
if ( name.startsWith("sunw.") )
return super.loadClass(name, resolve);
- // never transform classes in this very package, sub-packages should be transformed
- if ( name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX) )
- if ( name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1 )
- return super.loadClass(name, resolve);
+ if ( name.equals(MappedObjectClassLoader.class.getName()) )
+ return super.loadClass(name, resolve);
String className = name.replace('.', '/');
@@ -116,13 +138,16 @@
byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class")));
- long t0 = System.nanoTime();
- bytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode);
- long t1 = System.nanoTime();
- total_time_transforming += (t1 - t0);
+ // Classes in this package do not get transformed, but need to go through here because we have transformed MappedObject.
+ if ( !(name.startsWith(MAPPEDOBJECT_PACKAGE_PREFIX) && name.substring(MAPPEDOBJECT_PACKAGE_PREFIX.length()).indexOf('.') == -1) ) {
+ long t0 = System.nanoTime();
+ bytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode);
+ long t1 = System.nanoTime();
- if ( MappedObjectTransformer.PRINT_TIMING )
- LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)");
+ total_time_transforming += (t1 - t0);
+ if ( MappedObjectTransformer.PRINT_TIMING )
+ LWJGLUtil.log("transforming " + className + " took " + (t1 - t0) / 1000 + " micros (total: " + (total_time_transforming / 1000 / 1000) + "ms)");
+ }
Class<?> clazz = super.defineClass(name, bytecode, 0, bytecode.length);
if ( resolve )
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -35,6 +35,7 @@
import org.objectweb.asm.*;
import org.objectweb.asm.tree.*;
import org.objectweb.asm.tree.analysis.*;
+import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.util.TraceClassVisitor;
import java.io.PrintWriter;
@@ -76,10 +77,16 @@
static final String MAPPED_SET3_JVM = jvmClassName(MappedSet3.class);
static final String MAPPED_SET4_JVM = jvmClassName(MappedSet4.class);
- static final String LENGTH_METHOD_NAME = "length$LWJGL";
- static final String VIEWADDRESS_METHOD_NAME = "getViewAddress$LWJGL";
- static final String VIEW_CONSTRUCTOR_NAME = "constructView$LWJGL";
+ // Public methods
+ static final String VIEWADDRESS_METHOD_NAME = "getViewAddress";
+ static final String NEXT_METHOD_NAME = "next";
+ static final String ALIGN_METHOD_NAME = "getAlign";
+ static final String SIZEOF_METHOD_NAME = "getSizeof";
+ // Internal methods
+ static final String LENGTH_METHOD_NAME = "length$LWJGL"; // Used for .asArray().length
+ static final String VIEW_CONSTRUCTOR_NAME = "constructView$LWJGL"; // Used by runViewConstructor
+
static final Map<Integer, String> OPCODE_TO_NAME = new HashMap<Integer, String>();
static final Map<Integer, String> INSNTYPE_TO_NAME = new HashMap<Integer, String>();
@@ -122,9 +129,6 @@
* @param type the mapped object class.
*/
public static void register(Class<?> type) {
- if ( MappedObjectClassLoader.FORKED )
- return;
-
final MappedType mapped = type.getAnnotation(MappedType.class);
if ( mapped == null )
throw new InternalError("missing " + MappedType.class.getName() + " annotation");
@@ -185,6 +189,34 @@
return (int)byteLength;
}
+ /** Removes final from methods that will be overriden by subclasses. */
+ static byte[] transformMappedObject(byte[] bytecode) {
+ final ClassWriter cw = new ClassWriter(0);
+
+ ClassVisitor cv = new ClassAdapter(cw) {
+
+ private final String[] DEFINALIZE_LIST = {
+ VIEWADDRESS_METHOD_NAME,
+ NEXT_METHOD_NAME,
+ ALIGN_METHOD_NAME,
+ SIZEOF_METHOD_NAME,
+ };
+
+ public MethodVisitor visitMethod(int access, final String name, final String desc, final String signature, final String[] exceptions) {
+ for ( String method : DEFINALIZE_LIST ) {
+ if ( name.equals(method) ) {
+ access &= ~ACC_FINAL;
+ break;
+ }
+ }
+ return super.visitMethod(access, name, desc, signature, exceptions);
+ }
+ };
+
+ new ClassReader(bytecode).accept(cv, 0);
+ return cw.toByteArray();
+ }
+
static byte[] transformMappedAPI(final String className, byte[] bytecode) {
final ClassWriter cw = new ClassWriter(COMPUTE_FRAMES) {
@@ -203,8 +235,7 @@
if ( className_to_subtype.containsKey(className) ) // Do a first pass to generate address getters
cv = getMethodGenAdapter(className, cv);
- //cr.accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
- new ClassReader(bytecode).accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
+ new ClassReader(bytecode).accept(cv, ClassReader.SKIP_FRAMES);
bytecode = cw.toByteArray();
if ( PRINT_BYTECODE )
@@ -218,11 +249,14 @@
@Override
public void visitEnd() {
+ final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
+
generateViewAddressGetter();
generateLengthGetter();
+ generateAlignGetter(mappedSubtype);
+ generateSizeofGetter();
+ generateNext();
- final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
-
for ( String fieldName : mappedSubtype.fieldToOffset.keySet() ) {
final Type type = mappedSubtype.fieldToType.get(fieldName);
@@ -238,7 +272,7 @@
}
private void generateViewAddressGetter() {
- MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, VIEWADDRESS_METHOD_NAME, "(L" + className + ";I)J", null, null);
+ MethodVisitor mv = super.visitMethod(ACC_PUBLIC, VIEWADDRESS_METHOD_NAME, "(I)J", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, MAPPED_OBJECT_JVM, "baseAddress", "J");
@@ -266,7 +300,7 @@
MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, LENGTH_METHOD_NAME, "(L" + className + ";)I", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKEVIRTUAL, className, "backingByteBuffer", "()L" + jvmClassName(ByteBuffer.class) + ";");
+ mv.visitMethodInsn(INVOKEVIRTUAL, MAPPED_OBJECT_JVM, "backingByteBuffer", "()L" + jvmClassName(ByteBuffer.class) + ";");
mv.visitMethodInsn(INVOKEVIRTUAL, jvmClassName(ByteBuffer.class), "capacity", "()I");
mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I");
mv.visitInsn(IDIV);
@@ -275,12 +309,45 @@
mv.visitEnd();
}
+ private void generateAlignGetter(final MappedSubtypeInfo mappedSubtype) {
+ MethodVisitor mv = super.visitMethod(ACC_PUBLIC, ALIGN_METHOD_NAME, "()I", null, null);
+ mv.visitCode();
+ visitIntNode(mv, mappedSubtype.sizeof);
+ mv.visitInsn(IRETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+
+ private void generateSizeofGetter() {
+ MethodVisitor mv = super.visitMethod(ACC_PUBLIC, SIZEOF_METHOD_NAME, "()I", null, null);
+ mv.visitCode();
+ mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I");
+ mv.visitInsn(IRETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+
+ private void generateNext() {
+ MethodVisitor mv = super.visitMethod(ACC_PUBLIC, NEXT_METHOD_NAME, "()V", null, null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitInsn(DUP);
+ mv.visitFieldInsn(GETFIELD, MAPPED_OBJECT_JVM, "viewAddress", "J");
+ mv.visitFieldInsn(GETSTATIC, className, "SIZEOF", "I");
+ mv.visitInsn(I2L);
+ mv.visitInsn(LADD);
+ mv.visitMethodInsn(INVOKEVIRTUAL, className, "setViewAddress", "(J)V");
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(3, 1);
+ mv.visitEnd();
+ }
+
private void generateByteBufferGetter(final MappedSubtypeInfo mappedSubtype, final String fieldName, final Type type) {
MethodVisitor mv = super.visitMethod(ACC_PUBLIC | ACC_STATIC, getterName(fieldName), "(L" + className + ";I)" + type.getDescriptor(), null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
- mv.visitMethodInsn(INVOKESTATIC, className, VIEWADDRESS_METHOD_NAME, "(L" + className + ";I)J");
+ mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue());
mv.visitInsn(I2L);
mv.visitInsn(LADD);
@@ -296,13 +363,13 @@
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
- mv.visitMethodInsn(INVOKESTATIC, className, VIEWADDRESS_METHOD_NAME, "(L" + className + ";I)J");
+ mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue());
mv.visitInsn(I2L);
mv.visitInsn(LADD);
mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, type.getDescriptor().toLowerCase() + "get", "(J)" + type.getDescriptor());
mv.visitInsn(type.getOpcode(IRETURN));
- mv.visitMaxs(2, 2);
+ mv.visitMaxs(3, 2);
mv.visitEnd();
}
@@ -331,13 +398,13 @@
mv.visitVarInsn(load, 2);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
- mv.visitMethodInsn(INVOKESTATIC, className, VIEWADDRESS_METHOD_NAME, "(L" + className + ";I)J");
+ mv.visitMethodInsn(INVOKEVIRTUAL, className, VIEWADDRESS_METHOD_NAME, "(I)J");
visitIntNode(mv, mappedSubtype.fieldToOffset.get(fieldName).intValue());
mv.visitInsn(I2L);
mv.visitInsn(LADD);
mv.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, type.getDescriptor().toLowerCase() + "put", "(" + type.getDescriptor() + "J)V");
mv.visitInsn(RETURN);
- mv.visitMaxs(3, 3);
+ mv.visitMaxs(4, 3);
mv.visitEnd();
}
@@ -415,12 +482,14 @@
@Override
public void visitEnd() {
- if ( needsTransformation ) // Early-out for methods that do not touch a mapped object.
+ if ( needsTransformation ) { // Early-out for methods that do not touch a mapped object.
+ //System.err.println("\nTRANSFORMING: " + className + "." + name + desc);
try {
transformMethod(analyse());
} catch (Exception e) {
throw new RuntimeException(e);
}
+ }
// Pass the instruction stream to the adapter's MethodVisitor
accept(mv);
@@ -433,8 +502,6 @@
}
private void transformMethod(final Frame<BasicValue>[] frames) {
- //System.err.println("\nTRANSFORMING: " + className + " - " + name + desc);
-
final InsnList instructions = this.instructions;
final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>();
@@ -540,10 +607,6 @@
break;
}
- if ( "next".equals(methodInsn.name) && "()V".equals(methodInsn.desc) ) {
- i = replace(instructions, i, methodInsn, generateNextInstructions(mappedType));
- break;
- }
break;
case INVOKESPECIAL:
// super() in VIEW_CONSTRUCTOR_NAME, remove
@@ -567,18 +630,6 @@
return i;
}
- private static InsnList generateNextInstructions(final MappedSubtypeInfo mappedType) {
- final InsnList list = new InsnList();
-
- // stack: this
- list.add(getIntNode(mappedType.sizeof));
- // stack: sizeof, this
- list.add(new MethodInsnNode(INVOKESTATIC, MAPPED_HELPER_JVM, "put_view_next", "(L" + MAPPED_OBJECT_JVM + ";I)V"));
- // stack: -
-
- return list;
- }
-
private static InsnList generateCopyRangeInstructions(final MappedSubtypeInfo mappedType) {
final InsnList list = new InsnList();
@@ -705,9 +756,6 @@
if ( "view".equals(fieldInsn.name) )
return generateViewInstructions(fieldInsn, mappedSubtype);
- if ( "align".equals(fieldInsn.name) || "sizeof".equals(fieldInsn.name) )
- return generateAlignSizeofInstructions(fieldInsn, mappedSubtype);
-
if ( "baseAddress".equals(fieldInsn.name) || "viewAddress".equals(fieldInsn.name) ) {
return generateAddressInstructions(fieldInsn);
}
@@ -806,29 +854,6 @@
throw new InternalError();
}
- private static InsnList generateAlignSizeofInstructions(final FieldInsnNode fieldInsn, final MappedSubtypeInfo mappedSubtype) {
- if ( !"I".equals(fieldInsn.desc) )
- throw new InternalError();
-
- if ( fieldInsn.getOpcode() == GETFIELD ) {
- final InsnList list = new InsnList();
-
- // stack: instance
- list.add(new InsnNode(POP));
- // stack: -
- if ( "sizeof".equals(fieldInsn.name) )
- list.add(getIntNode(mappedSubtype.sizeof));
- else if ( "align".equals(fieldInsn.name) )
- list.add(getIntNode(mappedSubtype.align));
- // stack: int
- return list;
- }
-
- if ( fieldInsn.getOpcode() == PUTFIELD )
- throwAccessErrorOnReadOnlyField(fieldInsn.owner, fieldInsn.name);
- throw new InternalError();
- }
-
private static InsnList generateAddressInstructions(final FieldInsnNode fieldInsn) {
if ( !"J".equals(fieldInsn.desc) )
throw new IllegalStateException();
@@ -961,7 +986,7 @@
nextInsn = getter;
continue;
} else if ( stackSize < loadStackSize )
- throw new ClassFormatError("Invalid .asArray() usage detected: " + getOpcodeName(nextInsn));
+ throw new ClassFormatError("Invalid " + mappedSubtype.className + " view array usage detected: " + getOpcodeName(nextInsn));
}
instructions.remove(aaLoadInsn);
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -44,13 +44,13 @@
public int view;
void view(int view) {
- MappedHelper.put_view(this.a, view, this.a.sizeof);
- MappedHelper.put_view(this.b, view, this.b.sizeof);
+ a.setViewAddress(a.getViewAddress(view));
+ b.setViewAddress(b.getViewAddress(view));
}
public void next() {
- this.a.nextSet();
- this.b.nextSet();
+ this.a.next();
+ this.b.next();
}
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -45,15 +45,15 @@
public int view;
void view(int view) {
- MappedHelper.put_view(this.a, view, this.a.sizeof);
- MappedHelper.put_view(this.b, view, this.b.sizeof);
- MappedHelper.put_view(this.c, view, this.c.sizeof);
+ a.setViewAddress(a.getViewAddress(view));
+ b.setViewAddress(b.getViewAddress(view));
+ c.setViewAddress(c.getViewAddress(view));
}
public void next() {
- this.a.nextSet();
- this.b.nextSet();
- this.c.nextSet();
+ this.a.next();
+ this.b.next();
+ this.c.next();
}
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java 2011-07-22 02:01:56 UTC (rev 3597)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java 2011-07-22 20:09:01 UTC (rev 3598)
@@ -46,16 +46,16 @@
public int view;
void view(int view) {
- MappedHelper.put_view(this.a, view, this.a.sizeof);
- MappedHelper.put_view(this.b, view, this.b.sizeof);
- MappedHelper.put_view(this.c, view, this.c.sizeof);
- MappedHelper.put_view(this.d, view, this.d.sizeof);
+ a.setViewAddress(a.getViewAddress(view));
+ b.setViewAddress(b.getViewAddress(view));
+ c.setViewAddress(c.getViewAddress(view));
+ d.setViewAddress(d.getViewAddress(view));
}
public void next() {
- this.a.nextSet();
- this.b.nextSet();
- this.c.nextSet();
- this.d.nextSet();
+ this.a.next();
+ this.b.next();
+ this.c.next();
+ this.d.next();
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-22 02:02:05
|
Revision: 3597
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3597&view=rev
Author: spasi
Date: 2011-07-22 02:01:56 +0000 (Fri, 22 Jul 2011)
Log Message:
-----------
Added support for array access to mapped objects.
Added SpriteShootout test that uses mapped objects.
Modified Paths:
--------------
trunk/LWJGL/build.xml
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectUnsafe.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java
Added Paths:
-----------
trunk/LWJGL/libs/asm-debug-all.jar
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java
Removed Paths:
-------------
trunk/LWJGL/libs/asm-util.jar
trunk/LWJGL/libs/asm.jar
Modified: trunk/LWJGL/build.xml
===================================================================
--- trunk/LWJGL/build.xml 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/build.xml 2011-07-22 02:01:56 UTC (rev 3597)
@@ -410,7 +410,7 @@
<!-- Compiles the Java source code -->
<target name="compile" description="Compiles the java source code" depends="-initialize">
- <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar;${lwjgl.lib}/asm.jar;${lwjgl.lib}/asm-util.jar" taskname="core">
+ <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar" taskname="core">
<!--<compilerarg value="-Xlint:unchecked"/>-->
<src path="${lwjgl.src}/java/"/>
<src path="${lwjgl.src}/generated/"/>
Added: trunk/LWJGL/libs/asm-debug-all.jar
===================================================================
(Binary files differ)
Property changes on: trunk/LWJGL/libs/asm-debug-all.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: trunk/LWJGL/libs/asm-util.jar
===================================================================
(Binary files differ)
Deleted: trunk/LWJGL/libs/asm.jar
===================================================================
(Binary files differ)
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -31,6 +31,7 @@
*/
package org.lwjgl.test.mapped;
+import org.lwjgl.MemoryUtil;
import org.lwjgl.util.mapped.MappedObjectUnsafe;
import java.nio.ByteBuffer;
@@ -212,7 +213,7 @@
final int iterations = 64 * 1024;
ByteBuffer bb = ByteBuffer.allocateDirect(200);
- long addr = MappedObjectUnsafe.getBufferBaseAddress(bb);
+ long addr = MemoryUtil.getAddress(bb);
long[] took = new long[runs];
for ( int run = 0; run < runs; run++ ) {
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -31,6 +31,7 @@
*/
package org.lwjgl.test.mapped;
+import org.lwjgl.MemoryUtil;
import org.lwjgl.util.mapped.MappedHelper;
import org.lwjgl.util.mapped.MappedObjectUnsafe;
@@ -143,9 +144,9 @@
// test newBuffer
{
- long addr1 = MappedObjectUnsafe.getBufferBaseAddress(bb);
+ long addr1 = MemoryUtil.getAddress(bb);
ByteBuffer bb2 = MappedHelper.newBuffer(addr1, bb.capacity());
- long addr2 = MappedObjectUnsafe.getBufferBaseAddress(bb);
+ long addr2 = MemoryUtil.getAddress(bb);
System.out.println(bb);
System.out.println(bb2);
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -31,7 +31,11 @@
*/
package org.lwjgl.test.mapped;
-import org.lwjgl.util.mapped.*;
+import org.lwjgl.MemoryUtil;
+import org.lwjgl.util.mapped.MappedObject;
+import org.lwjgl.util.mapped.MappedSet;
+import org.lwjgl.util.mapped.MappedSet2;
+import org.lwjgl.util.mapped.MappedType;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -49,10 +53,10 @@
assert (some.data != some.data);
- long addr1 = MappedObjectUnsafe.getBufferBaseAddress(some.backingByteBuffer());
+ long addr1 = MemoryUtil.getAddress(some.backingByteBuffer());
ByteBuffer mapped = some.data; // creates new ByteBuffer instance
- long addr2 = MappedObjectUnsafe.getBufferBaseAddress(mapped);
+ long addr2 = MemoryUtil.getAddress(mapped);
assert (addr2 - addr1 == 4);
assert (mapped.capacity() == MappedSomething.SIZEOF - 4);
@@ -60,7 +64,7 @@
some.view++;
mapped = some.data; // creates new ByteBuffer instance
- long addr3 = MappedObjectUnsafe.getBufferBaseAddress(mapped);
+ long addr3 = MemoryUtil.getAddress(mapped);
assert (addr3 - addr1 == 4 + MappedSomething.SIZEOF);
assert (addr3 - addr2 == 0 + MappedSomething.SIZEOF);
assert (mapped.capacity() == MappedSomething.SIZEOF - 4);
@@ -87,7 +91,7 @@
static void testConstructor() {
int capacity = 1024;
ByteBuffer bb = ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder());
- long address = MappedObjectUnsafe.getBufferBaseAddress(bb);
+ long address = MemoryUtil.getAddress(bb);
MappedFloat mf = MappedFloat.map(address, capacity);
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests4.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2002-2011 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.mapped;
+
+import org.lwjgl.MemoryUtil;
+import org.lwjgl.opengl.Display;
+
+import java.io.File;
+import java.nio.ByteBuffer;
+
+/** @author Riven */
+@SuppressWarnings("static-access")
+public class MappedObjectTests4 {
+
+ public static void testLWJGL() throws Exception {
+ System.out.println(new File(System.getProperty("java.library.path")).getCanonicalPath());
+ Display.create();
+ }
+
+ public static void testLocalView() {
+ MappedFloat mapped1 = MappedFloat.malloc(5);
+ MappedFloat mapped2 = MappedFloat.malloc(5);
+
+ testLocalView(mapped1);
+ testLocalView(mapped1, mapped2);
+
+ MappedSomething some = MappedSomething.malloc(5);
+ testLocalView(some);
+ }
+
+ private static void testLocalView(MappedFloat mapped1) {
+ final MappedFloat[] array = mapped1.asArray();
+
+ assert (array.length == 5);
+
+ int l = 10 * array.length;
+ for ( int localView1 = 0; localView1 < 5; localView1++ ) {
+ array[localView1].value = localView1 * 5;
+ array[localView1].value *= 2.0f;
+ }
+ System.out.println();
+ float x = 0.0f;
+ for ( int localView1 = 0; localView1 < 5; localView1++ ) {
+ System.out.println("[" + localView1 + "] =>" + array[localView1].value);
+ x += array[localView1].value;
+ }
+ System.out.println("x = " + x);
+ }
+
+ private static void testLocalView(MappedFloat mo1, MappedFloat mo2) {
+ final MappedFloat[] array1 = mo1.<MappedFloat>asArray();
+ for ( int v1 = 0; v1 < 5; v1++ ) {
+ array1[v1].value = (float)Math.random();
+ array1[v1].value *= 2.0f;
+ }
+ final MappedFloat[] array2 = mo2.<MappedFloat>asArray();
+ for ( int v2 = 0; v2 < 5; v2++ ) {
+ array2[v2].value = (float)Math.random();
+ array2[v2].value *= 2.0f;
+ }
+
+ System.out.println();
+
+ for ( int v1 = 0; v1 < 5; v1++ ) {
+ System.out.println("[" + v1 + "] =>" + array1[v1].value);
+ }
+ for ( int v2 = 0; v2 < 5; v2++ ) {
+ System.out.println("[" + v2 + "] =>" + array2[v2].value);
+ }
+ }
+
+ private static void testLocalView(MappedSomething some) {
+ final MappedSomething[] array = some.asArray();
+
+ assert (array.length == 5);
+
+ final long baseAddress = MemoryUtil.getAddress(some.backingByteBuffer());
+ for ( int i = 0; i < array.length; i++ ) {
+ ByteBuffer data = array[i].data;
+
+ assert (data.capacity() == (64 - 4));
+ assert (MemoryUtil.getAddress(data) == baseAddress + i * MappedSomething.SIZEOF + 4);
+ }
+ }
+
+}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -71,6 +71,11 @@
MappedObjectTests3.testConstructor();
MappedObjectTests3.testMappedSet();
+ MappedObjectTests4.testLocalView();
+
+ //MappedObjectTests4.testLWJGL();
+
+
System.out.println("done");
}
Added: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutMapped.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -0,0 +1,831 @@
+/*
+ * Copyright (c) 2002-2011 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.sprites;
+
+import org.lwjgl.BufferUtils;
+import org.lwjgl.LWJGLException;
+import org.lwjgl.Sys;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.*;
+import org.lwjgl.util.mapped.MappedObject;
+import org.lwjgl.util.mapped.MappedObjectClassLoader;
+import org.lwjgl.util.mapped.MappedObjectTransformer;
+import org.lwjgl.util.mapped.MappedType;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Random;
+import javax.imageio.ImageIO;
+
+import static org.lwjgl.opengl.EXTTransformFeedback.*;
+import static org.lwjgl.opengl.GL11.*;
+import static org.lwjgl.opengl.GL12.*;
+import static org.lwjgl.opengl.GL15.*;
+import static org.lwjgl.opengl.GL20.*;
+import static org.lwjgl.opengl.GL30.*;
+
+/**
+ * Sprite rendering demo. Three implementations are supported:
+ * a) CPU animation + BufferData VBO update.
+ * b) CPU animation + MapBufferRange VBO update.
+ * c) GPU animation using transform feedback with a vertex shader.
+ *
+ * @author Spasi
+ * @since 18/3/2011
+ */
+public final class SpriteShootoutMapped {
+
+ static final int SCREEN_WIDTH = 800;
+ static final int SCREEN_HEIGHT = 600;
+
+ private static final int ANIMATION_TICKS = 60;
+
+ private boolean run = true;
+ private boolean render = true;
+ private boolean colorMask = true;
+ private boolean animate = true;
+ private boolean smooth;
+ private boolean vsync;
+
+ int ballSize = 42;
+ int ballCount = 100 * 1000;
+
+ private SpriteRenderer renderer;
+
+ // OpenGL stuff
+ private int texID;
+ private int texBigID;
+ private int texSmallID;
+
+ private SpriteShootoutMapped() {
+ }
+
+ public static void main(String[] args) {
+ MappedObjectTransformer.register(Pixel4b.class);
+ MappedObjectTransformer.register(Pixel3b.class);
+ MappedObjectTransformer.register(Sprite.class);
+ MappedObjectTransformer.register(SpriteRender.class);
+
+ if ( MappedObjectClassLoader.fork(SpriteShootoutMapped.class, args) )
+ return;
+
+ try {
+ new SpriteShootoutMapped().start();
+ } catch (LWJGLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void start() throws LWJGLException {
+ try {
+ initGL();
+
+ final ContextCapabilities caps = GLContext.getCapabilities();
+ if ( !true && (caps.OpenGL30 || caps.GL_EXT_transform_feedback) )
+ renderer = new SpriteRendererTF();
+ else if ( true && caps.GL_ARB_map_buffer_range )
+ renderer = new SpriteRendererMapped();
+ else
+ renderer = new SpriteRendererPlain();
+
+ updateBalls(ballCount);
+ run();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ } finally {
+ destroy();
+ }
+ }
+
+ private void initGL() throws LWJGLException {
+ Display.setLocation((Display.getDisplayMode().getWidth() - SCREEN_WIDTH) / 2,
+ (Display.getDisplayMode().getHeight() - SCREEN_HEIGHT) / 2);
+ Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT));
+ Display.setTitle("Sprite Shootout");
+ Display.create();
+ //Display.create(new PixelFormat(), new ContextAttribs(4, 1).withProfileCompatibility(true).withDebug(true));
+ //AMDDebugOutput.glDebugMessageCallbackAMD(new AMDDebugOutputCallback());
+
+ if ( !GLContext.getCapabilities().OpenGL20 )
+ throw new RuntimeException("OpenGL 2.0 is required for this demo.");
+
+ // Setup viewport
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1.0, 1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+
+ glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
+
+ // Create textures
+
+ try {
+ texSmallID = createTexture("res/ball_sm.png");
+ texBigID = createTexture("res/ball.png");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+ texID = texBigID;
+
+ // Setup rendering state
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.0f);
+
+ glColorMask(colorMask, colorMask, colorMask, false);
+ glDepthMask(false);
+ glDisable(GL_DEPTH_TEST);
+
+ // Setup geometry
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ Util.checkGLError();
+ }
+
+ private static int createTexture(final String path) throws IOException {
+ final BufferedImage img = ImageIO.read(SpriteShootoutMapped.class.getClassLoader().getResource(path));
+
+ final int w = img.getWidth();
+ final int h = img.getHeight();
+
+ final ByteBuffer buffer = readImage(img);
+
+ final int texID = glGenTextures();
+
+ glBindTexture(GL_TEXTURE_2D, texID);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
+
+ return texID;
+ }
+
+ @MappedType(sizeof = 4)
+ public static class Pixel4b extends MappedObject {
+
+ public byte r, g, b, a;
+
+ }
+
+ @MappedType(sizeof = 3, align = 3)
+ public static class Pixel3b extends MappedObject {
+
+ public byte r, g, b;
+
+ }
+
+ private static ByteBuffer readImage(final BufferedImage img) throws IOException {
+ final Raster raster = img.getRaster();
+
+ final int bands = raster.getNumBands();
+
+ final int w = img.getWidth();
+ final int h = img.getHeight();
+
+ final int count = w * h;
+
+ final byte[] pixels = new byte[count * bands];
+ raster.getDataElements(0, 0, w, h, pixels);
+
+ if ( bands == 4 ) {
+ Pixel4b p = Pixel4b.malloc(count);
+
+ int b = 0;
+ for ( int i = 0; i < count; i++, b += 4 ) {
+ // Pre-multiply alpha
+ final float a = unpackUByte01(pixels[b + 3]);
+
+ p.view = i;
+ p.r = packUByte01(unpackUByte01(pixels[b + 2]) * a);
+ p.g = packUByte01(unpackUByte01(pixels[b + 1]) * a);
+ p.b = packUByte01(unpackUByte01(pixels[b + 0]) * a);
+ p.a = pixels[b + 3];
+ }
+
+ return p.backingByteBuffer();
+ } else if ( bands == 3 ) {
+ Pixel3b p = Pixel3b.malloc(count);
+
+ int b = 0;
+ for ( int i = 0; i < count; i++, b += 3 ) {
+ p.view = i;
+ p.r = pixels[b + 2];
+ p.g = pixels[b + 1];
+ p.b = pixels[b + 0];
+ }
+
+ return p.backingByteBuffer();
+ } else {
+ ByteBuffer p = BufferUtils.createByteBuffer(count * bands);
+ p.put(pixels, 0, p.capacity());
+ p.flip();
+ return p;
+ }
+
+ }
+
+ private static float unpackUByte01(final byte x) {
+ return (x & 0xFF) / 255.0f;
+ }
+
+ private static byte packUByte01(final float x) {
+ return (byte)(x * 255.0f);
+ }
+
+ private void updateBalls(final int count) {
+ System.out.println("NUMBER OF BALLS: " + count);
+ renderer.updateBalls(ballCount);
+ }
+
+ private void run() {
+ long startTime = System.currentTimeMillis() + 5000;
+ long fps = 0;
+
+ long time = Sys.getTime();
+ final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);
+
+ renderer.render(false, true, 0);
+
+ while ( run ) {
+ Display.processMessages();
+ handleInput();
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ final long currTime = Sys.getTime();
+ final int delta = (int)(currTime - time);
+ if ( smooth || delta >= ticksPerUpdate ) {
+ renderer.render(render, animate, delta);
+ time = currTime;
+ } else
+ renderer.render(render, false, 0);
+
+ Display.update(false);
+ //Display.sync(60);
+
+ if ( startTime > System.currentTimeMillis() ) {
+ fps++;
+ } else {
+ long timeUsed = 5000 + (startTime - System.currentTimeMillis());
+ startTime = System.currentTimeMillis() + 5000;
+ System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
+ fps = 0;
+ }
+ }
+ }
+
+ private void handleInput() {
+ if ( Display.isCloseRequested() )
+ run = false;
+
+ while ( Keyboard.next() ) {
+ if ( Keyboard.getEventKeyState() )
+ continue;
+
+ switch ( Keyboard.getEventKey() ) {
+ case Keyboard.KEY_1:
+ case Keyboard.KEY_2:
+ case Keyboard.KEY_3:
+ case Keyboard.KEY_4:
+ case Keyboard.KEY_5:
+ case Keyboard.KEY_6:
+ case Keyboard.KEY_7:
+ case Keyboard.KEY_8:
+ case Keyboard.KEY_9:
+ case Keyboard.KEY_0:
+ ballCount = 1 << (Keyboard.getEventKey() - Keyboard.KEY_1);
+ updateBalls(ballCount);
+ break;
+ case Keyboard.KEY_ADD:
+ case Keyboard.KEY_SUBTRACT:
+ int mult;
+ if ( Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) )
+ mult = 1000;
+ else if ( Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU) )
+ mult = 100;
+ else if ( Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) )
+ mult = 10;
+ else
+ mult = 1;
+ if ( Keyboard.getEventKey() == Keyboard.KEY_SUBTRACT )
+ mult = -mult;
+ ballCount += mult * 100;
+ if ( ballCount <= 0 )
+ ballCount = 1;
+ updateBalls(ballCount);
+ break;
+ case Keyboard.KEY_ESCAPE:
+ run = false;
+ break;
+ case Keyboard.KEY_A:
+ animate = !animate;
+ System.out.println("Animation is now " + (animate ? "on" : "off") + ".");
+ break;
+ case Keyboard.KEY_C:
+ colorMask = !colorMask;
+ glColorMask(colorMask, colorMask, colorMask, false);
+ System.out.println("Color mask is now " + (colorMask ? "on" : "off") + ".");
+ // Disable alpha test when color mask is off, else we get no benefit.
+ if ( colorMask ) {
+ glEnable(GL_BLEND);
+ glEnable(GL_ALPHA_TEST);
+ } else {
+ glDisable(GL_BLEND);
+ glDisable(GL_ALPHA_TEST);
+ }
+ break;
+ case Keyboard.KEY_R:
+ render = !render;
+ System.out.println("Rendering is now " + (render ? "on" : "off") + ".");
+ break;
+ case Keyboard.KEY_S:
+ smooth = !smooth;
+ System.out.println("Smooth animation is now " + (smooth ? "on" : "off") + ".");
+ break;
+ case Keyboard.KEY_T:
+ if ( texID == texBigID ) {
+ texID = texSmallID;
+ ballSize = 16;
+ } else {
+ texID = texBigID;
+ ballSize = 42;
+ }
+ renderer.updateBallSize();
+ glBindTexture(GL_TEXTURE_2D, texID);
+ System.out.println("Now using the " + (texID == texBigID ? "big" : "small") + " texture.");
+ break;
+ case Keyboard.KEY_V:
+ vsync = !vsync;
+ Display.setVSyncEnabled(vsync);
+ System.out.println("VSYNC is now " + (vsync ? "enabled" : "disabled") + ".");
+ break;
+ }
+ }
+
+ while ( Mouse.next() ) ;
+ }
+
+ private void destroy() {
+ Display.destroy();
+ }
+
+ @MappedType(sizeof = 4 * 4)
+ public static class Sprite extends MappedObject {
+
+ public float x, y;
+ public float dx, dy;
+
+ }
+
+ @MappedType(sizeof = 2 * 4)
+ public static class SpriteRender extends MappedObject {
+
+ public float x, y;
+
+ }
+
+ private abstract class SpriteRenderer {
+
+ protected Sprite sprites;
+
+ protected int spriteCount;
+
+ protected int vshID;
+ protected int progID;
+
+ protected void createProgram() {
+ final int fshID = glCreateShader(GL_FRAGMENT_SHADER);
+ glShaderSource(fshID, "uniform sampler2D COLOR_MAP;\n" +
+ "void main(void) {\n" +
+ " gl_FragColor = texture2D(COLOR_MAP, gl_PointCoord);\n" +
+ "}");
+ glCompileShader(fshID);
+ if ( glGetShader(fshID, GL_COMPILE_STATUS) == GL_FALSE ) {
+ System.out.println(glGetShaderInfoLog(fshID, glGetShader(fshID, GL_INFO_LOG_LENGTH)));
+ throw new RuntimeException("Failed to compile fragment shader.");
+ }
+
+ progID = glCreateProgram();
+ glAttachShader(progID, vshID);
+ glAttachShader(progID, fshID);
+ glLinkProgram(progID);
+ if ( glGetProgram(progID, GL_LINK_STATUS) == GL_FALSE ) {
+ System.out.println(glGetProgramInfoLog(progID, glGetProgram(progID, GL_INFO_LOG_LENGTH)));
+ throw new RuntimeException("Failed to link shader program.");
+ }
+
+ glUseProgram(progID);
+ glUniform1i(glGetUniformLocation(progID, "COLOR_MAP"), 0);
+
+ updateBallSize();
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ }
+
+ public void updateBallSize() {
+ glPointSize(ballSize);
+ }
+
+ public abstract void updateBalls(int count);
+
+ protected abstract void render(boolean render, boolean animate, int delta);
+
+ }
+
+ private abstract class SpriteRendererBatched extends SpriteRenderer {
+
+ protected static final int BALLS_PER_BATCH = 10 * 1000;
+
+ SpriteRendererBatched() {
+ vshID = glCreateShader(GL_VERTEX_SHADER);
+ glShaderSource(vshID, "void main(void) {\n" +
+ " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +
+ "}");
+ glCompileShader(vshID);
+ if ( glGetShader(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
+ System.out.println(glGetShaderInfoLog(vshID, glGetShader(vshID, GL_INFO_LOG_LENGTH)));
+ throw new RuntimeException("Failed to compile vertex shader.");
+ }
+
+ createProgram();
+ }
+
+ public void updateBalls(final int count) {
+ final Random random = new Random();
+
+ final Sprite newSprites = Sprite.malloc(count);
+ if ( sprites != null ) {
+ sprites.view = 0;
+ sprites.copyRange(newSprites, Math.min(count, spriteCount));
+ }
+
+ if ( count > spriteCount ) {
+ for ( int i = spriteCount; i < count; i++ ) {
+ newSprites.view = i;
+
+ newSprites.x = (int)(random.nextFloat() * (SCREEN_WIDTH - ballSize) + ballSize * 0.5f);
+ newSprites.y = (int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize) + ballSize * 0.5f);
+ newSprites.dx = random.nextFloat() * 0.4f - 0.2f;
+ newSprites.dy = random.nextFloat() * 0.4f - 0.2f;
+ }
+ }
+
+ sprites = newSprites;
+ spriteCount = count;
+ }
+
+ protected void animate(
+ final Sprite sprite,
+ final SpriteRender spriteRender,
+ final int ballSize, final int ballIndex, final int batchSize, final int delta
+ ) {
+ final float ballRadius = ballSize * 0.5f;
+ final float boundW = SCREEN_WIDTH - ballRadius;
+ final float boundH = SCREEN_HEIGHT - ballRadius;
+
+ final Sprite[] sprites = sprite.asArray();
+ final SpriteRender[] spritesRender = spriteRender.asArray();
+ for ( int b = ballIndex, r = 0, len = (ballIndex + batchSize); b < len; b++, r++ ) {
+ float x = sprites[b].x;
+ float dx = sprites[b].dx;
+
+ x += dx * delta;
+ if ( x < ballRadius ) {
+ x = ballRadius;
+ sprites[b].dx = -dx;
+ } else if ( x > boundW ) {
+ x = boundW;
+ sprites[b].dx = -dx;
+ }
+ sprites[b].x = x;
+
+ float y = sprites[b].y;
+ float dy = sprites[b].dy;
+
+ y += dy * delta;
+ if ( y < ballRadius ) {
+ y = ballRadius;
+ sprites[b].dy = -dy;
+ } else if ( y > boundH ) {
+ y = boundH;
+ sprites[b].dy = -dy;
+ }
+ sprites[b].y = y;
+
+ spritesRender[r].x = x;
+ spritesRender[r].y = y;
+ }
+ }
+
+ }
+
+ private class SpriteRendererPlain extends SpriteRendererBatched {
+
+ private final int DATA_PER_BATCH = BALLS_PER_BATCH * 2 * 4; // balls * 2 floats * 4 bytes
+
+ protected int[] animVBO;
+
+ private SpriteRender spritesRender;
+
+ SpriteRendererPlain() {
+ System.out.println("Shootout Implementation: CPU animation & BufferData");
+ spritesRender = SpriteRender.malloc(BALLS_PER_BATCH);
+ }
+
+ public void updateBalls(final int count) {
+ super.updateBalls(count);
+
+ final int batchCount = count / BALLS_PER_BATCH + (count % BALLS_PER_BATCH == 0 ? 0 : 1);
+ if ( animVBO != null && batchCount == animVBO.length )
+ return;
+
+ final int[] newAnimVBO = new int[batchCount];
+ if ( animVBO != null ) {
+ System.arraycopy(animVBO, 0, newAnimVBO, 0, Math.min(animVBO.length, newAnimVBO.length));
+ for ( int i = newAnimVBO.length; i < animVBO.length; i++ )
+ glDeleteBuffers(animVBO[i]);
+ }
+ for ( int i = animVBO == null ? 0 : animVBO.length; i < newAnimVBO.length; i++ ) {
+ newAnimVBO[i] = glGenBuffers();
+ glBindBuffer(GL_ARRAY_BUFFER, newAnimVBO[i]);
+ }
+
+ animVBO = newAnimVBO;
+ }
+
+ public void render(final boolean render, final boolean animate, final int delta) {
+ int batchSize = Math.min(ballCount, BALLS_PER_BATCH);
+ int ballIndex = 0;
+ int batchIndex = 0;
+ while ( ballIndex < ballCount ) {
+ glBindBuffer(GL_ARRAY_BUFFER, animVBO[batchIndex]);
+
+ if ( animate )
+ animate(ballIndex, batchSize, delta);
+
+ if ( render ) {
+ glVertexPointer(2, GL_FLOAT, 0, 0);
+ glDrawArrays(GL_POINTS, 0, batchSize);
+ }
+
+ ballIndex += batchSize;
+ batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH);
+ batchIndex++;
+ }
+ }
+
+ private void animate(final int ballIndex, final int batchSize, final int delta) {
+ animate(
+ sprites, spritesRender,
+ ballSize, ballIndex, batchSize, delta
+ );
+
+ glBufferData(GL_ARRAY_BUFFER, DATA_PER_BATCH, GL_STREAM_DRAW);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, spritesRender.backingByteBuffer());
+ }
+
+ }
+
+ private class SpriteRendererMapped extends SpriteRendererBatched {
+
+ private StreamVBO animVBO;
+
+ SpriteRendererMapped() {
+ System.out.println("Shootout Implementation: CPU animation & MapBufferRange");
+ }
+
+ public void updateBalls(final int count) {
+ super.updateBalls(count);
+
+ if ( animVBO != null )
+ animVBO.destroy();
+
+ animVBO = new StreamVBO(GL_ARRAY_BUFFER, ballCount * (2 * 4));
+ }
+
+ public void render(final boolean render, final boolean animate, final int delta) {
+ int batchSize = Math.min(ballCount, BALLS_PER_BATCH);
+ int ballIndex = 0;
+ while ( ballIndex < ballCount ) {
+ if ( animate ) {
+ final ByteBuffer buffer = animVBO.map(batchSize * (2 * 4));
+
+ animate(sprites, SpriteRender.<SpriteRender>map(buffer), ballSize, ballIndex, batchSize, delta);
+
+ animVBO.unmap();
+ }
+
+ if ( render ) {
+ glVertexPointer(2, GL_FLOAT, 0, ballIndex * (2 * 4));
+ glDrawArrays(GL_POINTS, 0, batchSize);
+ }
+
+ ballIndex += batchSize;
+ batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH);
+ }
+ }
+
+ }
+
+ private class SpriteRendererTF extends SpriteRenderer {
+
+ private int progIDTF;
+ private int ballSizeLoc;
+ private int deltaLoc;
+
+ private int[] tfVBO = new int[2];
+ private int currVBO;
+
+ SpriteRendererTF() {
+ System.out.println("Shootout Implementation: TF GPU animation");
+
+ // Transform-feedback program
+
+ final int vshID = glCreateShader(GL_VERTEX_SHADER);
+ glShaderSource(vshID, "#version 130\n" +
+ "const float WIDTH = " + SCREEN_WIDTH + ";\n" +
+ "const float HEIGHT = " + SCREEN_HEIGHT + ";\n" +
+ "uniform float ballSize;\n" + // ballSize / 2
+ "uniform float delta;\n" +
+ "void main(void) {\n" +
+ " vec4 anim = gl_Vertex;\n" +
+ " anim.xy = anim.xy + anim.zw * delta;\n" +
+ " vec2 animC = clamp(anim.xy, vec2(ballSize), vec2(WIDTH - ballSize, HEIGHT - ballSize));\n" +
+ " if ( anim.x != animC.x ) anim.z = -anim.z;\n" +
+ " if ( anim.y != animC.y ) anim.w = -anim.w;\n" +
+ " gl_Position = vec4(animC, anim.zw);\n" +
+ "}");
+ glCompileShader(vshID);
+ if ( glGetShader(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
+ System.out.println(glGetShaderInfoLog(vshID, glGetShader(vshID, GL_INFO_LOG_LENGTH)));
+ throw new RuntimeException("Failed to compile vertex shader.");
+ }
+
+ progIDTF = glCreateProgram();
+ glAttachShader(progIDTF, vshID);
+ glTransformFeedbackVaryings(progIDTF, new CharSequence[] { "gl_Position" }, GL_SEPARATE_ATTRIBS);
+ glLinkProgram(progIDTF);
+ if ( glGetProgram(progIDTF, GL_LINK_STATUS) == GL_FALSE ) {
+ System.out.println(glGetProgramInfoLog(progIDTF, glGetProgram(progIDTF, GL_INFO_LOG_LENGTH)));
+ throw new RuntimeException("Failed to link shader program.");
+ }
+
+ glUseProgram(progIDTF);
+
+ ballSizeLoc = glGetUniformLocation(progIDTF, "ballSize");
+ deltaLoc = glGetUniformLocation(progIDTF, "delta");
+
+ glUniform1f(ballSizeLoc, ballSize * 0.5f);
+
+ // -----------------
+
+ this.vshID = glCreateShader(GL_VERTEX_SHADER);
+ glShaderSource(this.vshID, "void main(void) {\n" +
+ " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +
+ "}");
+ glCompileShader(this.vshID);
+ if ( glGetShader(this.vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
+ System.out.println(glGetShaderInfoLog(this.vshID, glGetShader(this.vshID, GL_INFO_LOG_LENGTH)));
+ throw new RuntimeException("Failed to compile vertex shader.");
+ }
+
+ createProgram();
+ }
+
+ public void updateBallSize() {
+ glUseProgram(progIDTF);
+ glUniform1f(ballSizeLoc, ballSize * 0.5f);
+
+ glUseProgram(progID);
+ super.updateBallSize();
+ }
+
+ private void doUpdateBalls(final int count) {
+ final Random random = new Random();
+
+ final Sprite newSprites = Sprite.malloc(count);
+ if ( sprites != null ) {
+ sprites.view = 0;
+ sprites.copyRange(newSprites, Math.min(count, spriteCount));
+ }
+
+ if ( count > spriteCount ) {
+ for ( int i = spriteCount; i < count; i++ ) {
+ newSprites.view = i;
+
+ newSprites.x = (int)(random.nextFloat() * (SCREEN_WIDTH - ballSize) + ballSize * 0.5f);
+ newSprites.y = (int)(random.nextFloat() * (SCREEN_HEIGHT - ballSize) + ballSize * 0.5f);
+ newSprites.dx = random.nextFloat() * 0.4f - 0.2f;
+ newSprites.dy = random.nextFloat() * 0.4f - 0.2f;
+ }
+ }
+
+ sprites = newSprites;
+ spriteCount = count;
+ }
+
+ public void updateBalls(final int count) {
+ if ( tfVBO[0] != 0 ) {
+ // Fetch current animation state
+ glGetBufferSubData(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sprites.backingByteBuffer());
+ }
+
+ doUpdateBalls(count);
+
+ if ( tfVBO[0] != 0 ) {
+ for ( int i = 0; i < tfVBO.length; i++ )
+ glDeleteBuffers(tfVBO[i]);
+ }
+
+ for ( int i = 0; i < tfVBO.length; i++ ) {
+ tfVBO[i] = glGenBuffers();
+ glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, tfVBO[i]);
+ glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, sprites.backingByteBuffer(), GL_STATIC_DRAW);
+ }
+
+ glBindBuffer(GL_ARRAY_BUFFER, tfVBO[0]);
+ glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
+ }
+
+ public void render(final boolean render, final boolean animate, final int delta) {
+ if ( animate ) {
+ glUseProgram(progIDTF);
+ glUniform1f(deltaLoc, delta);
+
+ final int vbo = currVBO;
+ currVBO = 1 - currVBO;
+
+ glBindBuffer(GL_ARRAY_BUFFER, tfVBO[vbo]);
+ glVertexPointer(4, GL_FLOAT, 0, 0);
+
+ glEnable(GL_RASTERIZER_DISCARD);
+ if ( GLContext.getCapabilities().OpenGL30 ) {
+ glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfVBO[1 - vbo]);
+
+ glBeginTransformFeedback(GL_POINTS);
+ glDrawArrays(GL_POINTS, 0, ballCount);
+ glEndTransformFeedback();
+ } else {
+ glBindBufferBaseEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, tfVBO[1 - vbo]);
+
+ glBeginTransformFeedbackEXT(GL_POINTS);
+ glDrawArrays(GL_POINTS, 0, ballCount);
+ glEndTransformFeedbackEXT();
+ }
+ glDisable(GL_RASTERIZER_DISCARD);
+
+ glUseProgram(progID);
+ glVertexPointer(2, GL_FLOAT, (4 * 4), 0);
+ }
+
+ if ( render )
+ glDrawArrays(GL_POINTS, 0, ballCount);
+ }
+
+ }
+
+}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -31,6 +31,9 @@
*/
package org.lwjgl.util.mapped;
+import org.lwjgl.LWJGLUtil;
+import org.lwjgl.MemoryUtil;
+
import java.nio.ByteBuffer;
/**
@@ -43,30 +46,32 @@
public class MappedHelper {
public static void setup(MappedObject mo, ByteBuffer buffer, int align, int sizeof) {
- if ( mo.baseAddress != 0L )
+ if ( LWJGLUtil.CHECKS && mo.baseAddress != 0L )
throw new IllegalStateException("this method should not be called by user-code");
- if ( buffer == null )
- throw new NullPointerException("buffer");
- if ( !buffer.isDirect() )
+ if ( LWJGLUtil.CHECKS && !buffer.isDirect() )
throw new IllegalArgumentException("bytebuffer must be direct");
mo.preventGC = buffer;
- if ( align <= 0 )
+ if ( LWJGLUtil.CHECKS && align <= 0 )
throw new IllegalArgumentException("invalid alignment");
mo.align = align;
- if ( sizeof % align != 0 )
+ if ( LWJGLUtil.CHECKS && (sizeof <= 0 || sizeof % align != 0) )
throw new IllegalStateException("sizeof not a multiple of alignment");
mo.sizeof = sizeof;
- long addr = MappedObjectUnsafe.getBufferBaseAddress(buffer) + buffer.position();
- if ( addr % align != 0 )
+ long addr = MemoryUtil.getAddress(buffer);
+ if ( LWJGLUtil.CHECKS && addr % align != 0 )
throw new IllegalStateException("buffer address not aligned on " + align + " bytes");
mo.baseAddress = mo.viewAddress = addr;
}
+ public static void checkAddress(MappedObject mapped, long viewAddress) {
+ mapped.checkAddress(viewAddress);
+ }
+
public static void put_views(MappedSet2 set, int view) {
set.view(view);
}
@@ -87,6 +92,14 @@
return (int)(mapped.viewAddress - mapped.baseAddress) / sizeof;
}
+ public static void put_view_shift(MappedObject mapped, int view, int sizeof_shift) {
+ mapped.setViewAddress(mapped.baseAddress + (view << sizeof_shift));
+ }
+
+ public static int get_view_shift(MappedObject mapped, int sizeof_shift) {
+ return ((int)(mapped.viewAddress - mapped.baseAddress)) >> sizeof_shift;
+ }
+
public static void put_view_next(MappedObject mapped, int sizeof) {
mapped.setViewAddress(mapped.viewAddress + sizeof);
}
@@ -130,68 +143,124 @@
MappedObjectUnsafe.INSTANCE.putByte(addr, value);
}
+ public static void bput(MappedObject mapped, byte value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putByte(mapped.viewAddress + fieldOffset, value);
+ }
+
public static byte bget(long addr) {
return MappedObjectUnsafe.INSTANCE.getByte(addr);
}
+ public static byte bget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getByte(mapped.viewAddress + fieldOffset);
+ }
+
// short
public static void sput(short value, long addr) {
MappedObjectUnsafe.INSTANCE.putShort(addr, value);
}
+ public static void sput(MappedObject mapped, short value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putShort(mapped.viewAddress + fieldOffset, value);
+ }
+
public static short sget(long addr) {
return MappedObjectUnsafe.INSTANCE.getShort(addr);
}
+ public static short sget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getShort(mapped.viewAddress + fieldOffset);
+ }
+
// char
public static void cput(char value, long addr) {
MappedObjectUnsafe.INSTANCE.putChar(addr, value);
}
+ public static void cput(MappedObject mapped, char value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putChar(mapped.viewAddress + fieldOffset, value);
+ }
+
public static char cget(long addr) {
return MappedObjectUnsafe.INSTANCE.getChar(addr);
}
+ public static char cget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getChar(mapped.viewAddress + fieldOffset);
+ }
+
// int
public static void iput(int value, long addr) {
MappedObjectUnsafe.INSTANCE.putInt(addr, value);
}
- public static int iget(long addr) {
- return MappedObjectUnsafe.INSTANCE.getInt(addr);
+ public static void iput(MappedObject mapped, int value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putInt(mapped.viewAddress + fieldOffset, value);
}
+ public static int iget(long address) {
+ return MappedObjectUnsafe.INSTANCE.getInt(address);
+ }
+
+ public static int iget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getInt(mapped.viewAddress + fieldOffset);
+ }
+
// float
public static void fput(float value, long addr) {
MappedObjectUnsafe.INSTANCE.putFloat(addr, value);
}
+ public static void fput(MappedObject mapped, float value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value);
+ }
+
public static float fget(long addr) {
return MappedObjectUnsafe.INSTANCE.getFloat(addr);
}
+ public static float fget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getFloat(mapped.viewAddress + fieldOffset);
+ }
+
// long
public static void jput(long value, long addr) {
MappedObjectUnsafe.INSTANCE.putLong(addr, value);
}
+ public static void jput(MappedObject mapped, long value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putLong(mapped.viewAddress + fieldOffset, value);
+ }
+
public static long jget(long addr) {
return MappedObjectUnsafe.INSTANCE.getLong(addr);
}
+ public static long lget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset);
+ }
+
// double
public static void dput(double value, long addr) {
MappedObjectUnsafe.INSTANCE.putDouble(addr, value);
}
+ public static void dput(MappedObject mapped, double value, int fieldOffset) {
+ MappedObjectUnsafe.INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value);
+ }
+
public static double dget(long addr) {
return MappedObjectUnsafe.INSTANCE.getDouble(addr);
}
+ public static double dget(MappedObject mapped, int fieldOffset) {
+ return MappedObjectUnsafe.INSTANCE.getDouble(mapped.viewAddress + fieldOffset);
+ }
+
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -32,6 +32,7 @@
package org.lwjgl.util.mapped;
import org.lwjgl.LWJGLUtil;
+import org.lwjgl.MemoryUtil;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
@@ -93,7 +94,7 @@
}
final void checkAddress(final long address) {
- final long base = MappedObjectUnsafe.getBufferBaseAddress(preventGC);
+ final long base = MemoryUtil.getAddress0(preventGC);
final int offset = (int)(address - base);
if ( address < base || preventGC.capacity() < (offset + this.sizeof) )
throw new IndexOutOfBoundsException(Integer.toString(offset / sizeof));
@@ -103,7 +104,7 @@
if ( bytes < 0 )
throw new IllegalArgumentException();
- if ( preventGC.capacity() < (viewAddress - MappedObjectUnsafe.getBufferBaseAddress(preventGC) + bytes) )
+ if ( preventGC.capacity() < (viewAddress - MemoryUtil.getAddress0(preventGC) + bytes) )
throw new BufferOverflowException();
}
@@ -155,7 +156,7 @@
/**
* Creates an identical new MappedObject instance, comparable to the
- * contract of {@link ByteBuffer#duplicate}. This is useful when more than one
+ * contract of {@link java.nio.ByteBuffer#duplicate}. This is useful when more than one
* views of the mapped object are required at the same time, e.g. in
* multithreaded access.
*/
@@ -166,7 +167,7 @@
/**
* Creates a new MappedObject instance, with a base offset equal to
- * the offset of the current view, comparable to the contract of {@link ByteBuffer#slice}.
+ * the offset of the current view, comparable to the contract of {@link java.nio.ByteBuffer#slice}.
*/
public final <T extends MappedObject> T slice() {
// any method that calls this method will have its call-site modified
@@ -188,6 +189,11 @@
throw new InternalError("type not registered");
}
+ /** Moves the current view to the next element. Non-transformed implementation for MappedSets. */
+ final void nextSet() {
+ setViewAddress(viewAddress + sizeof);
+ }
+
/**
* Copies and amount of <code>SIZEOF</code> bytes, from the current
* mapped object, to the specified mapped object.
@@ -220,10 +226,16 @@
return new MappedForeach<T>(mapped, elementCount);
}
+ @SuppressWarnings("unused")
+ public final <T extends MappedObject> T[] asArray() {
+ // any method that calls this method will have its call-site modified
+ throw new InternalError("type not registered");
+ }
+
ByteBuffer preventGC;
/**
- * Returns the {@link ByteBuffer} that backs this mapped object.
+ * Returns the {@link java.nio.ByteBuffer} that backs this mapped object.
*
* @return the backing buffer
*/
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectClassLoader.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -117,7 +117,7 @@
byte[] bytecode = readStream(this.getResourceAsStream(className.concat(".class")));
long t0 = System.nanoTime();
- bytecode = MappedObjectTransformer.transformFieldAccess(className, bytecode);
+ bytecode = MappedObjectTransformer.transformMappedAPI(className, bytecode);
long t1 = System.nanoTime();
total_time_transforming += (t1 - t0);
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-21 22:52:16 UTC (rev 3596)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-22 02:01:56 UTC (rev 3597)
@@ -1,21 +1,51 @@
/*
- * Created on Jun 23, 2011
+ * Copyright (c) 2002-2011 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.mapped;
import org.lwjgl.LWJGLUtil;
import org.objectweb.asm.*;
+import org.objectweb.asm.tree.*;
+import org.objectweb.asm.tree.analysis.*;
import org.objectweb.asm.util.TraceClassVisitor;
-import java.io.*;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
-import java.util.StringTokenizer;
+import static org.objectweb.asm.ClassWriter.*;
import static org.objectweb.asm.Opcodes.*;
/**
@@ -25,7 +55,7 @@
* The transformer supports some debugging tools, enabled through JVM system properties:<br/>
* org.lwjgl.util.mapped.PrintTiming=true, prints timing information for the transformation step.<br/>
* org.lwjgl.util.mapped.PrintActivity=true, prints activity information.<br/>
- * org.lwjgl.util.mapped.PrintBytecode=true, prints the transformed bytecode. [not working atm]<br/>
+ * org.lwjgl.util.mapped.PrintBytecode=true, prints the transformed bytecode.<br/>
* org.lwjgl.util.Debug must also be set to true for the above to work.
*
* @author Riven
@@ -41,7 +71,24 @@
static final String MAPPED_OBJECT_JVM = jvmClassName(MappedObject.class);
static final String MAPPED_HELPER_JVM = jvmClassName(MappedHelper.class);
+ static final String MAPPEDSET_PREFIX = jvmClassName(MappedSet.class);
+ static final String MAPPED_SET2_JVM = jvmClassName(MappedSet2.class);
+ static final String MAPPED_SET3_JVM = jvmClassName(MappedSet3.class);
+ static final String MAPPED_SET4_JVM = jvmClassName(MappedSet4.class);
+
+ static final String LENGTH_METHOD_NAME = "length$LWJGL";
+ static final String VIEWADDRESS_METHOD_NAME = "getViewAddress$LWJGL";
+ static final String VIEW_CONSTRUCTOR_NAME = "constructView$LWJGL";
+
+ static final Map<Integer, String> OPCODE_TO_NAME = new HashMap<Integer, String>();
+ static final Map<Integer, String> INSNTYPE_TO_NAME = new HashMap<Integer, String>();
+
+ static boolean is_currently_computing_frames;
+
static {
+ getClassEnums(Opcodes.class, OPCODE_TO_NAME, "V1_", "ACC_", "T_", "F_", "MH_");
+ getClassEnums(AbstractInsnNode.class, INSNTYPE_TO_NAME);
+
className_to_subtype = new HashMap<String, MappedSubtypeInfo>();
{
@@ -59,11 +106,10 @@
// => IADD
// => PUTFIELD MyMappedType.view
//
- MappedSubtypeInfo info = new MappedSubtypeInfo(MAPPED_OBJECT_JVM, -1, -1);
- className_to_subtype.put(info.className, info);
+ className_to_subtype.put(MAPPED_OBJECT_JVM, new MappedSubtypeInfo(MAPPED_OBJECT_JVM, -1, -1));
}
- String vmName = System.getProperty("java.vm.name");
+ final String vmName = System.getProperty("java.vm.name");
if ( vmName != null && !vmName.contains("Server") ) {
System.err.println("Warning: " + MappedObject.class.getSimpleName() + "s have inferiour performance on Client VMs, please consider switching to a Server VM.");
}
@@ -71,7 +117,7 @@
/**
* Registers a class as a mapped object.
- * The class must extend {@link MappedObject} and be annotated with {@link MappedField}.
+ * The class must extend {@link org.lwjgl.util.mapped.MappedObject} and be annotated with {@link org.lwjgl.util.mapped.MappedField}.
*
* @param type the mapped object class.
*/
@@ -79,585 +125,992 @@
if ( MappedObjectClassLoader.FORKED )
return;
- MappedType mapped = type.getAnnotation(MappedType.class);
+ final MappedType mapped = type.getAnnotation(MappedType.class);
if ( mapped == null )
throw new InternalError("missing " + MappedType.class.getName() + " annotation");
if ( type.getEnclosingClass() != null && !Modifier.isStatic(type.getModifiers()) )
throw new InternalError("only top-level or static inner classes are allowed");
- String className = jvmClassName(type);
+ final MappedSubtypeInfo mappedType = new MappedSubtypeInfo(jvmClassName(type), mapped.sizeof(), mapped.align());
- MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, mapped.sizeof(), mapped.align());
-
int advancingOffset = 0;
+ for ( Field field : type.getDeclaredFields() )
+ advancingOffset += registerField(mapped, mappedType.className, mappedType, advancingOffset, field);
- for ( Field field : type.getDeclaredFields() ) {
- // static fields are never mapped
- if ( Modifier.isStatic(field.getModifiers()) )
- continue;
+ if ( className_to_subtype.put(mappedType.className, mappedType) != null )
+ throw new InternalError("duplicate mapped type: " + mappedType.className);
+ }
- // we only support primitives and ByteBuffers
- if ( !field.getType().isPrimitive() && field.getType() != ByteBuffer.class )
- throw new InternalError("field '" + className + "." + field.getName() + "' not supported: " + field.getType());
+ private static int registerField(final MappedType mapped, final String className, final MappedSubtypeInfo mappedType, int advancingOffset, final Field field) {
+ if ( Modifier.isStatic(field.getModifiers()) ) // static fields are never mapped
+ return 0;
- MappedField meta = field.getAnnotation(MappedField.class);
- if ( meta == null && !mapped.autoGenerateOffsets() )
- throw new InternalError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className);
+ // we only support primitives and ByteBuffers
+ if ( !field.getType().isPrimitive() && field.getType() != ByteBuffer.class )
+ throw new InternalError("field '" + className + "." + field.getName() + "' not supported: " + field.getType());
- // quick hack
- long byteOffset = meta == null ? advancingOffset : meta.byteOffset();
- long byteLength;
- if ( field.getType() == long.class || field.getType() == double.class )
- byteLength = 8;
- else if ( field.getType() == int.class || field.getType() == float.class )
- byteLength = 4;
- else if ( field.getType() == char.class || field.getType() == short.class )
- byteLength = 2;
- else if ( field.getType() == byte.class )
- byteLength = 1;
- else if ( field.getType() == ByteBuffer.class ) {
- byteLength = meta.byteLength();
- if ( byteLength < 0 )
- throw new IllegalStateException("invalid byte length for mapped ByteBuffer field: " + className + "." + field.getName() + " [length=" + byteLength + "]");
- } else
- throw new IllegalStateException(field.getType().getName());
+ MappedField meta = field.getAnnotation(MappedField.class);
+ if ( meta == null && !mapped.autoGenerateOffsets() )
+ throw new InternalError("field '" + className + "." + field.getName() + "' missing annotation " + MappedField.class.getName() + ": " + className);
- if ( field.getType() != ByteBuffer.class )
- if ( (advancingOffset % byteLength) != 0 )
- throw new IllegalStateException("misaligned mapped type: " + className + "." + field.getName());
+ // quick hack
+ long byteOffset = meta == null ? advancingOffset : meta.byteOffset();
+ long byteLength;
+ if ( field.getType() == long.class || field.getType() == double.class )
+ byteLength = 8;
+ else if ( field.getType() == int.class || field.getType() == float.class )
+ byteLength = 4;
+ else if ( field.getType() == char.class || field.getType() == short.class )
+ byteLength = 2;
+ else if ( field.getType() == byte.class )
+ byteLength = 1;
+ else if ( field.getType() == ByteBuffer.class ) {
+ byteLength = meta.byteLength();
+ if ( byteLength < 0 )
+ throw new IllegalStateException("invalid byte length for mapped ByteBuffer field: " + className + "." + field.getName() + " [length=" + byteLength + "]");
+ } else
+ throw new InternalError(field.getType().getName());
- if ( PRINT_ACTIVITY )
- LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]");
+ if ( field.getType() != ByteBuffer.class && (advancingOffset % byteLength) != 0 )
+ throw new IllegalStateException("misaligned mapped type: " + className + "." + field.getName());
- mappedType.fieldToOffset.put(field.getName(), byteOffset);
- mappedType.fieldToLength.put(field.getName(), byteLength);
+ if ( PRINT_ACTIVITY )
+ LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]");
- advancingOffset += byteLength;
- }
+ mappedType.fieldToOffset.put(field.getName(), byteOffset);
+ mappedType.fieldToLength.put(field.getName(), byteLength);
+ mappedType.fieldToType.put(field.getName(), Type.getType(field.getType()));
- if ( className_to_subtype.put(className, mappedType) != null ) {
- throw new InternalError("duplicate mapped type: " + className);
- }
+ return (int)byteLength;
}
- static boolean is_currently_computing_frames = false;
- static final String view_constructor_method = "_construct_view_";
+ static byte[] transformMappedAPI(final String className, byte[] bytecode) {
+ final ClassWriter cw = new ClassWriter(COMPUTE_FRAMES) {
- static byte[] transformFieldAccess(final String className, byte[] bytecode) {
- int flags = ClassWriter.COMPUTE_FRAMES;
-
- ClassWriter writer = new ClassWriter(flags) {
- // HACK: prevent user-code static-initialization-blocks to be executed
-
@Override
protected String getCommonSuperClass(String a, String b) {
- if ( is_currently_computing_frames )
- if ( !a.startsWith("java/") || !b.startsWith("java/") )
- return "java/lang/Object";
+ // HACK: prevent user-code static-initialization-blocks to be executed
+ if ( is_currently_computing_frames && !a.startsWith("java/") || !b.startsWith("java/") )
+ return "java/lang/Object";
+
return super.getCommonSuperClass(a, b);
}
+
};
- ClassAdapter adapter = new ClassAdapter(writer) {
+ ClassVisitor cv = getTransformationAdapter(className, cw);
+ if ( className_to_subtype.containsKey(className) ) // Do a first pass to generate address getters
+ cv = getMethodGenAdapter(className, cv);
+
+ //cr.accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
+ new ClassReader(bytecode).accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
+ bytecode = cw.toByteArray();
+
+ if ( PRINT_BYTECODE )
+ printBytecode(bytecode);
+
+ return bytecode;
+ }
+
+ private static ClassAdapter getMethodGenAdapter(final String className, final ClassVisitor cv) {
+ return new ClassAdapter(cv) {
+
@Override
- public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
- {
- MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
+ public void visitEnd() {
+ generateViewAddressGetter();
+ generateLengthGetter();
- if ( mappedSubtype != null && !mappedSubtype.className.equals(MAPPED_OBJECT_JVM) ) {
- if ( "<init>".equals(name) ) {
- if ( !"()V".equals(desc) )
- throw new IllegalStateException(className + " can only have a default constructor, found: " + desc);
+ final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
- MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
- mv.visitCode(...
[truncated message content] |
|
From: <ma...@us...> - 2011-07-21 22:52:23
|
Revision: 3596
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3596&view=rev
Author: matzon
Date: 2011-07-21 22:52:16 +0000 (Thu, 21 Jul 2011)
Log Message:
-----------
Initial stab at win32 resize api
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-17 09:37:35 UTC (rev 3595)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-21 22:52:16 UTC (rev 3596)
@@ -41,6 +41,7 @@
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
+import java.nio.LongBuffer;
import java.awt.Canvas;
import org.lwjgl.LWJGLException;
@@ -66,7 +67,10 @@
private static final int WM_MBUTTONDBLCLK = 0x0209;
private static final int WM_MOUSEWHEEL = 0x020A;
private static final int WM_CAPTURECHANGED = 0x0215;
- private static final int WM_MOUSELEAVE = 0x02A3;
+ private static final int WM_MOUSELEAVE = 0x02A3;
+ private static final int WM_ENTERSIZEMOVE = 0x0231;
+ private static final int WM_EXITSIZEMOVE = 0x0232;
+ private static final int WM_SIZING = 0x0214;
private static final int WM_KEYDOWN = 256;
private static final int WM_KEYUP = 257;
private static final int WM_SYSKEYUP = 261;
@@ -115,6 +119,7 @@
private static final int WA_INACTIVE = 0;
private static final int WA_ACTIVE = 1;
private static final int WA_CLICKACTIVE = 2;
+ private static final int SW_NORMAL = 1;
private static final int SW_SHOWMINNOACTIVE = 7;
private static final int SW_SHOWDEFAULT = 10;
private static final int SW_RESTORE = 9;
@@ -124,6 +129,23 @@
private static final IntBuffer rect_buffer = BufferUtils.createIntBuffer(4);
private static final Rect rect = new Rect();
+
+ private static final long HWND_TOP = 0;
+ private static final long HWND_BOTTOM = 1;
+ private static final long HWND_TOPMOST = -1;
+ private static final long HWND_NOTOPMOST = -2;
+
+ private static final int SWP_NOSIZE = 0x0001;
+ private static final int SWP_NOMOVE = 0x0002;
+ private static final int SWP_NOZORDER = 0x0004;
+ private static final int SWP_FRAMECHANGED = 0x0020;
+
+ private static final int GWL_STYLE = -16;
+ private static final int GWL_EXSTYLE = -20;
+
+ private static final int WS_THICKFRAME = 0x00040000;
+
+
private static WindowsDisplay current_display;
private static boolean cursor_clipped;
@@ -147,6 +169,10 @@
private boolean isFocused;
private boolean did_maximize;
private boolean inAppActivate;
+ private boolean resized;
+ private boolean resizable;
+ private int width;
+ private int height;
private long hwnd;
private long hdc;
@@ -191,7 +217,13 @@
}
peer_info.initDC(getHwnd(), getHdc());
showWindow(getHwnd(), SW_SHOWDEFAULT);
+
+ updateWidthAndHeight();
+
if ( parent == null ) {
+ if(Display.isResizable()) {
+ setResizable(true);
+ }
setForegroundWindow(getHwnd());
setFocus(getHwnd());
}
@@ -201,6 +233,14 @@
throw e;
}
}
+
+ private void updateWidthAndHeight() {
+ getClientRect(hwnd, rect_buffer);
+ rect.copyFromBuffer(rect_buffer);
+ width = rect.right - rect.left;
+ height = rect.bottom - rect.top;
+ }
+
private static native long nCreateWindow(int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException;
private static boolean isUndecorated() {
@@ -695,6 +735,9 @@
private static native long createIcon(int width, int height, IntBuffer icon);
private static native void destroyIcon(long handle);
private static native long sendMessage(long hwnd, long msg, long wparam, long lparam);
+ private static native long setWindowLongPtr(long hwnd, int nindex, long longPtr);
+ private static native long getWindowLongPtr(long hwnd, int nindex);
+ private static native boolean setWindowPos(long hwnd, long hwnd_after, int x, int y, int cx, int cy, long uflags);
private void handleMouseButton(int button, int state, long millis) {
if (mouse != null) {
@@ -820,6 +863,14 @@
break;
}
return defWindowProc(hwnd, msg, wParam, lParam);
+ case WM_ENTERSIZEMOVE:
+ return defWindowProc(hwnd, msg, wParam, lParam);
+ case WM_EXITSIZEMOVE:
+ return defWindowProc(hwnd, msg, wParam, lParam);
+ case WM_SIZING:
+ resized = true;
+ updateWidthAndHeight();
+ return defWindowProc(hwnd, msg, wParam, lParam);
case WM_KILLFOCUS:
appActivate(false);
return 0;
@@ -900,10 +951,10 @@
case WM_PAINT:
is_dirty = true;
return defWindowProc(hwnd, msg, wParam, lParam);
- case WM_MOUSELEAVE:
- mouseInside = false;
- trackingMouse = false;
- return defWindowProc(hwnd, msg, wParam, lParam);
+ case WM_MOUSELEAVE:
+ mouseInside = false;
+ trackingMouse = false;
+ return defWindowProc(hwnd, msg, wParam, lParam);
case WM_CANCELMODE:
nReleaseCapture();
/* fall through */
@@ -919,11 +970,11 @@
}
public int getWidth() {
- return Display.getDisplayMode().getWidth();
+ return width;
}
public int getHeight() {
- return Display.getDisplayMode().getHeight();
+ return height;
}
private int firstMouseButtonDown() {
@@ -942,10 +993,40 @@
}
public void setResizable(boolean resizable) {
-
+ if(this.resizable != resizable) {
+ long style = getWindowLongPtr(hwnd, GWL_STYLE);
+ long styleex = getWindowLongPtr(hwnd, GWL_EXSTYLE);
+
+ // update frame style
+ if(resizable) {
+ setWindowLongPtr(hwnd, GWL_STYLE, style |= WS_THICKFRAME);
+ } else {
+ setWindowLongPtr(hwnd, GWL_STYLE, style &= ~WS_THICKFRAME);
+ }
+
+ // from the existing client rect, determine the new window rect
+ // based on the style changes - using AdjustWindowRectEx.
+ getClientRect(hwnd, rect_buffer);
+ rect.copyFromBuffer(rect_buffer);
+ adjustWindowRectEx(rect_buffer, style, false, styleex);
+ rect.copyFromBuffer(rect_buffer);
+
+ // force a frame update and resize accordingly
+ setWindowPos(hwnd, HWND_TOP, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
+
+ updateWidthAndHeight();
+ resized = false;
+ }
+ this.resizable = resizable;
}
+ private native boolean adjustWindowRectEx(IntBuffer rectBuffer, long style, boolean menu, long styleex);
+
public boolean wasResized() {
+ if(resized) {
+ resized = false;
+ return true;
+ }
return false;
}
@@ -981,7 +1062,7 @@
}
public String toString() {
- return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right;
+ return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right + ", width: " + (right - left) + ", height: " + (bottom - top);
}
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java 2011-07-17 09:37:35 UTC (rev 3595)
+++ trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java 2011-07-21 22:52:16 UTC (rev 3596)
@@ -354,6 +354,10 @@
if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
Mouse.setGrabbed(!Mouse.isGrabbed());
}
+
+ if(Keyboard.getEventKey() == Keyboard.KEY_R && Keyboard.getEventKeyState()) {
+ Display.setResizable(!Display.isResizable());
+ }
}
}
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2011-07-17 09:37:35 UTC (rev 3595)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2011-07-21 22:52:16 UTC (rev 3596)
@@ -427,6 +427,32 @@
return SendMessage(hwnd, (UINT)msg, (WPARAM)wparam, (LPARAM)lparam);
}
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowLongPtr
+ (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex, jlong longPtr) {
+
+ HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
+ return SetWindowLongPtr(hwnd, nindex, (LONG_PTR) longPtr);
+}
+
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowLongPtr
+ (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex) {
+
+ HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
+ jlong result = GetWindowLongPtr(hwnd, nindex);
+ return result;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowPos
+ (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hwnd_after_ptr, jint x, jint y, jint width, jint height, jlong uflags) {
+
+ jboolean result;
+ HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
+ HWND hwnd_after = (HWND)(INT_PTR)hwnd_after_ptr;
+
+ result = SetWindowPos(hwnd, hwnd_after, x, y, width, height, (UINT) uflags);
+ return result;
+}
+
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition
(JNIEnv * env, jclass unused, jint x, jint y) {
if (!SetCursorPos(x, y))
@@ -441,6 +467,16 @@
copyRectToBuffer(env, &clientRect, rect_buffer);
}
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_adjustWindowRectEx
+ (JNIEnv *env, jclass unused, jobject rect_buffer, jlong style, jboolean menu, jlong styleex) {
+ jboolean result;
+ RECT clientRect;
+ copyBufferToRect(env, rect_buffer, &clientRect);
+ result = AdjustWindowRectEx(&clientRect, style, menu, styleex);
+ copyRectToBuffer(env, &clientRect, rect_buffer);
+ return result;
+}
+
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetNativeCursor
(JNIEnv *env, jclass unused, jlong hwnd_int, jobject handle_buffer)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-17 09:37:41
|
Revision: 3595
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3595&view=rev
Author: spasi
Date: 2011-07-17 09:37:35 +0000 (Sun, 17 Jul 2011)
Log Message:
-----------
Code cleanup.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java
trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-16 22:40:06 UTC (rev 3594)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-17 09:37:35 UTC (rev 3595)
@@ -50,20 +50,29 @@
private static final int BUFFERS_SIZE = 32;
- private char[] arrayTL;
- private ByteBuffer bufferTL;
- private IntBuffer lengthsTL;
- private final Buffers buffersTL;
+ private char[] array;
+ private ByteBuffer buffer;
+ private IntBuffer lengths;
+ private final IntBuffer ints;
+ private final LongBuffer longs;
+ private final FloatBuffer floats;
+ private final DoubleBuffer doubles;
+
APIUtil() {
- arrayTL = new char[INITIAL_BUFFER_SIZE];
- bufferTL = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE);
- lengthsTL = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE);
- buffersTL = new Buffers();
+ array = new char[INITIAL_BUFFER_SIZE];
+ buffer = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE);
+ lengths = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE);
+
+ ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
+ longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
+
+ floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
+ doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
}
private static char[] getArray(final ContextCapabilities caps, final int size) {
- char[] array = caps.util.arrayTL;
+ char[] array = caps.util.array;
if ( array.length < size ) {
int sizeNew = array.length << 1;
@@ -71,14 +80,14 @@
sizeNew <<= 1;
array = new char[size];
- caps.util.arrayTL = array;
+ caps.util.array = array;
}
return array;
}
static ByteBuffer getBufferByte(final ContextCapabilities caps, final int size) {
- ByteBuffer buffer = caps.util.bufferTL;
+ ByteBuffer buffer = caps.util.buffer;
if ( buffer.capacity() < size ) {
int sizeNew = buffer.capacity() << 1;
@@ -86,7 +95,7 @@
sizeNew <<= 1;
buffer = BufferUtils.createByteBuffer(size);
- caps.util.bufferTL = buffer;
+ caps.util.buffer = buffer;
} else
buffer.clear();
@@ -94,7 +103,7 @@
}
private static ByteBuffer getBufferByteOffset(final ContextCapabilities caps, final int size) {
- ByteBuffer buffer = caps.util.bufferTL;
+ ByteBuffer buffer = caps.util.buffer;
if ( buffer.capacity() < size ) {
int sizeNew = buffer.capacity() << 1;
@@ -103,7 +112,7 @@
final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size);
bufferNew.put(buffer);
- caps.util.bufferTL = (buffer = bufferNew);
+ caps.util.buffer = (buffer = bufferNew);
} else {
buffer.position(buffer.limit());
buffer.limit(buffer.capacity());
@@ -112,22 +121,20 @@
return buffer;
}
- static ShortBuffer getBufferShort(final ContextCapabilities caps) { return caps.util.buffersTL.shorts; }
+ static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.ints; }
- static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.buffersTL.ints; }
+ static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.longs; }
- static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.buffersTL.longs; }
+ static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.floats; }
- static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.buffersTL.floats; }
+ static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.doubles; }
- static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.buffersTL.doubles; }
-
static IntBuffer getLengths(final ContextCapabilities caps) {
return getLengths(caps, 1);
}
static IntBuffer getLengths(final ContextCapabilities caps, final int size) {
- IntBuffer lengths = caps.util.lengthsTL;
+ IntBuffer lengths = caps.util.lengths;
if ( lengths.capacity() < size ) {
int sizeNew = lengths.capacity();
@@ -135,7 +142,7 @@
sizeNew <<= 1;
lengths = BufferUtils.createIntBuffer(size);
- caps.util.lengthsTL = lengths;
+ caps.util.lengths = lengths;
} else
lengths.clear();
@@ -286,24 +293,4 @@
return MemoryUtil.getAddress0(getBufferByte(caps, 0));
}
- private static class Buffers {
-
- final ShortBuffer shorts;
- final IntBuffer ints;
- final LongBuffer longs;
-
- final FloatBuffer floats;
- final DoubleBuffer doubles;
-
- Buffers() {
- shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE);
- ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
- longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
-
- floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
- doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
- }
-
- }
-
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java 2011-07-16 22:40:06 UTC (rev 3594)
+++ trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java 2011-07-17 09:37:35 UTC (rev 3595)
@@ -39,9 +39,12 @@
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
-/** @author spasi */
+/**
+ * Utility class for OpenGL ES API calls.
+ *
+ * @author spasi
+ */
final class APIUtil {
private static final int INITIAL_BUFFER_SIZE = 256;
@@ -138,14 +141,10 @@
return buffer;
}
- static ShortBuffer getBufferShort() { return buffersTL.get().shorts; }
-
static IntBuffer getBufferInt() { return buffersTL.get().ints; }
static FloatBuffer getBufferFloat() { return buffersTL.get().floats; }
- static PointerBuffer getBufferPointer() { return buffersTL.get().pointers; }
-
static IntBuffer getLengths() {
return getLengths(1);
}
@@ -312,18 +311,12 @@
private static class Buffers {
- final ShortBuffer shorts;
final IntBuffer ints;
final FloatBuffer floats;
- final PointerBuffer pointers;
-
Buffers() {
- shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE);
ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
-
- pointers = BufferUtils.createPointerBuffer(BUFFERS_SIZE);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-16 22:40:12
|
Revision: 3594
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3594&view=rev
Author: spasi
Date: 2011-07-16 22:40:06 +0000 (Sat, 16 Jul 2011)
Log Message:
-----------
Removed GLES dependency on GL APIUtil.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java 2011-07-16 22:26:46 UTC (rev 3593)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java 2011-07-16 22:40:06 UTC (rev 3594)
@@ -31,6 +31,7 @@
*/
package org.lwjgl.opengl;
+import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.PointerBuffer;
@@ -95,7 +96,7 @@
EGL_NATIVE_RENDERABLE, EGL_FALSE,
};
- final EGLConfig[] configs = eglDisplay.chooseConfig(pf.getAttribBuffer(eglDisplay, eglSurfaceType, attribs), null, APIUtil.getBufferInt());
+ final EGLConfig[] configs = eglDisplay.chooseConfig(pf.getAttribBuffer(eglDisplay, eglSurfaceType, attribs), null, BufferUtils.createIntBuffer(1));
if ( configs.length == 0 )
throw new LWJGLException("No EGLConfigs found for the specified PixelFormat.");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-16 22:26:54
|
Revision: 3593
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3593&view=rev
Author: spasi
Date: 2011-07-16 22:26:46 +0000 (Sat, 16 Jul 2011)
Log Message:
-----------
Converted GL APIUtil to a per ContextCapabilities instance.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/TypeMap.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLESTypeMap.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL30.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL33.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL40.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL41.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_fence.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_occlusion_query.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_program.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002-2008 LWJGL Project
+ * Copyright (c) 2002-2011 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,35 +37,33 @@
import java.nio.*;
-/** @author spasi */
+/**
+ * Utility class for OpenGL API calls. Instances of APIUtil are created in ContextCapabilities,
+ * so we have an instance per OpenGL context.
+ *
+ * @author spasi
+ */
final class APIUtil {
- private static final int INITIAL_BUFFER_SIZE = 256;
+ private static final int INITIAL_BUFFER_SIZE = 256;
private static final int INITIAL_LENGTHS_SIZE = 4;
private static final int BUFFERS_SIZE = 32;
- private static final ThreadLocal<char[]> arrayTL = new ThreadLocal<char[]>() {
- protected char[] initialValue() { return new char[INITIAL_BUFFER_SIZE]; }
- };
+ private char[] arrayTL;
+ private ByteBuffer bufferTL;
+ private IntBuffer lengthsTL;
+ private final Buffers buffersTL;
- private static final ThreadLocal<ByteBuffer> bufferTL = new ThreadLocal<ByteBuffer>() {
- protected ByteBuffer initialValue() { return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); }
- };
-
- private static final ThreadLocal<IntBuffer> lengthsTL = new ThreadLocal<IntBuffer>() {
- protected IntBuffer initialValue() { return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); }
- };
-
- private static final ThreadLocal<Buffers> buffersTL = new ThreadLocal<Buffers>() {
- protected Buffers initialValue() { return new Buffers(); }
- };
-
- private APIUtil() {
+ APIUtil() {
+ arrayTL = new char[INITIAL_BUFFER_SIZE];
+ bufferTL = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE);
+ lengthsTL = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE);
+ buffersTL = new Buffers();
}
- private static char[] getArray(final int size) {
- char[] array = arrayTL.get();
+ private static char[] getArray(final ContextCapabilities caps, final int size) {
+ char[] array = caps.util.arrayTL;
if ( array.length < size ) {
int sizeNew = array.length << 1;
@@ -73,14 +71,14 @@
sizeNew <<= 1;
array = new char[size];
- arrayTL.set(array);
+ caps.util.arrayTL = array;
}
return array;
}
- static ByteBuffer getBufferByte(final int size) {
- ByteBuffer buffer = bufferTL.get();
+ static ByteBuffer getBufferByte(final ContextCapabilities caps, final int size) {
+ ByteBuffer buffer = caps.util.bufferTL;
if ( buffer.capacity() < size ) {
int sizeNew = buffer.capacity() << 1;
@@ -88,15 +86,15 @@
sizeNew <<= 1;
buffer = BufferUtils.createByteBuffer(size);
- bufferTL.set(buffer);
+ caps.util.bufferTL = buffer;
} else
buffer.clear();
return buffer;
}
- private static ByteBuffer getBufferByteOffset(final int size) {
- ByteBuffer buffer = bufferTL.get();
+ private static ByteBuffer getBufferByteOffset(final ContextCapabilities caps, final int size) {
+ ByteBuffer buffer = caps.util.bufferTL;
if ( buffer.capacity() < size ) {
int sizeNew = buffer.capacity() << 1;
@@ -105,7 +103,7 @@
final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size);
bufferNew.put(buffer);
- bufferTL.set(buffer = bufferNew);
+ caps.util.bufferTL = (buffer = bufferNew);
} else {
buffer.position(buffer.limit());
buffer.limit(buffer.capacity());
@@ -114,22 +112,22 @@
return buffer;
}
- static ShortBuffer getBufferShort() { return buffersTL.get().shorts; }
+ static ShortBuffer getBufferShort(final ContextCapabilities caps) { return caps.util.buffersTL.shorts; }
- static IntBuffer getBufferInt() { return buffersTL.get().ints; }
+ static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.buffersTL.ints; }
- static LongBuffer getBufferLong() { return buffersTL.get().longs; }
+ static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.buffersTL.longs; }
- static FloatBuffer getBufferFloat() { return buffersTL.get().floats; }
+ static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.buffersTL.floats; }
- static DoubleBuffer getBufferDouble() { return buffersTL.get().doubles; }
+ static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.buffersTL.doubles; }
- static IntBuffer getLengths() {
- return getLengths(1);
+ static IntBuffer getLengths(final ContextCapabilities caps) {
+ return getLengths(caps, 1);
}
- static IntBuffer getLengths(final int size) {
- IntBuffer lengths = lengthsTL.get();
+ static IntBuffer getLengths(final ContextCapabilities caps, final int size) {
+ IntBuffer lengths = caps.util.lengthsTL;
if ( lengths.capacity() < size ) {
int sizeNew = lengths.capacity();
@@ -137,7 +135,7 @@
sizeNew <<= 1;
lengths = BufferUtils.createIntBuffer(size);
- lengthsTL.set(lengths);
+ caps.util.lengthsTL = lengths;
} else
lengths.clear();
@@ -169,9 +167,9 @@
*
* @return the buffer as a String.
*/
- static String getString(final ByteBuffer buffer) {
+ static String getString(final ContextCapabilities caps, final ByteBuffer buffer) {
final int length = buffer.remaining();
- final char[] charArray = getArray(length);
+ final char[] charArray = getArray(caps, length);
for ( int i = buffer.position(); i < buffer.limit(); i++ )
charArray[i - buffer.position()] = (char)buffer.get(i);
@@ -186,8 +184,8 @@
*
* @return the String as a ByteBuffer
*/
- static long getBuffer(final CharSequence string) {
- final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
+ static long getBuffer(final ContextCapabilities caps, final CharSequence string) {
+ final ByteBuffer buffer = encode(getBufferByte(caps, string.length()), string);
buffer.flip();
return MemoryUtil.getAddress0(buffer);
}
@@ -199,8 +197,8 @@
*
* @return the String as a ByteBuffer
*/
- static long getBuffer(final CharSequence string, final int offset) {
- final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
+ static long getBuffer(final ContextCapabilities caps, final CharSequence string, final int offset) {
+ final ByteBuffer buffer = encode(getBufferByteOffset(caps, offset + string.length()), string);
buffer.flip();
return MemoryUtil.getAddress(buffer);
}
@@ -212,8 +210,8 @@
*
* @return the String as a ByteBuffer
*/
- static long getBufferNT(final CharSequence string) {
- final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
+ static long getBufferNT(final ContextCapabilities caps, final CharSequence string) {
+ final ByteBuffer buffer = encode(getBufferByte(caps, string.length() + 1), string);
buffer.put((byte)0);
buffer.flip();
return MemoryUtil.getAddress0(buffer);
@@ -234,8 +232,8 @@
*
* @return the Strings as a ByteBuffer
*/
- static long getBuffer(final CharSequence[] strings) {
- final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
+ static long getBuffer(final ContextCapabilities caps, final CharSequence[] strings) {
+ final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings));
for ( CharSequence string : strings )
encode(buffer, string);
@@ -251,8 +249,8 @@
*
* @return the Strings as a ByteBuffer
*/
- static long getBufferNT(final CharSequence[] strings) {
- final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
+ static long getBufferNT(final ContextCapabilities caps, final CharSequence[] strings) {
+ final ByteBuffer buffer = getBufferByte(caps, getTotalLength(strings) + strings.length);
for ( CharSequence string : strings ) {
encode(buffer, string);
@@ -270,8 +268,8 @@
*
* @return the String lengths in an IntBuffer
*/
- static long getLengths(final CharSequence[] strings) {
- IntBuffer buffer = getLengths(strings.length);
+ static long getLengths(final ContextCapabilities caps, final CharSequence[] strings) {
+ IntBuffer buffer = getLengths(caps, strings.length);
for ( CharSequence string : strings )
buffer.put(string.length());
@@ -280,21 +278,21 @@
return MemoryUtil.getAddress0(buffer);
}
- static long getInt(final int value) {
- return MemoryUtil.getAddress0(getBufferInt().put(0, value));
+ static long getInt(final ContextCapabilities caps, final int value) {
+ return MemoryUtil.getAddress0(getBufferInt(caps).put(0, value));
}
- static long getBufferByte0() {
- return MemoryUtil.getAddress0(getBufferByte(0));
+ static long getBufferByte0(final ContextCapabilities caps) {
+ return MemoryUtil.getAddress0(getBufferByte(caps, 0));
}
private static class Buffers {
final ShortBuffer shorts;
- final IntBuffer ints;
- final LongBuffer longs;
+ final IntBuffer ints;
+ final LongBuffer longs;
- final FloatBuffer floats;
+ final FloatBuffer floats;
final DoubleBuffer doubles;
Buffers() {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -301,13 +301,13 @@
}
} else if ( method.getAnnotation(GLreturn.class) != null ) {
has_result = true;
- Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class));
+ Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class), type_map);
}
writer.print(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
if (mode == Mode.BUFFEROBJECT)
writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX);
writer.print("(");
- boolean first_parameter = printMethodCallArguments(writer, method, typeinfos_instance, mode);
+ boolean first_parameter = printMethodCallArguments(writer, method, typeinfos_instance, mode, type_map);
if (context_specific) {
if (!first_parameter)
writer.print(", ");
@@ -335,7 +335,7 @@
else
writer.println(tabs + "return " + Utils.RESULT_VAR_NAME + ";");
} else
- Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class));
+ Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class), type_map);
}
if ( code_annotation != null && code_annotation.tryBlock() ) {
@@ -439,7 +439,7 @@
throw new RuntimeException(c + " is not allowed");
}
- private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean first_parameter) {
+ private static boolean printMethodCallArgument(PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, boolean first_parameter, TypeMap type_map) {
if (!first_parameter)
writer.print(", ");
@@ -496,7 +496,9 @@
writer.print("APIUtil.getBuffer");
if ( param.getAnnotation(NullTerminated.class) != null )
writer.print("NT");
- writer.print("(" + param.getSimpleName());
+ writer.print('(');
+ writer.print(type_map.getAPIUtilParam(true));
+ writer.print(param.getSimpleName());
if ( offset != null )
writer.print(", " + offset);
writer.print(")");
@@ -531,7 +533,7 @@
return false;
}
- private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode) {
+ private static boolean printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode, TypeMap type_map) {
boolean first_parameter = true;
for ( ParameterDeclaration param : method.getParameters() ) {
if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) )
@@ -539,7 +541,7 @@
final Constant constant_annotation = param.getAnnotation(Constant.class);
if ( constant_annotation== null || !constant_annotation.isNative() )
- first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter);
+ first_parameter = printMethodCallArgument(writer, method, param, typeinfos_instance, mode, first_parameter, type_map);
}
if (Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null) {
if (method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange()) {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/TypeMap.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/TypeMap.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/TypeMap.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -50,6 +50,7 @@
public interface TypeMap {
void printCapabilitiesInit(PrintWriter writer);
String getCapabilities();
+ String getAPIUtilParam(boolean comma);
void printErrorCheckMethod(PrintWriter writer, MethodDeclaration method, String tabs);
String getRegisterNativesFunctionName();
PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class<? extends Annotation> native_type);
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -57,19 +57,19 @@
public class Utils {
- public static final String TYPEDEF_POSTFIX = "PROC";
- public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer";
- public static final String FUNCTION_POINTER_POSTFIX = "_pointer";
- public static final String CHECKS_CLASS_NAME = "GLChecks";
- public static final String CONTEXT_CAPS_CLASS_NAME = "ContextCapabilities";
- public static final String STUB_INITIALIZER_NAME = "initNativeStubs";
- public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO";
- public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset";
- public static final String RESULT_SIZE_NAME = "result_size";
- public static final String RESULT_VAR_NAME = "__result";
- public static final String CACHED_BUFFER_LENGTH_NAME = "length";
- public static final String CACHED_BUFFER_NAME = "old_buffer";
- private static final String OVERLOADED_METHOD_PREFIX = "n";
+ public static final String TYPEDEF_POSTFIX = "PROC";
+ public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer";
+ public static final String FUNCTION_POINTER_POSTFIX = "_pointer";
+ public static final String CHECKS_CLASS_NAME = "GLChecks";
+ public static final String CONTEXT_CAPS_CLASS_NAME = "ContextCapabilities";
+ public static final String STUB_INITIALIZER_NAME = "initNativeStubs";
+ public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO";
+ public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset";
+ public static final String RESULT_SIZE_NAME = "result_size";
+ public static final String RESULT_VAR_NAME = "__result";
+ public static final String CACHED_BUFFER_LENGTH_NAME = "length";
+ public static final String CACHED_BUFFER_NAME = "old_buffer";
+ private static final String OVERLOADED_METHOD_PREFIX = "n";
public static String getTypedefName(MethodDeclaration method) {
Alternate alt_annotation = method.getAnnotation(Alternate.class);
@@ -102,6 +102,7 @@
}
private static class AnnotationMirrorComparator implements Comparator<AnnotationMirror> {
+
public int compare(AnnotationMirror a1, AnnotationMirror a2) {
String n1 = a1.getAnnotationType().getDeclaration().getQualifiedName();
String n2 = a2.getAnnotationType().getDeclaration().getQualifiedName();
@@ -148,22 +149,22 @@
private static boolean hasParameterMultipleTypes(ParameterDeclaration param) {
int num_native_annotations = 0;
- for (AnnotationMirror annotation : param.getAnnotationMirrors())
- if (NativeTypeTranslator.getAnnotation(annotation, NativeType.class) != null)
+ for ( AnnotationMirror annotation : param.getAnnotationMirrors() )
+ if ( NativeTypeTranslator.getAnnotation(annotation, NativeType.class) != null )
num_native_annotations++;
return num_native_annotations > 1;
}
public static boolean isParameterMultiTyped(ParameterDeclaration param) {
boolean result = Buffer.class.equals(Utils.getJavaType(param.getType()));
- if (!result && hasParameterMultipleTypes(param))
+ if ( !result && hasParameterMultipleTypes(param) )
throw new RuntimeException(param + " not defined as java.nio.Buffer but has multiple types");
return result;
}
public static ParameterDeclaration findParameter(MethodDeclaration method, String name) {
- for (ParameterDeclaration param : method.getParameters())
- if (param.getSimpleName().equals(name))
+ for ( ParameterDeclaration param : method.getParameters() )
+ if ( param.getSimpleName().equals(name) )
return param;
throw new RuntimeException("Parameter " + name + " not found");
}
@@ -176,7 +177,7 @@
overloadsComment = null;
String doc_comment = decl.getDocComment();
- if (doc_comment != null) {
+ if ( doc_comment != null ) {
final String tab = decl instanceof InterfaceDeclaration ? "" : "\t";
writer.println(tab + "/**");
@@ -187,7 +188,7 @@
final StringTokenizer doc_lines = new StringTokenizer(doc_comment, "\n", true);
boolean lastWasNL = false;
- while (doc_lines.hasMoreTokens()) {
+ while ( doc_lines.hasMoreTokens() ) {
final String t = doc_lines.nextToken();
if ( "\n".equals(t) ) {
if ( lastWasNL )
@@ -205,8 +206,8 @@
}
public static AnnotationMirror getParameterAutoAnnotation(ParameterDeclaration param) {
- for (AnnotationMirror annotation : param.getAnnotationMirrors())
- if (NativeTypeTranslator.getAnnotation(annotation, Auto.class) != null)
+ for ( AnnotationMirror annotation : param.getAnnotationMirrors() )
+ if ( NativeTypeTranslator.getAnnotation(annotation, Auto.class) != null )
return annotation;
return null;
}
@@ -242,9 +243,9 @@
public static ParameterDeclaration getResultParameter(MethodDeclaration method) {
ParameterDeclaration result_param = null;
- for (ParameterDeclaration param : method.getParameters()) {
- if (param.getAnnotation(Result.class) != null) {
- if (result_param != null)
+ for ( ParameterDeclaration param : method.getParameters() ) {
+ if ( param.getAnnotation(Result.class) != null ) {
+ if ( result_param != null )
throw new RuntimeException("Multiple parameters annotated with Result in method " + method);
result_param = param;
}
@@ -255,7 +256,7 @@
public static TypeMirror getMethodReturnType(MethodDeclaration method) {
TypeMirror result_type;
ParameterDeclaration result_param = getResultParameter(method);
- if (result_param != null) {
+ if ( result_param != null ) {
result_type = result_param.getType();
} else
result_type = method.getReturnType();
@@ -291,20 +292,20 @@
public static void printExtraCallArguments(PrintWriter writer, MethodDeclaration method, String size_parameter_name) {
writer.print(size_parameter_name);
- if (method.getAnnotation(CachedResult.class) != null) {
+ if ( method.getAnnotation(CachedResult.class) != null ) {
writer.print(", " + CACHED_BUFFER_NAME);
}
}
private static String getClassName(InterfaceDeclaration interface_decl, String opengl_name) {
Extension extension_annotation = interface_decl.getAnnotation(Extension.class);
- if (extension_annotation != null && !"".equals(extension_annotation.className())) {
+ if ( extension_annotation != null && !"".equals(extension_annotation.className()) ) {
return extension_annotation.className();
}
StringBuilder result = new StringBuilder();
- for (int i = 0; i < opengl_name.length(); i++) {
+ for ( int i = 0; i < opengl_name.length(); i++ ) {
int ch = opengl_name.codePointAt(i);
- if (ch == '_') {
+ if ( ch == '_' ) {
i++;
result.appendCodePoint(Character.toUpperCase(opengl_name.codePointAt(i)));
} else
@@ -314,8 +315,8 @@
}
public static boolean hasMethodBufferObjectParameter(MethodDeclaration method) {
- for (ParameterDeclaration param : method.getParameters()) {
- if (param.getAnnotation(BufferObject.class) != null) {
+ for ( ParameterDeclaration param : method.getParameters() ) {
+ if ( param.getAnnotation(BufferObject.class) != null ) {
return true;
}
}
@@ -332,7 +333,7 @@
public static Class<?> getNIOBufferType(TypeMirror t) {
Class<?> param_type = getJavaType(t);
- if (Buffer.class.isAssignableFrom(param_type))
+ if ( Buffer.class.isAssignableFrom(param_type) )
return param_type;
else if ( param_type == CharSequence.class || param_type == CharSequence[].class || param_type == PointerBuffer.class )
return ByteBuffer.class;
@@ -344,7 +345,7 @@
String method_name;
Alternate alt_annotation = method.getAnnotation(Alternate.class);
method_name = alt_annotation == null || alt_annotation.nativeAlt() ? method.getSimpleName() : alt_annotation.value();
- if (isMethodIndirect(generate_error_checks, context_specific, method))
+ if ( isMethodIndirect(generate_error_checks, context_specific, method) )
method_name = OVERLOADED_METHOD_PREFIX + method_name;
return method_name;
}
@@ -392,15 +393,15 @@
return offset;
}
- static void printGLReturnPre(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) {
+ static void printGLReturnPre(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation, TypeMap type_map) {
final String return_type = getMethodReturnType(method, return_annotation, true);
if ( "String".equals(return_type) ) {
if ( !return_annotation.forceMaxLength() ) {
- writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtil.getLengths();");
+ writer.println("IntBuffer " + return_annotation.value() + "_length = APIUtil.getLengths(" + type_map.getAPIUtilParam(false) + ");");
writer.print("\t\t");
}
- writer.print("ByteBuffer " + return_annotation.value() + " = APIUtil.getBufferByte(" + return_annotation.maxLength());
+ writer.print("ByteBuffer " + return_annotation.value() + " = APIUtil.getBufferByte(" + type_map.getAPIUtilParam(true) + return_annotation.maxLength());
/*
Params that use the return buffer will advance its position while filling it. When we return, the position will be
at the right spot for grabbing the returned string bytes. We only have to make sure that the original buffer was
@@ -412,9 +413,9 @@
writer.println(");");
} else {
final String buffer_type = "Boolean".equals(return_type) ? "Byte" : return_type;
- writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtil.getBuffer" + buffer_type + "(");
+ writer.print(buffer_type + "Buffer " + return_annotation.value() + " = APIUtil.getBuffer" + buffer_type + "(" + type_map.getAPIUtilParam(false));
if ( "Byte".equals(buffer_type) )
- writer.print('1');
+ writer.print((type_map.getAPIUtilParam(false).length() > 0 ? ", " : "") + "1");
writer.println(");");
}
@@ -426,20 +427,20 @@
writer.print("\t\t");
}
- static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation) {
+ static void printGLReturnPost(PrintWriter writer, MethodDeclaration method, GLreturn return_annotation, TypeMap type_map) {
final String return_type = getMethodReturnType(method, return_annotation, true);
if ( "String".equals(return_type) ) {
writer.print("\t\t" + return_annotation.value() + ".limit(");
final String offset = getStringOffset(method, null);
- if ( offset != null)
+ if ( offset != null )
writer.print(offset + " + ");
if ( return_annotation.forceMaxLength() )
writer.print(return_annotation.maxLength());
else
writer.print(return_annotation.value() + "_length.get(0)");
writer.println(");");
- writer.println("\t\treturn APIUtil.getString(" + return_annotation.value() + ");");
+ writer.println("\t\treturn APIUtil.getString(" + type_map.getAPIUtilParam(true) + return_annotation.value() + ");");
} else {
writer.print("\t\treturn " + return_annotation.value() + ".get(0)");
if ( "Boolean".equals(return_type) )
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/openal/ALTypeMap.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -178,6 +178,10 @@
throw new UnsupportedOperationException();
}
+ public String getAPIUtilParam(boolean comma) {
+ return "";
+ }
+
public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
writer.println(tabs + "Util.checkALError();");
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLTypeMap.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -89,6 +89,10 @@
return "CLCapabilities";
}
+ public String getAPIUtilParam(boolean comma) {
+ return "";
+ }
+
public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
final Check check = method.getAnnotation(Check.class);
if ( check != null ) // Get the error code from an IntBuffer output parameter
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -64,6 +64,7 @@
public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";");
+ writer.println("\tfinal APIUtil util = new APIUtil();");
writer.println("\tfinal StateTracker tracker = new StateTracker();");
writer.println();
if ( !context_specific ) {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLESTypeMap.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLESTypeMap.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLESTypeMap.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -97,6 +97,10 @@
return "caps";
}
+ public String getAPIUtilParam(boolean comma) {
+ return "";
+ }
+
public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
writer.println(tabs + "Util.checkGLError();");
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLTypeMap.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -106,6 +106,10 @@
return "caps";
}
+ public String getAPIUtilParam(boolean comma) {
+ return comma ? "caps, " : "caps";
+ }
+
public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
writer.println(tabs + "Util.checkGLError();");
}
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -58,7 +58,7 @@
void glDeleteNamesAMD(@GLenum int identifier, @AutoSize("names") @GLsizei int num, @Const @GLuint IntBuffer names);
@Alternate("glDeleteNamesAMD")
- void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtil.getInt(name)", keepParam = true) int name);
+ void glDeleteNamesAMD(@GLenum int identifier, @Constant("1") @GLsizei int num, @Constant(value = "APIUtil.getInt(caps, name)", keepParam = true) int name);
boolean glIsNameAMD(@GLenum int identifier, @GLuint int name);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -100,12 +100,12 @@
void glDeletePerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @GLuint IntBuffer monitors);
@Alternate("glDeletePerfMonitorsAMD")
- void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(monitor)", keepParam = true) int monitor);
+ void glDeletePerfMonitorsAMD(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, monitor)", keepParam = true) int monitor);
void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @AutoSize("counterList") int numCounters, @GLuint IntBuffer counterList);
@Alternate("glSelectPerfMonitorCountersAMD")
- void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getInt(counter)", keepParam = true) int counter);
+ void glSelectPerfMonitorCountersAMD(@GLuint int monitor, boolean enable, @GLuint int group, @Constant("1") int numCounters, @Constant(value = "APIUtil.getInt(caps, counter)", keepParam = true) int counter);
void glBeginPerfMonitorAMD(@GLuint int monitor);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -55,7 +55,7 @@
void glDeleteFencesAPPLE(@AutoSize("fences") @GLsizei int n, @Const @GLuint IntBuffer fences);
@Alternate("glDeleteFencesAPPLE")
- void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(fence)", keepParam = true) int fence);
+ void glDeleteFencesAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(caps, fence)", keepParam = true) int fence);
void glSetFenceAPPLE(@GLuint int fence);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -52,7 +52,7 @@
void glDeleteVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
@Alternate("glDeleteVertexArraysAPPLE")
- void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(array)", keepParam = true) int array);
+ void glDeleteVertexArraysAPPLE(@Constant("1") @GLsizei int n, @Const @GLuint @Constant(value = "APIUtil.getInt(caps, array)", keepParam = true) int array);
void glGenVertexArraysAPPLE(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -71,7 +71,7 @@
void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
@Alternate("glDeleteBuffersARB")
- void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer);
+ void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
void glGenBuffersARB(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -65,5 +65,5 @@
void glDrawBuffersARB(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
@Alternate("glDrawBuffersARB")
- void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer);
+ void glDrawBuffersARB(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
}
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -197,7 +197,7 @@
@Reuse("GL30")
@Alternate("glDeleteRenderbuffers")
- void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(renderbuffer)", keepParam = true) int renderbuffer);
+ void glDeleteRenderbuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, renderbuffer)", keepParam = true) int renderbuffer);
@Reuse("GL30")
void glGenRenderbuffers(@AutoSize("renderbuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer renderbuffers);
@@ -237,7 +237,7 @@
@Reuse("GL30")
@Alternate("glDeleteFramebuffers")
- void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(framebuffer)", keepParam = true) int framebuffer);
+ void glDeleteFramebuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, framebuffer)", keepParam = true) int framebuffer);
@Reuse("GL30")
void glGenFramebuffers(@AutoSize("framebuffers") @GLsizei int n, @OutParameter @GLuint IntBuffer framebuffers);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -68,7 +68,7 @@
void glDeleteQueriesARB(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
@Alternate("glDeleteQueriesARB")
- void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id);
+ void glDeleteQueriesARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id);
boolean glIsQueryARB(@GLuint int id);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -128,7 +128,7 @@
void glDeleteProgramsARB(@AutoSize("programs") @GLsizei int n, @Const @GLuint IntBuffer programs);
@Alternate("glDeleteProgramsARB")
- void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(program)", keepParam = true) int program);
+ void glDeleteProgramsARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, program)", keepParam = true) int program);
void glGenProgramsARB(@AutoSize("programs") @GLsizei int n, @OutParameter @GLuint IntBuffer programs);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -63,7 +63,7 @@
@Reuse("GL33")
@Alternate("glDeleteSamplers")
- void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getInt(sampler)", keepParam = true) int sampler);
+ void glDeleteSamplers(@Constant("1") @GLsizei int count, @Constant(value = "APIUtil.getInt(caps, sampler)", keepParam = true) int sampler);
@Reuse("GL33")
boolean glIsSampler(@GLuint int sampler);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -98,7 +98,7 @@
@Reuse("GL41")
@Alternate("glDeleteProgramPipelines")
- void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(pipeline)", keepParam = true) int pipeline);
+ void glDeleteProgramPipelines(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, pipeline)", keepParam = true) int pipeline);
@Reuse("GL41")
void glGenProgramPipelines(@AutoSize("pipelines") @GLsizei int n, @OutParameter @GLuint IntBuffer pipelines);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -110,7 +110,7 @@
@Alternate(value = "glShaderSourceARB", nativeAlt = true)
void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count,
@Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings,
- @Constant("APIUtil.getLengths(strings)") @Const IntBuffer length);
+ @Constant("APIUtil.getLengths(caps, strings)") @Const IntBuffer length);
void glCompileShaderARB(@GLhandleARB int shaderObj);
@@ -234,7 +234,7 @@
@Alternate(value = "glGetActiveUniformARB", javaAlt = true)
@GLreturn(value = "name", maxLength = "maxLength")
void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
- @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt()), MemoryUtil.getAddress(APIUtil.getBufferInt(), 1)") IntBuffer length,
+ @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
@OutParameter @GLcharARB ByteBuffer name);
/** Overloads glGetActiveUniformARB. This version returns only the uniform size. */
@@ -244,7 +244,7 @@
@OutParameter @GLsizei @Constant("0L") IntBuffer length,
@OutParameter IntBuffer size,
@OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
- @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0()") ByteBuffer name);
+ @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
/** Overloads glGetActiveUniformARB. This version returns only the uniform type. */
@Alternate(value = "glGetActiveUniformARB", javaAlt = true)
@@ -253,7 +253,7 @@
@OutParameter @GLsizei @Constant("0L") IntBuffer length,
@OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
@OutParameter @GLenum IntBuffer type,
- @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0()") ByteBuffer name);
+ @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
@StripPostfix("params")
void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -68,7 +68,7 @@
@Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true)
void glCompileShaderIncludeARB2(@GLuint int shader, @Constant("path.length") @GLsizei int count,
@Const @PointerArray(value = "count", lengths = "length") CharSequence[] path,
- @Constant("APIUtil.getLengths(path)") @Const IntBuffer length);
+ @Constant("APIUtil.getLengths(caps, path)") @Const IntBuffer length);
boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -61,7 +61,7 @@
@Reuse("GL40")
@Alternate("glDeleteTransformFeedbacks")
- void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id);
+ void glDeleteTransformFeedbacks(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id);
@Reuse("GL40")
void glGenTransformFeedbacks(@AutoSize("ids") @GLsizei int n, @OutParameter @GLuint IntBuffer ids);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -55,7 +55,7 @@
@Reuse("GL30")
@Alternate("glDeleteVertexArrays")
- void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(array)", keepParam = true) int array);
+ void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, array)", keepParam = true) int array);
@Reuse("GL30")
void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -170,7 +170,7 @@
@Alternate(value = "glGetActiveAttribARB", javaAlt = true)
@GLreturn(value = "name", maxLength = "maxLength")
void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength,
- @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt()), MemoryUtil.getAddress(APIUtil.getBufferInt(), 1)") IntBuffer length,
+ @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
@OutParameter @GLcharARB ByteBuffer name);
/** Overloads glGetActiveAttribARB. This version returns only the attrib size. */
@@ -180,7 +180,7 @@
@OutParameter @GLsizei @Constant("0L") IntBuffer length,
@OutParameter IntBuffer size,
@OutParameter @GLenum @Constant("MemoryUtil.getAddress(size, 1)") IntBuffer type, // Reuse size buffer and ignore
- @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0()") ByteBuffer name);
+ @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
/** Overloads glGetActiveAttribARB. This version returns only the attrib type. */
@Alternate(value = "glGetActiveAttribARB", javaAlt = true)
@@ -189,7 +189,7 @@
@OutParameter @GLsizei @Constant("0L") IntBuffer length,
@OutParameter @Constant("MemoryUtil.getAddress(type, 1)") IntBuffer size, // Reuse type buffer and ignore
@OutParameter @GLenum IntBuffer type,
- @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0()") ByteBuffer name);
+ @OutParameter @GLcharARB @Constant("APIUtil.getBufferByte0(caps)") ByteBuffer name);
int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -65,5 +65,5 @@
void glDrawBuffersATI(@AutoSize("buffers") @GLsizei int size, @Const @GLenum IntBuffer buffers);
@Alternate("glDrawBuffersATI")
- void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer);
+ void glDrawBuffersATI(@Constant("1") @GLsizei int size, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
}
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -1075,7 +1075,7 @@
@Alternate("glTextureParameterIivEXT")
@Dependent("GL_EXT_texture_integer")
@StripPostfix("param")
- void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param);
+ void glTextureParameterIivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
@Dependent("GL_EXT_texture_integer")
@StripPostfix("params")
@@ -1084,7 +1084,7 @@
@Alternate("glTextureParameterIuivEXT")
@Dependent("GL_EXT_texture_integer")
@StripPostfix("param")
- void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) @GLuint int param);
+ void glTextureParameterIuivEXT(@GLuint int texture, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) @GLuint int param);
@Dependent("GL_EXT_texture_integer")
@StripPostfix("params")
@@ -1119,7 +1119,7 @@
@Alternate("glMultiTexParameterIivEXT")
@Dependent("GL_EXT_texture_integer")
@StripPostfix("param")
- void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param);
+ void glMultiTexParameterIivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
@Dependent("GL_EXT_texture_integer")
@StripPostfix("params")
@@ -1128,7 +1128,7 @@
@Alternate("glMultiTexParameterIuivEXT")
@Dependent("GL_EXT_texture_integer")
@StripPostfix("param")
- void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param);
+ void glMultiTexParameterIuivEXT(@GLenum int texunit, @GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
@Dependent("GL_EXT_texture_integer")
@StripPostfix("params")
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -136,7 +136,7 @@
void glDeleteRenderbuffersEXT(@AutoSize("renderbuffers") int n, @Const @GLuint IntBuffer renderbuffers);
@Alternate("glDeleteRenderbuffersEXT")
- void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(renderbuffer)", keepParam = true) int renderbuffer);
+ void glDeleteRenderbuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(caps, renderbuffer)", keepParam = true) int renderbuffer);
void glGenRenderbuffersEXT(@AutoSize("renderbuffers") int n, @OutParameter @GLuint IntBuffer renderbuffers);
@@ -161,7 +161,7 @@
void glDeleteFramebuffersEXT(@AutoSize("framebuffers") int n, @Const @GLuint IntBuffer framebuffers);
@Alternate("glDeleteFramebuffersEXT")
- void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(framebuffer)", keepParam = true) int framebuffer);
+ void glDeleteFramebuffersEXT(@Constant("1") int n, @Constant(value = "APIUtil.getInt(caps, framebuffer)", keepParam = true) int framebuffer);
void glGenFramebuffersEXT(@AutoSize("framebuffers") int n, @OutParameter @GLuint IntBuffer framebuffers);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -118,14 +118,14 @@
@Alternate("glTexParameterIivEXT")
@StripPostfix(value = "param", postfix = "v")
- void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param);
+ void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
@StripPostfix("params")
void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params);
@Alternate("glTexParameterIuivEXT")
@StripPostfix(value = "param", postfix = "v")
- void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(param)", keepParam = true) int param);
+ void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Constant(value = "APIUtil.getInt(caps, param)", keepParam = true) int param);
@StripPostfix("params")
void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -784,7 +784,7 @@
void glDeleteTextures(@AutoSize("textures") @GLsizei int n, @Const @GLuint IntBuffer textures);
@Alternate("glDeleteTextures")
- void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(texture)", keepParam = true) int texture);
+ void glDeleteTextures(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, texture)", keepParam = true) int texture);
void glCullFace(@GLenum int mode);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -97,7 +97,7 @@
void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers);
@Alternate("glDeleteBuffers")
- void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(buffer)", keepParam = true) int buffer);
+ void glDeleteBuffers(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer);
void glGenBuffers(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers);
@@ -205,7 +205,7 @@
void glDeleteQueries(@AutoSize("ids") @GLsizei int n, @GLuint IntBuffer ids);
@Alternate("glDeleteQueries")
- void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(id)", keepParam = true) int id);
+ void glDeleteQueries(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, id)", keepParam = true) int id);
boolean glIsQuery(@GLuint int id);
Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java 2011-07-16 19:40:16 UTC (rev 3592)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java 2011-07-16 22:26:46 UTC (rev 3593)
@@ -108,7 +108,7 @@
@Alternate(value = "glShaderSource", nativeAlt = true)
void glShaderSource3(@GLuint int shader, @Constant("strings.length") @GLsizei int count,
@Const @PointerArray(value = "count", lengths = "length") CharSequence[] strings,
- @Constant("APIUtil.getLengths(strings)") @Const IntBuffer length);
+ @Constant("APIUtil.getLengths(caps, strings)") @Const IntBuffer length);
int glCreateShader(@GLuint int type);
@@ -257,7 +257,7 @@
@Alternate(value = "glGetActiveUniform", javaAlt = true)
@GLreturn(value = "name", maxLength = "maxLength")
void glGetActiveUniform(@GLuint int program, @GLuint int index, @GLsizei int maxLength,
- @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt()), MemoryUtil.getAddress(APIUtil.getBufferInt(), 1)") IntBuffer length,
+ @OutParameter @GLsizei @Constant("MemoryUtil.getAddress0(name_length), MemoryUtil.getAddress0(APIUtil.getBufferInt(caps)), MemoryUtil.getAddress(APIUtil.getBufferInt(caps), 1)") IntBuffer length,
@OutParameter @GLchar ByteBuffer name);
/** Overloads glGetActiveUniform. This version returns only the uniform size. */
@@ -267,7 +267,7 @@
@OutParameter @GLsizei @Constant("0L") IntBuffer length,
...
[truncated message content] |
|
From: <sp...@us...> - 2011-07-16 19:40:23
|
Revision: 3592
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3592&view=rev
Author: spasi
Date: 2011-07-16 19:40:16 +0000 (Sat, 16 Jul 2011)
Log Message:
-----------
Removed test code. /fail
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java
Modified: trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-07-16 16:59:46 UTC (rev 3591)
+++ trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-07-16 19:40:16 UTC (rev 3592)
@@ -49,8 +49,7 @@
Accessor util;
try {
// Depends on java.nio.Buffer#address and sun.misc.Unsafe
- //util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe");
- util = new AccessorJNI();
+ util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe");
} catch (Exception e0) {
try {
// Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-16 16:59:53
|
Revision: 3591
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3591&view=rev
Author: spasi
Date: 2011-07-16 16:59:46 +0000 (Sat, 16 Jul 2011)
Log Message:
-----------
Pointer cast warning fix.
Modified Paths:
--------------
trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_CallbackUtil.c
Modified: trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_CallbackUtil.c
===================================================================
--- trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_CallbackUtil.c 2011-07-16 16:42:51 UTC (rev 3590)
+++ trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_CallbackUtil.c 2011-07-16 16:59:46 UTC (rev 3591)
@@ -45,11 +45,11 @@
static jmethodID debugOutputCallbackAMDJ;
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) {
- return (jlong)(*env)->NewGlobalRef(env, obj);
+ return (jlong)(intptr_t)(*env)->NewGlobalRef(env, obj);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_CallbackUtil_deleteGlobalRef(JNIEnv *env, jclass clazz, jlong globalRef) {
- (*env)->DeleteGlobalRef(env, (jobject)globalRef);
+ (*env)->DeleteGlobalRef(env, (jobject)(intptr_t)globalRef);
}
// ----------------- [ ARB_debug_output ] -----------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-16 16:42:59
|
Revision: 3590
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3590&view=rev
Author: spasi
Date: 2011-07-16 16:42:51 +0000 (Sat, 16 Jul 2011)
Log Message:
-----------
More java-side pointer arithmetic.
Fixed pointer cast warning.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java
trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java
trunk/LWJGL/src/java/org/lwjgl/opengles/EGL.java
trunk/LWJGL/src/java/org/lwjgl/opengles/EGLKHRFenceSync.java
trunk/LWJGL/src/java/org/lwjgl/opengles/EGLNVSync.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java
trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGL.c
trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGLKHRFenceSync.c
trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGLNVSync.c
trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c
trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c
Modified: trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java 2011-07-16 16:42:51 UTC (rev 3590)
@@ -37,6 +37,7 @@
import org.lwjgl.BufferChecks;
import org.lwjgl.LWJGLException;
+import org.lwjgl.MemoryUtil;
/**
*
@@ -180,10 +181,10 @@
*/
public static void alcGetInteger(ALCdevice device, int pname, IntBuffer integerdata) {
BufferChecks.checkDirect(integerdata);
- nalcGetIntegerv(getDevice(device), pname, integerdata.remaining(), integerdata, integerdata.position());
+ nalcGetIntegerv(getDevice(device), pname, integerdata.remaining(), MemoryUtil.getAddress(integerdata));
Util.checkALCError(device);
}
- static native void nalcGetIntegerv(long device, int pname, int size, Buffer integerdata, int offset);
+ static native void nalcGetIntegerv(long device, int pname, int size, long integerdata);
/**
* The <code>alcOpenDevice</code> function allows the application (i.e. the client program) to
@@ -246,7 +247,7 @@
* @return New context, or null if creation failed
*/
public static ALCcontext alcCreateContext(ALCdevice device, IntBuffer attrList) {
- long context_address = nalcCreateContext(getDevice(device), attrList);
+ long context_address = nalcCreateContext(getDevice(device), MemoryUtil.getAddressSafe(attrList));
Util.checkALCError(device);
if(context_address != 0) {
@@ -259,7 +260,7 @@
}
return null;
}
- static native long nalcCreateContext(long device, IntBuffer attrList);
+ static native long nalcCreateContext(long device, long attrList);
/**
* To make a Context current with respect to AL Operation (state changes by issueing
Modified: trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java 2011-07-16 16:42:51 UTC (rev 3590)
@@ -37,8 +37,8 @@
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
+import org.lwjgl.MemoryUtil;
-
/**
* <p>
* The ALC11 class implements features in OpenAL 1.1, specifically
@@ -162,9 +162,9 @@
* @param samples Number of samples to request
*/
public static void alcCaptureSamples(ALCdevice device, ByteBuffer buffer, int samples ) {
- nalcCaptureSamples(ALC10.getDevice(device), buffer, buffer.position(), samples);
+ nalcCaptureSamples(ALC10.getDevice(device), MemoryUtil.getAddress(buffer), samples);
}
- static native void nalcCaptureSamples(long device, ByteBuffer buffer, int position, int samples );
+ static native void nalcCaptureSamples(long device, long buffer, int samples );
static native void initNativeStubs() throws LWJGLException;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengles/EGL.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengles/EGL.java 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/java/org/lwjgl/opengles/EGL.java 2011-07-16 16:42:51 UTC (rev 3590)
@@ -33,9 +33,9 @@
import org.lwjgl.BufferChecks;
import org.lwjgl.LWJGLException;
+import org.lwjgl.MemoryUtil;
import org.lwjgl.PointerBuffer;
-import java.nio.ByteBuffer;
import java.nio.IntBuffer;
/** EGL wrapper class. */
@@ -266,11 +266,11 @@
static void eglInitialize(EGLDisplay dpy, IntBuffer version) throws LWJGLException {
//LWJGLUtil.log("eglInitialize");
BufferChecks.checkBuffer(version, 2);
- if ( !neglInitialize(dpy.getPointer(), version, version.position()) )
+ if ( !neglInitialize(dpy.getPointer(), MemoryUtil.getAddress(version)) )
throwEGLError("Failed to initialize EGL display.");
}
- private static native boolean neglInitialize(long dpy_ptr, IntBuffer version, int version_position);
+ private static native boolean neglInitialize(long dpy_ptr, long version);
/**
* Release the resources associated with the specified EGL display.
@@ -314,7 +314,7 @@
//LWJGLUtil.log("eglGetConfigsNum");
IntBuffer num_config = APIUtil.getBufferInt();
- if ( !neglGetConfigs(dpy.getPointer(), null, 0, 0, num_config, num_config.position()) )
+ if ( !neglGetConfigs(dpy.getPointer(), 0L, 0, MemoryUtil.getAddress0(num_config)) )
throwEGLError("Failed to get EGL configs.");
return num_config.get(0);
@@ -340,14 +340,14 @@
BufferChecks.checkBuffer(num_config, 1);
if ( configs == null ) {
- if ( !neglGetConfigs(dpy.getPointer(), null, 0, 0, num_config, num_config.position()) )
+ if ( !neglGetConfigs(dpy.getPointer(), 0L, 0, MemoryUtil.getAddress(num_config)) )
throwEGLError("Failed to get number of available EGL configs.");
configs = new EGLConfig[num_config.get(num_config.position())];
}
final PointerBuffer configs_buffer = APIUtil.getBufferPointer(configs.length);
- if ( !neglGetConfigs(dpy.getPointer(), configs_buffer.getBuffer(), 0, configs.length, num_config, num_config.position()) )
+ if ( !neglGetConfigs(dpy.getPointer(), MemoryUtil.getAddress0(configs_buffer), configs.length, MemoryUtil.getAddress(num_config)) )
throwEGLError("Failed to get EGL configs.");
final int config_size = num_config.get(num_config.position());
@@ -357,7 +357,7 @@
return configs;
}
- private static native boolean neglGetConfigs(long dpy_ptr, ByteBuffer configs, int configs_position, int config_size, IntBuffer num_config, int num_config_position);
+ private static native boolean neglGetConfigs(long dpy_ptr, long configs, int config_size, long num_config);
/**
* Returns the number of EGLConfigs that are available on the specified display and
@@ -376,7 +376,7 @@
checkAttribList(attrib_list);
IntBuffer num_config = APIUtil.getBufferInt();
- if ( !neglChooseConfig(dpy.getPointer(), attrib_list, attrib_list == null ? 0 : attrib_list.position(), null, 0, 0, num_config, num_config.position()) )
+ if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), 0L, 0, MemoryUtil.getAddress0(num_config)) )
throwEGLError("Failed to get EGL configs.");
return num_config.get(0);
@@ -405,7 +405,7 @@
int config_size;
if ( configs == null ) {
- if ( !neglChooseConfig(dpy.getPointer(), attrib_list, attrib_list == null ? 0 : attrib_list.position(), null, 0, 0, num_config, num_config.position()) )
+ if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), 0L, 0, MemoryUtil.getAddress(num_config)) )
throwEGLError("Failed to get number of available EGL configs.");
config_size = num_config.get(num_config.position());
@@ -414,7 +414,7 @@
//LWJGLUtil.log("config_size = " + config_size);
PointerBuffer configs_buffer = APIUtil.getBufferPointer(config_size);
- if ( !neglChooseConfig(dpy.getPointer(), attrib_list, attrib_list == null ? 0 : attrib_list.position(), configs_buffer.getBuffer(), 0, config_size, num_config, num_config.position()) )
+ if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), MemoryUtil.getAddress0(configs_buffer), config_size, MemoryUtil.getAddress(num_config)) )
throwEGLError("Failed to choose EGL config.");
// Get the true number of configurations (the first neglChooseConfig call may return more than the second)
@@ -427,7 +427,7 @@
return configs;
}
- private static native boolean neglChooseConfig(long dpy_ptr, IntBuffer attrib_list, int attrib_list_position, ByteBuffer configs, int configs_position, int config_size, IntBuffer num_config, int num_config_position);
+ private static native boolean neglChooseConfig(long dpy_ptr, long attrib_list, long configs, int config_size, long num_config);
/**
* Returns the value of an EGL config attribute.
@@ -442,13 +442,13 @@
//LWJGLUtil.log("eglGetConfigAttrib");
final IntBuffer value = APIUtil.getBufferInt();
- if ( !neglGetConfigAttrib(dpy.getPointer(), config.getPointer(), attribute, value, value.position()) )
+ if ( !neglGetConfigAttrib(dpy.getPointer(), config.getPointer(), attribute, MemoryUtil.getAddress(value)) )
throwEGLError("Failed to get EGL config attribute.");
return value.get(0);
}
- private static native boolean neglGetConfigAttrib(long dpy_ptr, long config_ptr, int attribute, IntBuffer value, int value_position);
+ private static native boolean neglGetConfigAttrib(long dpy_ptr, long config_ptr, int attribute, long value);
/**
* Creates an on-screen rendering surface on the specified EGL display.
@@ -465,7 +465,7 @@
static EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, long win, IntBuffer attrib_list) throws LWJGLException {
//LWJGLUtil.log("eglCreateWindowSurface");
checkAttribList(attrib_list);
- final long pointer = neglCreateWindowSurface(dpy.getPointer(), config.getPointer(), win, attrib_list, attrib_list == null ? 0 : attrib_list.position());
+ final long pointer = neglCreateWindowSurface(dpy.getPointer(), config.getPointer(), win, MemoryUtil.getAddressSafe(attrib_list));
if ( pointer == EGL_NO_SURFACE )
throwEGLError("Failed to create EGL window surface.");
@@ -473,7 +473,7 @@
return new EGLSurface(dpy, config, pointer);
}
- private static native long neglCreateWindowSurface(long dpy_ptr, long config_ptr, long win, IntBuffer attrib_list, int attrib_list_position);
+ private static native long neglCreateWindowSurface(long dpy_ptr, long config_ptr, long win, long attrib_list);
/**
* Creates an off-screen rendering surface on the specified EGL display.
@@ -489,7 +489,7 @@
static EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, IntBuffer attrib_list) throws LWJGLException {
//LWJGLUtil.log("eglCreatePbufferSurface");
checkAttribList(attrib_list);
- final long pointer = neglCreatePbufferSurface(dpy.getPointer(), config.getPointer(), attrib_list, attrib_list == null ? 0 : attrib_list.position());
+ final long pointer = neglCreatePbufferSurface(dpy.getPointer(), config.getPointer(), MemoryUtil.getAddressSafe(attrib_list));
if ( pointer == EGL_NO_SURFACE )
throwEGLError("Failed to create EGL pbuffer surface.");
@@ -497,7 +497,7 @@
return new EGLSurface(dpy, config, pointer);
}
- private static native long neglCreatePbufferSurface(long dpy_ptr, long config_ptr, IntBuffer attrib_list, int attrib_list_position);
+ private static native long neglCreatePbufferSurface(long dpy_ptr, long config_ptr, long attrib_list);
/*
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
@@ -550,11 +550,11 @@
public static void eglQuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, IntBuffer value) throws LWJGLException {
//LWJGLUtil.log("eglQuerySurface");
BufferChecks.checkBuffer(value, 1);
- if ( !neglQuerySurface(dpy.getPointer(), surface.getPointer(), attribute, value, value.position()) )
+ if ( !neglQuerySurface(dpy.getPointer(), surface.getPointer(), attribute, MemoryUtil.getAddress(value)) )
throwEGLError("Failed to query surface attribute.");
}
- private static native boolean neglQuerySurface(long dpy_ptr, long surface_ptr, int attribute, IntBuffer value, int value_position);
+ private static native boolean neglQuerySurface(long dpy_ptr, long surface_ptr, int attribute, long value);
/**
* Binds the specified rendering API to the current thread.
@@ -627,7 +627,7 @@
checkAttribList(attrib_list);
final long pointer = neglCreateContext(dpy.getPointer(), config.getPointer(),
share_context == null ? EGL_NO_CONTEXT : share_context.getPointer(),
- attrib_list, attrib_list == null ? 0 : attrib_list.position());
+ MemoryUtil.getAddressSafe(attrib_list));
if ( pointer == EGL_NO_CONTEXT )
throwEGLError("Failed to create EGL context.");
@@ -635,7 +635,7 @@
return new EGLContext(dpy, config, pointer);
}
- private static native long neglCreateContext(long dpy_ptr, long config_ptr, long share_context_ptr, IntBuffer attrib_list, int attrib_list_position);
+ private static native long neglCreateContext(long dpy_ptr, long config_ptr, long share_context_ptr, long attrib_list);
/**
* Destroys a rendering context.
@@ -714,7 +714,7 @@
// Query context's CONFIG_ID
final IntBuffer attrib_list = APIUtil.getBufferInt();
- neglQueryContext(display.getPointer(), ctx, EGL_CONFIG_ID, attrib_list, 0);
+ neglQueryContext(display.getPointer(), ctx, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list));
final EGLConfig config = getEGLConfig(display, attrib_list);
@@ -761,7 +761,7 @@
// Query context's CONFIG_ID
final IntBuffer attrib_list = APIUtil.getBufferInt();
- if ( !neglQuerySurface(display.getPointer(), surface, EGL_CONFIG_ID, attrib_list, 0) )
+ if ( !neglQuerySurface(display.getPointer(), surface, EGL_CONFIG_ID, MemoryUtil.getAddress0(attrib_list)) )
throwEGLError("Failed to query surface EGL config ID.");
final EGLConfig config = getEGLConfig(display, attrib_list);
@@ -799,11 +799,11 @@
public static void eglQueryContext(EGLDisplay dpy, EGLContext ctx, int attribute, IntBuffer value) throws LWJGLException {
//LWJGLUtil.log("eglQueryContext");
BufferChecks.checkBuffer(value, 1);
- if ( !neglQueryContext(dpy.getPointer(), ctx.getPointer(), attribute, value, value.position()) )
+ if ( !neglQueryContext(dpy.getPointer(), ctx.getPointer(), attribute, MemoryUtil.getAddress(value)) )
throwEGLError("Failed to query context attribute.");
}
- private static native boolean neglQueryContext(long dpy_ptr, long ctx_ptr, int attribute, IntBuffer value, int value_position);
+ private static native boolean neglQueryContext(long dpy_ptr, long ctx_ptr, int attribute, long value);
/**
* Prevents native rendering API functions from executing until any
@@ -883,7 +883,7 @@
attrib_list.put(0, EGL_CONFIG_ID).put(1, configID).put(2, EGL_NONE);
final PointerBuffer configs_buffer = APIUtil.getBufferPointer(1);
- if ( !neglChooseConfig(dpy.getPointer(), attrib_list, attrib_list.position(), configs_buffer.getBuffer(), 0, 1, attrib_list, attrib_list.position() + 3) )
+ if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddress(attrib_list), MemoryUtil.getAddress0(configs_buffer), 1, MemoryUtil.getAddress(attrib_list, 3)) )
throwEGLError("Failed to choose EGL config.");
return new EGLConfig(dpy, configs_buffer.get(0));
Modified: trunk/LWJGL/src/java/org/lwjgl/opengles/EGLKHRFenceSync.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengles/EGLKHRFenceSync.java 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/java/org/lwjgl/opengles/EGLKHRFenceSync.java 2011-07-16 16:42:51 UTC (rev 3590)
@@ -32,6 +32,7 @@
package org.lwjgl.opengles;
import org.lwjgl.LWJGLException;
+import org.lwjgl.MemoryUtil;
import java.nio.IntBuffer;
@@ -102,7 +103,7 @@
public static EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, int type, IntBuffer attrib_list) throws LWJGLException {
checkAttribList(attrib_list);
- final long pointer = neglCreateSyncKHR(dpy.getPointer(), type, attrib_list, attrib_list == null ? 0 : attrib_list.position());
+ final long pointer = neglCreateSyncKHR(dpy.getPointer(), type, MemoryUtil.getAddressSafe(attrib_list));
if ( pointer == EGL_NO_SYNC_KHR )
throwEGLError("Failed to create KHR fence sync object.");
@@ -110,7 +111,7 @@
return new EGLSyncKHR(pointer);
}
- private static native long neglCreateSyncKHR(long dpy_ptr, int type, IntBuffer attrib_list, int attrib_list_position);
+ private static native long neglCreateSyncKHR(long dpy_ptr, int type, long attrib_list);
/**
* Destroys an existing sync object.
@@ -162,12 +163,12 @@
public static int eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, int attribute) throws LWJGLException {
final IntBuffer value = APIUtil.getBufferInt();
- if ( !neglGetSyncAttribKHR(dpy.getPointer(), sync.getPointer(), attribute, value, value.position()) )
+ if ( !neglGetSyncAttribKHR(dpy.getPointer(), sync.getPointer(), attribute, MemoryUtil.getAddress(value)) )
throwEGLError("Failed to get KHR fence sync object attribute.");
return value.get(0);
}
- private static native boolean neglGetSyncAttribKHR(long dpy_ptr, long sync_ptr, int attribute, IntBuffer value, int value_position);
+ private static native boolean neglGetSyncAttribKHR(long dpy_ptr, long sync_ptr, int attribute, long value);
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/opengles/EGLNVSync.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengles/EGLNVSync.java 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/java/org/lwjgl/opengles/EGLNVSync.java 2011-07-16 16:42:51 UTC (rev 3590)
@@ -32,6 +32,7 @@
package org.lwjgl.opengles;
import org.lwjgl.LWJGLException;
+import org.lwjgl.MemoryUtil;
import java.nio.IntBuffer;
@@ -112,7 +113,7 @@
public static EGLSyncNV eglCreateFenceSyncNV(EGLDisplay dpy, int condition, IntBuffer attrib_list) throws LWJGLException {
checkAttribList(attrib_list);
- final long pointer = neglCreateFenceSyncNV(dpy.getPointer(), condition, attrib_list, attrib_list == null ? 0 : attrib_list.position());
+ final long pointer = neglCreateFenceSyncNV(dpy.getPointer(), condition, MemoryUtil.getAddressSafe(attrib_list));
if ( pointer == EGL_NO_SYNC_NV )
throwEGLError("Failed to create NV fence sync object.");
@@ -120,7 +121,7 @@
return new EGLSyncNV(pointer);
}
- private static native long neglCreateFenceSyncNV(long dpy_ptr, int condition, IntBuffer attrib_list, int attrib_list_position);
+ private static native long neglCreateFenceSyncNV(long dpy_ptr, int condition, long attrib_list);
/**
* Destroys an existing sync object.
@@ -203,12 +204,12 @@
public static int eglGetSyncAttribNV(EGLSyncNV sync, int attribute) throws LWJGLException {
final IntBuffer value = APIUtil.getBufferInt();
- if ( !neglGetSyncAttribNV(sync.getPointer(), attribute, value, 0) )
+ if ( !neglGetSyncAttribNV(sync.getPointer(), attribute, MemoryUtil.getAddress0(value)) )
throwEGLError("Failed to get NV fence sync object attribute.");
return value.get(0);
}
- private static native boolean neglGetSyncAttribNV(long sync_ptr, int attribute, IntBuffer value, int value_position);
+ private static native boolean neglGetSyncAttribNV(long sync_ptr, int attribute, long value);
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java 2011-07-16 16:42:51 UTC (rev 3590)
@@ -298,7 +298,7 @@
writer.print("\t" + native_type + param.getSimpleName());
writer.print(BUFFER_ADDRESS_POSTFIX + " = (");
writer.print(native_type);
- writer.print(")");
+ writer.print(")(intptr_t)");
if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + ")");
Modified: trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGL.c
===================================================================
--- trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGL.c 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGL.c 2011-07-16 16:42:51 UTC (rev 3590)
@@ -43,9 +43,9 @@
return (intptr_t)eglGetDisplay((EGLNativeDisplayType)(intptr_t)display_id);
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglInitialize(JNIEnv *env, jclass clazz, jlong dpy_ptr, jobject version, jint version_position) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglInitialize(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong version) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
- EGLint *version_address = ((EGLint *)(*env)->GetDirectBufferAddress(env, version)) + version_position;
+ EGLint *version_address = (EGLint *)(intptr_t)version;
return eglInitialize(dpy, version_address, version_address + 1);
}
@@ -65,43 +65,43 @@
return NewStringNativeWithLength(env, __result, strlen(__result));
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglGetConfigs(JNIEnv *env, jclass clazz, jlong dpy_ptr, jobject configs, jint configs_position, jint config_size, jobject num_config, jint num_config_position) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglGetConfigs(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong configs, jint config_size, jlong num_config) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
- EGLConfig *configs_address = ((EGLConfig *)safeGetBufferAddress(env, configs)) + configs_position;
- EGLint *num_config_address = ((EGLint *)(*env)->GetDirectBufferAddress(env, num_config)) + num_config_position;
+ EGLConfig *configs_address = (EGLConfig *)(intptr_t)configs;
+ EGLint *num_config_address = (EGLint *)(intptr_t)num_config;
return eglGetConfigs(dpy, configs_address, config_size, num_config_address);
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglChooseConfig(JNIEnv *env, jclass clazz, jlong dpy_ptr, jobject attrib_list, jint attrib_list_position, jobject configs, jint configs_position, jint config_size, jobject num_config, jint num_config_position) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglChooseConfig(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong attrib_list, jlong configs, jint config_size, jlong num_config) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
- const EGLint *attrib_list_address = ((EGLint *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position;
- EGLConfig *configs_address = ((EGLConfig *)safeGetBufferAddress(env, configs)) + configs_position;
- EGLint *num_config_address = ((EGLint *)(*env)->GetDirectBufferAddress(env, num_config)) + num_config_position;
+ const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
+ EGLConfig *configs_address = (EGLConfig *)(intptr_t)configs;
+ EGLint *num_config_address = (EGLint *)(intptr_t)num_config;
return eglChooseConfig(dpy, attrib_list_address, configs_address, config_size, num_config_address);
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglGetConfigAttrib(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jint attribute, jobject value, jint value_position) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglGetConfigAttrib(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jint attribute, jlong value) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
- EGLint *value_address = ((EGLint *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
+ EGLint *value_address = (EGLint *)(intptr_t)value;
return eglGetConfigAttrib(dpy, config, attribute, value_address);
}
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateWindowSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong win, jobject attrib_list, jint attrib_list_position) {
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateWindowSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong win, jlong attrib_list) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
- const EGLint *attrib_list_address = ((EGLint *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position;
+ const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
return (intptr_t)eglCreateWindowSurface(dpy, config, (EGLNativeWindowType)(intptr_t)win, attrib_list_address);
}
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreatePbufferSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jobject attrib_list, jint attrib_list_position) {
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreatePbufferSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong attrib_list) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
- const EGLint *attrib_list_address = ((EGLint *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position;
+ const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
return (intptr_t)eglCreatePbufferSurface(dpy, config, attrib_list_address);
}
@@ -120,10 +120,10 @@
return eglSurfaceAttrib(dpy, surface, attribute, value);
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglQuerySurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong surface_ptr, jint attribute, jobject value, jint value_position) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglQuerySurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong surface_ptr, jint attribute, jlong value) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
EGLSurface surface = (EGLSurface)(intptr_t)surface_ptr;
- EGLint *value_address = ((EGLint *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
+ EGLint *value_address = (EGLint *)(intptr_t)value;
return eglQuerySurface(dpy, surface, attribute, value_address);
}
@@ -145,11 +145,11 @@
return eglSwapInterval(dpy, interval);
}
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateContext(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong share_context_ptr, jobject attrib_list, jint attrib_list_position) {
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateContext(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong share_context_ptr, jlong attrib_list) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
EGLContext share_context = (EGLContext)(intptr_t)share_context_ptr;
- const EGLint *attrib_list_address = ((EGLint *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position;
+ const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
return (intptr_t)eglCreateContext(dpy, config, share_context, attrib_list_address);
}
@@ -182,10 +182,10 @@
return (intptr_t)eglGetCurrentDisplay();
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglQueryContext(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong ctx_ptr, jint attribute, jobject value, jint value_position) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglQueryContext(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong ctx_ptr, jint attribute, jlong value) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
EGLContext ctx = (EGLContext)(intptr_t)ctx_ptr;
- EGLint *value_address = ((EGLint *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
+ EGLint *value_address = (EGLint *)(intptr_t)value;
return eglQueryContext(dpy, ctx, attribute, value_address);
Modified: trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGLKHRFenceSync.c
===================================================================
--- trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGLKHRFenceSync.c 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGLKHRFenceSync.c 2011-07-16 16:42:51 UTC (rev 3590)
@@ -40,9 +40,9 @@
static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
static PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglCreateSyncKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jint type, jobject attrib_list, jint attrib_list_position) {
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglCreateSyncKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jint type, jlong attrib_list) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
- const EGLint *attrib_list_address = ((EGLint *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position;
+ const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
return (intptr_t)eglCreateSyncKHR(dpy, type, attrib_list_address);
}
@@ -61,20 +61,20 @@
return eglClientWaitSyncKHR(dpy, sync, flags, timeout);
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglGetSyncAttribKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong sync_ptr, jint attribute, jobject value, jint value_position) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_neglGetSyncAttribKHR(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong sync_ptr, jint attribute, jlong value) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
EGLSyncKHR sync = (EGLSyncKHR)(intptr_t)sync_ptr;
- EGLint *value_address = ((EGLint *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
+ EGLint *value_address = (EGLint *)(intptr_t)value;
return eglGetSyncAttribKHR(dpy, sync, attribute, value_address);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EGLKHRFenceSync_initNativeStubs(JNIEnv *env, jclass clazz) {
JavaMethodAndExtFunction functions[] = {
- {"neglCreateSyncKHR", "(JILjava/nio/IntBuffer;I)J", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglCreateSyncKHR, "eglCreateSyncKHR", (void *)&eglCreateSyncKHR},
+ {"neglCreateSyncKHR", "(JIJ)J", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglCreateSyncKHR, "eglCreateSyncKHR", (void *)&eglCreateSyncKHR},
{"neglDestroySyncKHR", "(JJ)Z", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglDestroySyncKHR, "eglDestroySyncKHR", (void *)&eglDestroySyncKHR},
{"neglClientWaitSyncKHR", "(JJIJ)I", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglClientWaitSyncKHR, "eglClientWaitSyncKHR", (void *)&eglClientWaitSyncKHR},
- {"neglGetSyncAttribKHR", "(JJILjava/nio/IntBuffer;I)Z", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglGetSyncAttribKHR, "eglGetSyncAttribKHR", (void *)&eglGetSyncAttribKHR}
+ {"neglGetSyncAttribKHR", "(JJIJ)Z", (void *)&Java_org_lwjgl_opengles_EGLKHRFenceSync_neglGetSyncAttribKHR, "eglGetSyncAttribKHR", (void *)&eglGetSyncAttribKHR}
};
int num_functions = NUMFUNCTIONS(functions);
extgl_InitializeClass(env, clazz, num_functions, functions);
Modified: trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGLNVSync.c
===================================================================
--- trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGLNVSync.c 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/native/common/opengles/org_lwjgl_opengles_EGLNVSync.c 2011-07-16 16:42:51 UTC (rev 3590)
@@ -42,9 +42,9 @@
static PFNEGLSIGNALSYNCNVPROC eglSignalSyncNV;
static PFNEGLGETSYNCATTRIBNVPROC eglGetSyncAttribNV;
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglCreateFenceSyncNV(JNIEnv *env, jclass clazz, jlong dpy_ptr, jint condition, jobject attrib_list, jint attrib_list_position) {
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglCreateFenceSyncNV(JNIEnv *env, jclass clazz, jlong dpy_ptr, jint condition, jlong attrib_list) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
- const EGLint *attrib_list_address = ((EGLint *)safeGetBufferAddress(env, attrib_list)) + attrib_list_position;
+ const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;
return (intptr_t)eglCreateFenceSyncNV(dpy, condition, attrib_list_address);
}
@@ -73,21 +73,21 @@
return eglSignalSyncNV(sync, mode);
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglGetSyncAttribNV(JNIEnv *env, jclass clazz, jlong sync_ptr, jint attribute, jobject value, jint value_position) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGLNVSync_neglGetSyncAttribNV(JNIEnv *env, jclass clazz, jlong sync_ptr, jint attribute, jlong value) {
EGLSyncNV sync = (EGLSyncNV)(intptr_t)sync_ptr;
- EGLint *value_address = ((EGLint *)(*env)->GetDirectBufferAddress(env, value)) + value_position;
+ EGLint *value_address = (EGLint *)(intptr_t)value;
return eglGetSyncAttribNV(sync, attribute, value_address);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EGLNVSync_initNativeStubs(JNIEnv *env, jclass clazz) {
JavaMethodAndExtFunction functions[] = {
- {"neglCreateFenceSyncNV", "(JILjava/nio/IntBuffer;I)J", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglCreateFenceSyncNV, "eglCreateFenceSyncNV", (void *)&eglCreateFenceSyncNV},
+ {"neglCreateFenceSyncNV", "(JIJ)J", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglCreateFenceSyncNV, "eglCreateFenceSyncNV", (void *)&eglCreateFenceSyncNV},
{"neglDestroySyncNV", "(J)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglDestroySyncNV, "eglDestroySyncNV", (void *)&eglDestroySyncNV},
{"neglFenceNV", "(J)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglFenceNV, "eglFenceNV", (void *)&eglFenceNV},
{"neglClientWaitSyncNV", "(JIJ)I", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglClientWaitSyncNV, "eglClientWaitSyncNV", (void *)&eglClientWaitSyncNV},
{"neglSignalSyncNV", "(JI)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglSignalSyncNV, "eglSignalSyncNV", (void *)&eglSignalSyncNV},
- {"neglGetSyncAttribNV", "(JILjava/nio/IntBuffer;I)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglGetSyncAttribNV, "eglGetSyncAttribNV", (void *)&eglGetSyncAttribNV}
+ {"neglGetSyncAttribNV", "(JIJ)Z", (void *)&Java_org_lwjgl_opengles_EGLNVSync_neglGetSyncAttribNV, "eglGetSyncAttribNV", (void *)&eglGetSyncAttribNV}
};
int num_functions = NUMFUNCTIONS(functions);
extgl_InitializeClass(env, clazz, num_functions, functions);
Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c
===================================================================
--- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2011-07-16 16:42:51 UTC (rev 3590)
@@ -1,40 +1,40 @@
-/*
+/*
* 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
+ * modification, are permitted provided that the following conditions are
* met:
- *
- * * Redistributions of source code must retain the above copyright
+ *
+ * * 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
+ * * 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
+ * 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
+ * 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.
*/
-
+
/**
* $Id: org_lwjgl_openal_ALC.c 2279 2006-02-23 19:22:00Z elias_naur $
*
- * This is the actual JNI implementation of the OpenAL context/device library.
- *
+ * This is the actual JNI implementation of the OpenAL context/device library.
+ *
* @author Brian Matzon <br...@ma...>
* @version $Revision: 2279 $
*/
@@ -103,8 +103,8 @@
break;
}
case 0x1013: // ALC_ALL_DEVICES_SPECIFIER
- while (alcString[i - 1] != '\0' || alcString[i] != '\0') {
- i++;
+ while (alcString[i - 1] != '\0' || alcString[i] != '\0') {
+ i++;
}
length = i + 1;
break;
@@ -116,21 +116,18 @@
/**
* This function returns integers related to the context.
- *
+ *
* C Specification:
* ALvoid alcGetIntegerv(ALCdevice *device, ALenum token, ALsizei size, ALint *dest);
*/
-static void JNICALL Java_org_lwjgl_openal_ALC10_nalcGetIntegerv (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token, jint size, jobject dest, jint offset) {
- ALint* address = NULL;
- if (dest != NULL) {
- address = offset + (ALint*) (*env)->GetDirectBufferAddress(env, dest);
- }
- alcGetIntegerv((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token, (ALsizei) size, address);
+static void JNICALL Java_org_lwjgl_openal_ALC10_nalcGetIntegerv (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token, jint size, jlong dest) {
+ ALint* dest_address = (ALint*)(intptr_t)dest;
+ alcGetIntegerv((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token, (ALsizei) size, dest_address);
}
/**
* This function opens a device by name.
- *
+ *
* C Specification:
* ALCdevice *alcOpenDevice( const ALubyte *tokstr );
*/
@@ -156,7 +153,7 @@
/**
* This function closes a device by name.
- *
+ *
* C Specification:
* bool alcCloseDevice( ALCdevice *dev );
*/
@@ -166,19 +163,16 @@
/**
* This function creates a context using a specified device.
- *
+ *
* C Specification:
* ALCcontext* alcCreateContext( ALCdevice *dev, ALint* attrlist );
*/
-static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jobject attrlist) {
- ALint* address = NULL;
+static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jlong attrlist) {
+ ALint* attrlist_address = (ALint*)(intptr_t)attrlist;
ALCcontext* context;
- if (attrlist != NULL) {
- address = (ALint*) safeGetBufferAddress(env, attrlist);
- }
- context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), address);
-
+ context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), attrlist_address);
+
return (jlong)((intptr_t)context);
}
@@ -195,7 +189,7 @@
/**
* This function tells a context to begin processing.
- *
+ *
* C Specification:
* void alcProcessContext(ALCcontext *context);
*/
@@ -205,7 +199,7 @@
/**
* This function retrieves the current context.
- *
+ *
* C Specification:
* ALCcontext* alcGetCurrentContext( ALvoid );
*/
@@ -216,7 +210,7 @@
/**
* This function retrieves the specified contexts device
- *
+ *
* C Specification:
* ALCdevice* alcGetContextsDevice(ALCcontext *context);
*/
@@ -237,7 +231,7 @@
/**
* This function destroys a context.
- *
+ *
* C Specification:
* void alcDestroyContext(ALCcontext *context);
*/
@@ -247,7 +241,7 @@
/**
* This function retrieves the specified devices context error state.
- *
+ *
* C Specification:
* ALCenum alcGetError(ALCdevice *device);
*/
@@ -257,18 +251,18 @@
/**
* This function queries if a specified context extension is available.
- *
+ *
* C Specification:
* ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName);
*/
static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring extName) {
/* get extension */
ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName);
-
+
jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), functionname);
-
+
free(functionname);
-
+
return result;
}
@@ -278,14 +272,14 @@
* C Specification:
* ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName);
*/
-static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring enumName) {
+static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring enumName) {
/* get extension */
ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName);
-
+
jint result = (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), enumerationname);
-
+
free(enumerationname);
-
+
return result;
}
Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c
===================================================================
--- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c 2011-07-16 16:05:37 UTC (rev 3589)
+++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c 2011-07-16 16:42:51 UTC (rev 3590)
@@ -1,40 +1,40 @@
-/*
+/*
* 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
+ * modification, are permitted provided that the following conditions are
* met:
- *
- * * Redistributions of source code must retain the above copyright
+ *
+ * * 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
+ * * 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
+ * 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
+ * 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.
*/
-
+
/**
* $Id: org_lwjgl_openal_ALC.c 2279 2006-02-23 19:22:00Z elias_naur $
*
- * This is the actual JNI implementation of the OpenAL context/device library.
- *
+ * This is the actual JNI implementation of the OpenAL context/device library.
+ *
* @author Brian Matzon <br...@ma...>
* @version $Revision: 2279 $
*/
@@ -106,8 +106,8 @@
* Method: nalcCaptureSamples
* Signature: (JLjava/nio/ByteBuffer;I)V
*/
-static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureSamples(JNIEnv *env, jclass clazz, jlong device, jobject buffer, jint position, jint samples) {
- ALvoid *buffer_address = ((ALbyte *)(((char*)(*env)->GetDirectBufferAddress(env, buffer)) + position));
+static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureSamples(JNIEnv *env, jclass clazz, jlong device, jlong buffer, jint samples) {
+ ALvoid *buffer_address = (ALbyte *)(intptr_t)buffer;
alcCaptureSamples((ALCdevice*) ((intptr_t)device), buffer_address, samples);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-16 16:05:47
|
Revision: 3589
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3589&view=rev
Author: spasi
Date: 2011-07-16 16:05:37 +0000 (Sat, 16 Jul 2011)
Log Message:
-----------
Moved all pointer arithmetic to Java code.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/PointerBuffer.java
trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java
trunk/LWJGL/src/java/org/lwjgl/opencl/InfoUtilFactory.java
trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java
trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout2P.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutCL.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/JNITypeTranslator.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java
trunk/LWJGL/src/templates/org/lwjgl/opencl/CL10.java
trunk/LWJGL/src/templates/org/lwjgl/opencl/CL10GL.java
trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_migrate_memobject.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_name_gen_delete.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_fence.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/APPLE_vertex_array_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_draw_buffers.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_framebuffer_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sampler_objects.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_transform_feedback2.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_array_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_draw_buffers.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_direct_state_access.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL30.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL31.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL32.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL33.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL40.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/GL41.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_fence.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_occlusion_query.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_program.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback.java
trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback2.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/AMD_performance_monitor.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/ARB_draw_buffers.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/GLES20.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_draw_buffers.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_fence.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/OES_framebuffer_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/OES_vertex_array_object.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/QCOM_driver_control.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java
trunk/LWJGL/src/java/org/lwjgl/MemoryUtilSun.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/StreamVBO.java
Added: trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2002-2011 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;
+
+import java.lang.reflect.Field;
+import java.nio.*;
+
+/**
+ * [INTERNAL USE ONLY]
+ * <p/>
+ * This class provides utility methods for passing buffer addresses to JNI API calls.
+ *
+ * @author Spasi
+ */
+public final class MemoryUtil {
+
+ private static final Accessor memUtil;
+
+ static {
+ Accessor util;
+ try {
+ // Depends on java.nio.Buffer#address and sun.misc.Unsafe
+ //util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe");
+ util = new AccessorJNI();
+ } catch (Exception e0) {
+ try {
+ // Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor
+ util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorReflectFast");
+ } catch (Exception e1) {
+ try {
+ // Depends on java.nio.Buffer#address
+ util = new AccessorReflect();
+ } catch (Exception e2) {
+ LWJGLUtil.log("Unsupported JVM detected, this will likely result in low performance. Please inform LWJGL developers.");
+ util = new AccessorJNI();
+ }
+ }
+ }
+
+ LWJGLUtil.log("MemoryUtil Accessor: " + util.getClass().getSimpleName());
+ memUtil = util;
+
+ /*
+ BENCHMARK RESULTS - Oracle Server VM:
+
+ Unsafe: 4ns
+ ReflectFast: 8ns
+ Reflect: 10ns
+ JNI: 82ns
+
+ BENCHMARK RESULTS - Oracle Client VM:
+
+ Unsafe: 5ns
+ ReflectFast: 81ns
+ Reflect: 85ns
+ JNI: 87ns
+
+ On non-Oracle VMs, Unsafe should be the fastest implementation as well. In the absence
+ of Unsafe, performance will depend on how reflection and JNI are implemented. For now
+ we'll go with what we see on the Oracle VM (that is, we'll prefer reflection over JNI).
+ */
+ }
+
+ private MemoryUtil() {
+ }
+
+ public static String wrap(final String test) {
+ return "MemoryUtil.getAddress(" + test + ")";
+ }
+
+ /**
+ * Returns the memory address of the specified buffer. [INTERNAL USE ONLY]
+ *
+ * @param buffer the buffer
+ *
+ * @return the memory address
+ */
+ public static long getAddress0(Buffer buffer) { return memUtil.getAddress(buffer); }
+
+ public static long getAddress0Safe(Buffer buffer) { return buffer == null ? 0L : memUtil.getAddress(buffer); }
+
+ public static long getAddress0(PointerBuffer buffer) { return memUtil.getAddress(buffer.getBuffer()); }
+
+ public static long getAddress0Safe(PointerBuffer buffer) { return buffer == null ? 0L : memUtil.getAddress(buffer.getBuffer()); }
+
+ // --- [ API utilities ] ---
+
+ public static long getAddress(ByteBuffer buffer) { return getAddress(buffer, buffer.position()); }
+
+ public static long getAddress(ByteBuffer buffer, int position) { return getAddress0(buffer) + position; }
+
+ public static long getAddress(ShortBuffer buffer) { return getAddress(buffer, buffer.position()); }
+
+ public static long getAddress(ShortBuffer buffer, int position) { return getAddress0(buffer) + (position << 1); }
+
+ public static long getAddress(CharBuffer buffer) { return getAddress(buffer, buffer.position()); }
+
+ public static long getAddress(CharBuffer buffer, int position) { return getAddress0(buffer) + (position << 1); }
+
+ public static long getAddress(IntBuffer buffer) { return getAddress(buffer, buffer.position()); }
+
+ public static long getAddress(IntBuffer buffer, int position) { return getAddress0(buffer) + (position << 2); }
+
+ public static long getAddress(FloatBuffer buffer) { return getAddress(buffer, buffer.position()); }
+
+ public static long getAddress(FloatBuffer buffer, int position) { return getAddress0(buffer) + (position << 2); }
+
+ public static long getAddress(LongBuffer buffer) { return getAddress(buffer, buffer.position()); }
+
+ public static long getAddress(LongBuffer buffer, int position) { return getAddress0(buffer) + (position << 3); }
+
+ public static long getAddress(DoubleBuffer buffer) { return getAddress(buffer, buffer.position()); }
+
+ public static long getAddress(DoubleBuffer buffer, int position) { return getAddress0(buffer) + (position << 3); }
+
+ public static long getAddress(PointerBuffer buffer) { return getAddress(buffer, buffer.position()); }
+
+ public static long getAddress(PointerBuffer buffer, int position) { return getAddress0(buffer) + (position * PointerBuffer.getPointerSize()); }
+
+ // --- [ API utilities - Safe ] ---
+
+ public static long getAddressSafe(ByteBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
+
+ public static long getAddressSafe(ByteBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+
+ public static long getAddressSafe(ShortBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
+
+ public static long getAddressSafe(ShortBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+
+ public static long getAddressSafe(CharBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
+
+ public static long getAddressSafe(CharBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+
+ public static long getAddressSafe(IntBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
+
+ public static long getAddressSafe(IntBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+
+ public static long getAddressSafe(FloatBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
+
+ public static long getAddressSafe(FloatBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+
+ public static long getAddressSafe(LongBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
+
+ public static long getAddressSafe(LongBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+
+ public static long getAddressSafe(DoubleBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
+
+ public static long getAddressSafe(DoubleBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+
+ public static long getAddressSafe(PointerBuffer buffer) { return buffer == null ? 0L : getAddress(buffer); }
+
+ public static long getAddressSafe(PointerBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+
+ interface Accessor {
+
+ long getAddress(Buffer buffer);
+
+ }
+
+ private static Accessor loadAccessor(final String className) throws Exception {
+ return (Accessor)Class.forName(className).newInstance();
+ }
+
+ /** Default implementation. */
+ private static class AccessorJNI implements Accessor {
+
+ public long getAddress(final Buffer buffer) {
+ return BufferUtils.getBufferAddress(buffer);
+ }
+
+ }
+
+ /** Implementation using reflection on ByteBuffer. */
+ private static class AccessorReflect implements Accessor {
+
+ private final Field address;
+
+ AccessorReflect() {
+ try {
+ address = getAddressField();
+ } catch (NoSuchFieldException e) {
+ throw new UnsupportedOperationException(e);
+ }
+ address.setAccessible(true);
+ }
+
+ public long getAddress(final Buffer buffer) {
+ try {
+ return address.getLong(buffer);
+ } catch (IllegalAccessException e) {
+ // cannot happen
+ return 0L;
+ }
+ }
+
+ }
+
+ static Field getAddressField() throws NoSuchFieldException {
+ return getDeclaredFieldRecursive(ByteBuffer.class, "address");
+ }
+
+ private static Field getDeclaredFieldRecursive(Class<?> type, final String fieldName) throws NoSuchFieldException {
+ while ( type != null ) {
+ try {
+ return type.getDeclaredField(fieldName);
+ } catch (NoSuchFieldException e) {
+ type = type.getSuperclass();
+ }
+ }
+
+ throw new NoSuchFieldException(fieldName + " does not exist in " + type.getSimpleName() + " or any of its superclasses.");
+ }
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/MemoryUtilSun.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/MemoryUtilSun.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/MemoryUtilSun.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2002-2011 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;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.nio.Buffer;
+
+import sun.misc.Unsafe;
+import sun.reflect.FieldAccessor;
+
+/**
+ * MemoryUtil.Accessor implementations that depend on sun.misc.
+ * We use reflection to grab these, so that we can compile on JDKs
+ * that do not support sun.misc.
+ *
+ * @author Spasi
+ */
+final class MemoryUtilSun {
+
+ private MemoryUtilSun() {
+ }
+
+ /** Implementation using sun.misc.Unsafe. */
+ private static class AccessorUnsafe implements MemoryUtil.Accessor {
+
+ private final Unsafe unsafe;
+ private final long address;
+
+ AccessorUnsafe() {
+ try {
+ unsafe = getUnsafeInstance();
+ address = unsafe.objectFieldOffset(MemoryUtil.getAddressField());
+ } catch (Exception e) {
+ throw new UnsupportedOperationException(e);
+ }
+ }
+
+ public long getAddress(final Buffer buffer) {
+ return unsafe.getLong(buffer, address);
+ }
+
+ private static Unsafe getUnsafeInstance() {
+ final Field[] fields = Unsafe.class.getDeclaredFields();
+
+ /*
+ Different runtimes use different names for the Unsafe singleton,
+ so we cannot use .getDeclaredField and we scan instead. For example:
+
+ Oracle: theUnsafe
+ PERC : m_unsafe_instance
+ Android: THE_ONE
+ */
+ for ( Field field : fields ) {
+ if ( !field.getType().equals(Unsafe.class) )
+ continue;
+
+ final int modifiers = field.getModifiers();
+ if ( !(Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers)) )
+ continue;
+
+ field.setAccessible(true);
+ try {
+ return (Unsafe)field.get(null);
+ } catch (IllegalAccessException e) {
+ // ignore
+ }
+ break;
+ }
+
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+ /** Implementation using reflection on ByteBuffer, FieldAccessor is used directly. */
+ private static class AccessorReflectFast implements MemoryUtil.Accessor {
+
+ private final FieldAccessor addressAccessor;
+
+ AccessorReflectFast() {
+ Field address;
+ try {
+ address = MemoryUtil.getAddressField();
+ } catch (NoSuchFieldException e) {
+ throw new UnsupportedOperationException(e);
+ }
+ address.setAccessible(true);
+
+ try {
+ Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class);
+ m.setAccessible(true);
+ addressAccessor = (FieldAccessor)m.invoke(address, true);
+ } catch (Exception e) {
+ throw new UnsupportedOperationException(e);
+ }
+ }
+
+ public long getAddress(final Buffer buffer) {
+ return addressAccessor.getLong(buffer);
+ }
+
+ }
+
+}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/PointerBuffer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/PointerBuffer.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/PointerBuffer.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -99,7 +99,7 @@
throw new IllegalArgumentException("The source buffer is not direct.");
final int alignment = is64Bit ? 8 : 4;
- if ( (BufferUtils.getBufferAddress(source) + source.position()) % alignment != 0 || source.remaining() % alignment != 0 )
+ if ( (MemoryUtil.getAddress0(source) + source.position()) % alignment != 0 || source.remaining() % alignment != 0 )
throw new IllegalArgumentException("The source buffer is not aligned to " + alignment + " bytes.");
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -31,9 +31,7 @@
*/
package org.lwjgl.opencl;
-import org.lwjgl.BufferUtils;
-import org.lwjgl.LWJGLUtil;
-import org.lwjgl.PointerBuffer;
+import org.lwjgl.*;
import org.lwjgl.opencl.FastLongMap.Entry;
import java.nio.*;
@@ -53,7 +51,7 @@
*/
final class APIUtil {
- private static final int INITIAL_BUFFER_SIZE = 256;
+ private static final int INITIAL_BUFFER_SIZE = 256;
private static final int INITIAL_LENGTHS_SIZE = 4;
private static final int BUFFERS_SIZE = 32;
@@ -223,10 +221,10 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence string) {
+ static long getBuffer(final CharSequence string) {
final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -236,10 +234,10 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence string, final int offset) {
+ static long getBuffer(final CharSequence string, final int offset) {
final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress(buffer);
}
/**
@@ -249,11 +247,11 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBufferNT(final CharSequence string) {
+ static long getBufferNT(final CharSequence string) {
final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
buffer.put((byte)0);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
static int getTotalLength(final CharSequence[] strings) {
@@ -271,14 +269,14 @@
*
* @return the Strings as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence[] strings) {
+ static long getBuffer(final CharSequence[] strings) {
final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
for ( CharSequence string : strings )
encode(buffer, string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -288,7 +286,7 @@
*
* @return the Strings as a ByteBuffer
*/
- static ByteBuffer getBufferNT(final CharSequence[] strings) {
+ static long getBufferNT(final CharSequence[] strings) {
final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
for ( CharSequence string : strings ) {
@@ -297,7 +295,7 @@
}
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -307,14 +305,14 @@
*
* @return the String lengths in a PointerBuffer
*/
- static PointerBuffer getLengths(final CharSequence[] strings) {
+ static long getLengths(final CharSequence[] strings) {
PointerBuffer buffer = getLengths(strings.length);
for ( CharSequence string : strings )
buffer.put(string.length());
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -324,14 +322,14 @@
*
* @return the buffer lengths in a PointerBuffer
*/
- static PointerBuffer getLengths(final ByteBuffer[] buffers) {
+ static long getLengths(final ByteBuffer[] buffers) {
PointerBuffer lengths = getLengths(buffers.length);
for ( ByteBuffer buffer : buffers )
lengths.put(buffer.remaining());
lengths.flip();
- return lengths;
+ return MemoryUtil.getAddress0(lengths);
}
static int getSize(final PointerBuffer lengths) {
@@ -342,14 +340,22 @@
return (int)size;
}
+ static long getPointer(final PointerWrapper pointer) {
+ return MemoryUtil.getAddress0(getBufferPointer().put(0, pointer));
+ }
+
+ static long getPointerSafe(final PointerWrapper pointer) {
+ return MemoryUtil.getAddress0(getBufferPointer().put(0, pointer == null ? 0L : pointer.getPointer()));
+ }
+
private static class Buffers {
final ShortBuffer shorts;
- final IntBuffer ints;
- final IntBuffer intsDebug;
- final LongBuffer longs;
+ final IntBuffer ints;
+ final IntBuffer intsDebug;
+ final LongBuffer longs;
- final FloatBuffer floats;
+ final FloatBuffer floats;
final DoubleBuffer doubles;
final PointerBuffer pointers;
@@ -513,25 +519,25 @@
}
}
- private static final ObjectDestructor<CLDevice> DESTRUCTOR_CLSubDevice = new ObjectDestructor<CLDevice>() {
+ private static final ObjectDestructor<CLDevice> DESTRUCTOR_CLSubDevice = new ObjectDestructor<CLDevice>() {
public void release(final CLDevice object) { clReleaseDeviceEXT(object); }
};
- private static final ObjectDestructor<CLMem> DESTRUCTOR_CLMem = new ObjectDestructor<CLMem>() {
+ private static final ObjectDestructor<CLMem> DESTRUCTOR_CLMem = new ObjectDestructor<CLMem>() {
public void release(final CLMem object) { clReleaseMemObject(object); }
};
private static final ObjectDestructor<CLCommandQueue> DESTRUCTOR_CLCommandQueue = new ObjectDestructor<CLCommandQueue>() {
public void release(final CLCommandQueue object) { clReleaseCommandQueue(object); }
};
- private static final ObjectDestructor<CLSampler> DESTRUCTOR_CLSampler = new ObjectDestructor<CLSampler>() {
+ private static final ObjectDestructor<CLSampler> DESTRUCTOR_CLSampler = new ObjectDestructor<CLSampler>() {
public void release(final CLSampler object) { clReleaseSampler(object); }
};
- private static final ObjectDestructor<CLProgram> DESTRUCTOR_CLProgram = new ObjectDestructor<CLProgram>() {
+ private static final ObjectDestructor<CLProgram> DESTRUCTOR_CLProgram = new ObjectDestructor<CLProgram>() {
public void release(final CLProgram object) { clReleaseProgram(object); }
};
- private static final ObjectDestructor<CLKernel> DESTRUCTOR_CLKernel = new ObjectDestructor<CLKernel>() {
+ private static final ObjectDestructor<CLKernel> DESTRUCTOR_CLKernel = new ObjectDestructor<CLKernel>() {
public void release(final CLKernel object) { clReleaseKernel(object); }
};
- private static final ObjectDestructor<CLEvent> DESTRUCTOR_CLEvent = new ObjectDestructor<CLEvent>() {
+ private static final ObjectDestructor<CLEvent> DESTRUCTOR_CLEvent = new ObjectDestructor<CLEvent>() {
public void release(final CLEvent object) { clReleaseEvent(object); }
};
Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/InfoUtilFactory.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opencl/InfoUtilFactory.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/opencl/InfoUtilFactory.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -118,7 +118,7 @@
final long user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);
CLContext __result = null;
try {
- __result = new CLContext(nclCreateContext(properties.getBuffer(), 0, devices.size(), properties.getBuffer(), propertyCount, pfn_notify == null ? 0 : pfn_notify.getPointer(), user_data, errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), platform);
+ __result = new CLContext(nclCreateContext(MemoryUtil.getAddress0(properties.getBuffer()), devices.size(), MemoryUtil.getAddress(properties, propertyCount), pfn_notify == null ? 0 : pfn_notify.getPointer(), user_data, MemoryUtil.getAddressSafe(errcode_ret), function_pointer), platform);
if ( LWJGLUtil.DEBUG )
Util.checkCLError(errcode_ret.get(0));
return __result;
@@ -304,9 +304,9 @@
else if ( LWJGLUtil.DEBUG )
errcode_ret = APIUtil.getBufferInt();
- CLMem __result = new CLMem(nclCreateImage2D(context.getPointer(), flags, formatBuffer, 0, image_width, image_height, image_row_pitch, host_ptr,
- host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(formatBuffer, image_width, image_height, image_row_pitch)) : 0,
- errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), context);
+ CLMem __result = new CLMem(nclCreateImage2D(context.getPointer(), flags, MemoryUtil.getAddress(formatBuffer, 0), image_width, image_height, image_row_pitch, MemoryUtil.getAddress0Safe(host_ptr) +
+ (host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(formatBuffer, image_width, image_height, image_row_pitch)) : 0),
+ MemoryUtil.getAddressSafe(errcode_ret), function_pointer), context);
if ( LWJGLUtil.DEBUG )
Util.checkCLError(errcode_ret.get(0));
return __result;
@@ -324,9 +324,9 @@
else if ( LWJGLUtil.DEBUG )
errcode_ret = APIUtil.getBufferInt();
- CLMem __result = new CLMem(nclCreateImage3D(context.getPointer(), flags, formatBuffer, 0, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, host_ptr,
- host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0,
- errcode_ret, errcode_ret != null ? errcode_ret.position() : 0, function_pointer), context);
+ CLMem __result = new CLMem(nclCreateImage3D(context.getPointer(), flags, MemoryUtil.getAddress(formatBuffer, 0), image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, MemoryUtil.getAddress0Safe(host_ptr) +
+ (host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0),
+ MemoryUtil.getAddressSafe(errcode_ret), function_pointer), context);
if ( LWJGLUtil.DEBUG )
Util.checkCLError(errcode_ret.get(0));
return __result;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -33,6 +33,7 @@
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLUtil;
+import org.lwjgl.MemoryUtil;
import java.nio.*;
@@ -185,10 +186,10 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence string) {
+ static long getBuffer(final CharSequence string) {
final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -198,10 +199,10 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence string, final int offset) {
+ static long getBuffer(final CharSequence string, final int offset) {
final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress(buffer);
}
/**
@@ -211,11 +212,11 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBufferNT(final CharSequence string) {
+ static long getBufferNT(final CharSequence string) {
final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
buffer.put((byte)0);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
static int getTotalLength(final CharSequence[] strings) {
@@ -233,14 +234,14 @@
*
* @return the Strings as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence[] strings) {
+ static long getBuffer(final CharSequence[] strings) {
final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
for ( CharSequence string : strings )
encode(buffer, string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -250,7 +251,7 @@
*
* @return the Strings as a ByteBuffer
*/
- static ByteBuffer getBufferNT(final CharSequence[] strings) {
+ static long getBufferNT(final CharSequence[] strings) {
final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
for ( CharSequence string : strings ) {
@@ -259,7 +260,7 @@
}
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -269,16 +270,24 @@
*
* @return the String lengths in an IntBuffer
*/
- static IntBuffer getLengths(final CharSequence[] strings) {
+ static long getLengths(final CharSequence[] strings) {
IntBuffer buffer = getLengths(strings.length);
for ( CharSequence string : strings )
buffer.put(string.length());
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
+ static long getInt(final int value) {
+ return MemoryUtil.getAddress0(getBufferInt().put(0, value));
+ }
+
+ static long getBufferByte0() {
+ return MemoryUtil.getAddress0(getBufferByte(0));
+ }
+
private static class Buffers {
final ShortBuffer shorts;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -33,6 +33,7 @@
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLUtil;
+import org.lwjgl.MemoryUtil;
import org.lwjgl.PointerBuffer;
import java.nio.ByteBuffer;
@@ -207,10 +208,10 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence string) {
+ static long getBuffer(final CharSequence string) {
final ByteBuffer buffer = encode(getBufferByte(string.length()), string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -220,10 +221,10 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence string, final int offset) {
+ static long getBuffer(final CharSequence string, final int offset) {
final ByteBuffer buffer = encode(getBufferByteOffset(offset + string.length()), string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress(buffer);
}
/**
@@ -233,11 +234,11 @@
*
* @return the String as a ByteBuffer
*/
- static ByteBuffer getBufferNT(final CharSequence string) {
+ static long getBufferNT(final CharSequence string) {
final ByteBuffer buffer = encode(getBufferByte(string.length() + 1), string);
buffer.put((byte)0);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
static int getTotalLength(final CharSequence[] strings) {
@@ -255,14 +256,14 @@
*
* @return the Strings as a ByteBuffer
*/
- static ByteBuffer getBuffer(final CharSequence[] strings) {
+ static long getBuffer(final CharSequence[] strings) {
final ByteBuffer buffer = getBufferByte(getTotalLength(strings));
for ( CharSequence string : strings )
encode(buffer, string);
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -272,7 +273,7 @@
*
* @return the Strings as a ByteBuffer
*/
- static ByteBuffer getBufferNT(final CharSequence[] strings) {
+ static long getBufferNT(final CharSequence[] strings) {
final ByteBuffer buffer = getBufferByte(getTotalLength(strings) + strings.length);
for ( CharSequence string : strings ) {
@@ -281,7 +282,7 @@
}
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
/**
@@ -291,16 +292,24 @@
*
* @return the String lengths in an IntBuffer
*/
- static IntBuffer getLengths(final CharSequence[] strings) {
+ static long getLengths(final CharSequence[] strings) {
IntBuffer buffer = getLengths(strings.length);
for ( CharSequence string : strings )
buffer.put(string.length());
buffer.flip();
- return buffer;
+ return MemoryUtil.getAddress0(buffer);
}
+ static long getInt(final int value) {
+ return MemoryUtil.getAddress(getBufferInt().put(0, value), 0);
+ }
+
+ static long getBufferByte0() {
+ return MemoryUtil.getAddress0(getBufferByte(0));
+ }
+
private static class Buffers {
final ShortBuffer shorts;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -118,6 +118,10 @@
set.view = 0;
assert (vec2.view == 0);
assert (vec3.view == 0);
+
+ set.next();
+ assert (vec2.view == 1);
+ assert (vec3.view == 1);
}
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2002-2011 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.sprites;
import org.lwjgl.BufferUtils;
@@ -33,8 +64,8 @@
*/
public final class SpriteShootout {
- private static final int SCREEN_WIDTH = 800;
- private static final int SCREEN_HEIGHT = 600;
+ static final int SCREEN_WIDTH = 800;
+ static final int SCREEN_HEIGHT = 600;
private static final int ANIMATION_TICKS = 60;
@@ -45,8 +76,8 @@
private boolean smooth;
private boolean vsync;
- private int ballSize = 42;
- private int ballCount = 100 * 1000;
+ int ballSize = 42;
+ int ballCount = 100 * 1000;
private SpriteRenderer renderer;
@@ -401,43 +432,45 @@
transform = newTransform;
}
- protected void animate(final FloatBuffer geom, final int ballIndex, final int batchSize, final int delta) {
- final float[] transform = this.transform;
-
+ protected void animate(
+ final float[] sprites,
+ final FloatBuffer spritesRender,
+ final int ballSize, final int ballIndex, final int batchSize, final int delta
+ ) {
final float ballRadius = ballSize * 0.5f;
final float boundW = SCREEN_WIDTH - ballRadius;
final float boundH = SCREEN_HEIGHT - ballRadius;
for ( int b = ballIndex * 4, len = (ballIndex + batchSize) * 4; b < len; b += 4 ) {
- float x = transform[b + 0];
- float dx = transform[b + 2];
+ float x = sprites[b + 0];
+ float dx = sprites[b + 2];
x += dx * delta;
if ( x < ballRadius ) {
x = ballRadius;
- transform[b + 2] = -dx;
+ sprites[b + 2] = -dx;
} else if ( x > boundW ) {
x = boundW;
- transform[b + 2] = -dx;
+ sprites[b + 2] = -dx;
}
- transform[b + 0] = x;
+ sprites[b + 0] = x;
- float y = transform[b + 1];
- float dy = transform[b + 3];
+ float y = sprites[b + 1];
+ float dy = sprites[b + 3];
y += dy * delta;
if ( y < ballRadius ) {
y = ballRadius;
- transform[b + 3] = -dy;
+ sprites[b + 3] = -dy;
} else if ( y > boundH ) {
y = boundH;
- transform[b + 3] = -dy;
+ sprites[b + 3] = -dy;
}
- transform[b + 1] = y;
+ sprites[b + 1] = y;
- geom.put(x).put(y);
+ spritesRender.put(x).put(y);
}
- geom.clear();
+ spritesRender.clear();
}
protected abstract void render(boolean render, boolean animate, int delta);
@@ -517,8 +550,9 @@
}
private void animate(final int ballIndex, final int batchSize, final int delta) {
- animate(geom, ballIndex, batchSize, delta);
+ animate(transform, geom, ballSize, ballIndex, batchSize, delta);
+ // Orphan current buffer and allocate a new one
glBufferData(GL_ARRAY_BUFFER, geom.capacity() * 4, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, geom);
}
@@ -526,11 +560,8 @@
private class SpriteRendererMapped extends SpriteRendererBatched {
- private ByteBuffer[] mapBuffer;
- private FloatBuffer[] geomBuffer;
+ private StreamVBO animVBO;
- protected int animVBO;
-
SpriteRendererMapped() {
System.out.println("Shootout Implementation: CPU animation & MapBufferRange");
}
@@ -538,41 +569,29 @@
public void updateBalls(final int count) {
super.updateBalls(count);
- final int batchCount = count / BALLS_PER_BATCH + (count % BALLS_PER_BATCH == 0 ? 0 : 1);
- mapBuffer = new ByteBuffer[batchCount];
- geomBuffer = new FloatBuffer[batchCount];
+ if ( animVBO != null )
+ animVBO.destroy();
- animVBO = glGenBuffers();
- glBindBuffer(GL_ARRAY_BUFFER, animVBO);
- glBufferData(GL_ARRAY_BUFFER, ballCount * (2 * 4), GL_DYNAMIC_DRAW);
- glVertexPointer(2, GL_FLOAT, 0, 0);
+ animVBO = new StreamVBO(GL_ARRAY_BUFFER, ballCount * (2 * 4));
}
public void render(final boolean render, final boolean animate, final int delta) {
int batchSize = Math.min(ballCount, BALLS_PER_BATCH);
int ballIndex = 0;
- int batchIndex = 0;
while ( ballIndex < ballCount ) {
if ( animate ) {
- final ByteBuffer buffer = glMapBufferRange(GL_ARRAY_BUFFER,
- ballIndex * (2 * 4),
- batchSize * (2 * 4),
- GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT,
- mapBuffer[batchIndex]);
- if ( buffer != mapBuffer[batchIndex] ) {
- mapBuffer[batchIndex] = buffer;
- geomBuffer[batchIndex] = mapBuffer[batchIndex].asFloatBuffer();
- }
+ final ByteBuffer buffer = animVBO.map(batchSize * (2 * 4));
- animate(geomBuffer[batchIndex], ballIndex, batchSize, delta);
+ animate(transform, buffer.asFloatBuffer(), ballSize, ballIndex, batchSize, delta);
- glUnmapBuffer(GL_ARRAY_BUFFER);
+ animVBO.unmap();
}
- if ( render )
- glDrawArrays(GL_POINTS, ballIndex, batchSize);
+ if ( render ) {
+ glVertexPointer(2, GL_FLOAT, 0, ballIndex * (2 * 4));
+ glDrawArrays(GL_POINTS, 0, batchSize);
+ }
- batchIndex++;
ballIndex += batchSize;
batchSize = Math.min(ballCount - ballIndex, BALLS_PER_BATCH);
}
@@ -653,6 +672,13 @@
}
public void updateBalls(final int count) {
+ if ( tfVBO[0] != 0 ) {
+ // Fetch current animation state
+ final FloatBuffer state = BufferUtils.createFloatBuffer(transform.length);
+ glGetBufferSubData(GL_TRANSFORM_FEEDBACK_BUFFER, 0, state);
+ state.get(transform);
+ }
+
super.updateBalls(count);
if ( tfVBO[0] != 0 ) {
@@ -660,14 +686,14 @@
glDeleteBuffers(tfVBO[i]);
}
- final FloatBuffer transform = BufferUtils.createFloatBuffer(count * 4);
- transform.put(this.transform);
- transform.flip();
+ final FloatBuffer state = BufferUtils.createFloatBuffer(count * 4);
+ state.put(transform);
+ state.flip();
for ( int i = 0; i < tfVBO.length; i++ ) {
tfVBO[i] = glGenBuffers();
glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, tfVBO[i]);
- glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, transform, GL_STATIC_DRAW);
+ glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, state, GL_STATIC_DRAW);
}
glBindBuffer(GL_ARRAY_BUFFER, tfVBO[0]);
Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout2P.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout2P.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootout2P.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2002-2011 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.sprites;
import org.lwjgl.BufferUtils;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutCL.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutCL.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/SpriteShootoutCL.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2002-2011 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.sprites;
import org.lwjgl.BufferUtils;
Added: trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/StreamVBO.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/StreamVBO.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/sprites/StreamVBO.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2002-2011 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.sprites;
+
+import org.lwjgl.LWJGLUtil;
+
+import java.nio.ByteBuffer;
+
+import static java.lang.Math.*;
+import static org.lwjgl.opengl.GL15.*;
+import static org.lwjgl.opengl.GL30.*;
+
+/**
+ * This class implements VBO orphaning, useful for streaming
+ * dynamically generated geometry to the GPU. OpenGL 3.0 or
+ * higher is required. See
+ * {@url http://www.opengl.org/wiki/Buffer_Object_Streaming}
+ * under "Buffer update" for details.
+ *
+ * @author Spasi
+ */
+public class StreamVBO {
+
+ private final int target;
+ private final long size;
+ private final int padding;
+
+ private int ID;
+
+ private long cursor;
+
+ public StreamVBO(final int target, final int size) {
+ this(target, size, 64);
+ }
+
+ public StreamVBO(final int target, final int size, final int padding) {
+ this.target = target;
+ this.padding = padding;
+ this.size = max(pad(size), padding);
+
+ ID = glGenBuffers();
+
+ glBindBuffer(target, ID);
+ glBufferData(target, this.size, GL_STREAM_DRAW);
+ }
+
+ public int getTarget() {
+ return target;
+ }
+
+ public int getID() {
+ return ID;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public int getPadding() {
+ return padding;
+ }
+
+ public void bind() {
+ glBindBuffer(target, ID);
+ }
+
+ public void init(final int offset, final ByteBuffer data) {
+ glBufferSubData(target, offset, data);
+ }
+
+ public void unmap() {
+ glUnmapBuffer(target);
+ }
+
+ public void destroy() {
+ glBindBuffer(target, 0);
+ glDeleteBuffers(ID);
+ }
+
+ public void reset() {
+ // Orphan current buffer and allocate a new one
+ glBufferData(target, size, GL_STREAM_DRAW);
+ // Flush
+ cursor = 0;
+ }
+
+ public ByteBuffer map(final int bytes) {
+ return map(bytes, null);
+ }
+
+ public ByteBuffer map(final int bytes, final ByteBuffer old_buffer) {
+ return doMap(pad(bytes), old_buffer);
+ }
+
+ private int pad(int size) {
+ final int mod = size % padding;
+ if ( mod == 0 )
+ return size;
+
+ return size + padding - mod;
+ }
+
+ private ByteBuffer doMap(final int bytes, final ByteBuffer old_buffer) {
+ if ( LWJGLUtil.CHECKS && size < bytes )
+ throw new IllegalArgumentException(Integer.toString(bytes));
+
+ if ( size < cursor + bytes )
+ reset();
+
+ final ByteBuffer map = glMapBufferRange(target, cursor, bytes, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT, old_buffer);
+ cursor += bytes;
+ return map;
+ }
+
+}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JNITypeTranslator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/JNITypeTranslator.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JNITypeTranslator.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -32,6 +32,10 @@
package org.lwjgl.util.generator;
+import org.lwjgl.PointerBuffer;
+
+import java.nio.Buffer;
+
import com.sun.mirror.type.*;
import com.sun.mirror.util.*;
@@ -45,12 +49,19 @@
* $Id$
*/
public class JNITypeTranslator implements TypeVisitor {
+
private final StringBuilder signature = new StringBuilder();
+ private boolean objectReturn;
+
public String getSignature() {
return signature.toString();
}
+ public String getReturnSignature() {
+ return objectReturn ? "jobject" : signature.toString();
+ }
+
public void visitAnnotationType(AnnotationType t) {
throw new RuntimeException(t + " is not allowed");
}
@@ -68,7 +79,12 @@
}
public void visitClassType(ClassType t) {
- signature.append("jobject");
+ final Class<?> type = Utils.getJavaType(t);
+ if ( Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type) ) {
+ signature.append("jlong");
+ objectReturn = true;
+ } else
+ signature.append("jobject");
}
public void visitDeclaredType(DeclaredType t) {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -194,8 +194,8 @@
writer.print("long ");
else {
Class type = type_info.getType();
- if ( native_stub && (type == CharSequence.class || type == CharSequence[].class || type == PointerBuffer.class) )
- writer.print("ByteBuffer ");
+ if ( native_stub && (type == CharSequence.class || type == CharSequence[].class || type == PointerBuffer.class || Buffer.class.isAssignableFrom(type) ) )
+ writer.print("long ");
else if ( printTypes )
writer.print(type_info.getType().getSimpleName() + " ");
}
@@ -203,8 +203,6 @@
if ( auto_size_annotation != null )
writer.print(auto_size_annotation.value() + "_");
writer.print(param.getSimpleName());
- if ( native_stub && buffer_type != null )
- writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX);
}
return false;
}
@@ -490,7 +488,7 @@
Check check_annotation = param.getAnnotation(Check.class);
boolean hide_buffer = mode == Mode.AUTOS && getAutoTypeParameter(method, param) != null;
if (hide_buffer) {
- writer.print("null");
+ writer.print("0L");
} else {
if ( type == CharSequence.class || type == CharSequence[].class ) {
final String offset = Utils.getStringOffset(method, param);
@@ -502,48 +500,25 @@
if ( offset != null )
writer.print(", " + offset);
writer.print(")");
- hide_buffer = true;
} else {
final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
if ( auto_size_annotation != null )
writer.print(auto_size_annotation.value() + "_");
- writer.print(param.getSimpleName());
- if ( PointerBuffer.class.isAssignableFrom(type) ) {
+
+ final Class buffer_type = Utils.getNIOBufferType(param.getType());
+ if ( buffer_type == null )
+ writer.print(param.getSimpleName());
+ else {
+ writer.print("MemoryUtil.getAddress");
if ( check_annotation != null && check_annotation.canBeNull() )
- writer.print(" != null ? " + param.getSimpleName());
- writer.print(".getBuffer()");
- if ( check_annotation != null && check_annotation.canBeNull() )
- writer.print(" : null");
+ writer.print("Safe");
+ writer.print("(");
+ writer.print(param.getSimpleName());
+ writer.print(")");
}
}
}
- Class buffer_type = Utils.getNIOBufferType(param.getType());
- if (buffer_type != null) {
- writer.print(", ");
- if (!hide_buffer) {
- int shifting;
- if (Utils.getNIOBufferType(param.getType()).equals(Buffer.class)) {
- shifting = getBufferElementSizeExponent(type == Buffer.class ? ByteBuffer.class : type); // TODO: This will always throw an exception
- //shifting = 0;
- } else
- shifting = 0;
- writer.print(param.getSimpleName());
- if (check_annotation != null && check_annotation.canBeNull())
- writer.print(" != null ? " + param.getSimpleName());
- if ( type == PointerBuffer.class && param.getAnnotation(NativeType.class).value().endsWith("void") )
- writer.print(".positionByte()");
- else
- writer.print(".position()");
- if (shifting > 0)
- writer.print(" << " + shifting);
- if (check_annotation != null && check_annotation.canBeNull())
- writer.print(" : 0");
- } else if ( type == CharSequence.class || type == CharSequence[].class ) {
- final String offset = Utils.getStringOffset(method, param);
- writer.print(offset == null ? "0" : offset);
- } else
- writer.print("0");
- } else if ( type != long.class ) {
+ if ( type != long.class ) {
PointerWrapper pointer_annotation = param.getAnnotation(PointerWrapper.class);
if ( pointer_annotation != null ) {
if ( pointer_annotation.canBeNull() )
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java 2011-07-14 23:11:41 UTC (rev 3588)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java 2011-07-16 16:05:37 UTC (rev 3589)
@@ -88,8 +88,6 @@
JNITypeTranslator translator = new JNITypeTranslator();
param.getType().accept(translator);
writer.print(translator.getSignature() + " " + param.getSimpleName());
- if (Utils.getNIOBufferType(param.getType()) != null)
- writer.print(", jint " + param.getSimpleName() + BUFFER_POSITION_POSTFIX);
}
}
@@ -108,7 +106,7 @@
} else {
JNITypeTranslator translator = new JNITypeTranslator();
result_type.accept(translator);
- writer.print(translator.getSignature());
+ writer.print(translator.getReturnSignature());
}
writer.print(" JNICALL ");
@@ -298,30 +296,17 @@
if ( !java_type.isArray() || CharSequence.class.isAssignableFrom(java_type.getComponentType()) ) {
writer.print("\t" + native_type + param.getSimpleName());
- writer.print(BUFFER_ADDRESS_POSTFIX + " = ((");
+ writer.print(BUFFER_ADDRESS_POSTFIX + " = (");
writer.print(native_type);
writer.print(")");
if (mode == Mode.BUFFEROBJECT && param.getAnnotation(BufferObject.class) != null) {
- writer.print("offsetToPointer(" + param.getSimpleNa...
[truncated message content] |
|
From: <sp...@us...> - 2011-07-14 23:11:47
|
Revision: 3588
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3588&view=rev
Author: spasi
Date: 2011-07-14 23:11:41 +0000 (Thu, 14 Jul 2011)
Log Message:
-----------
Fixed manual merge error.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-14 16:54:25 UTC (rev 3587)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-14 23:11:41 UTC (rev 3588)
@@ -184,7 +184,7 @@
}
}
- return new MappedInstanceMethodAdapter(access, className, name, desc, super.visitMethod(access, name, desc, signature, exceptions));
+ return new MappedInstanceMethodAdapter(className, name, desc, super.visitMethod(access, name, desc, signature, exceptions));
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-14 16:54:32
|
Revision: 3587
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3587&view=rev
Author: spasi
Date: 2011-07-14 16:54:25 +0000 (Thu, 14 Jul 2011)
Log Message:
-----------
Implemented .next() with bytecode transformation, 4x faster now.
Made method transformation a bit faster.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-13 22:15:35 UTC (rev 3586)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-14 16:54:25 UTC (rev 3587)
@@ -89,6 +89,15 @@
vecs.view = 0;
}
+ // manipulate 'view' with next()
+ {
+ assert (vecs.view == 0);
+ vecs.next();
+ assert (vecs.view == 1);
+ assert (vecs.value != 1.1f); // old view
+ vecs.view = 0;
+ }
+
// test bounds checking
{
assert (vecs.view == 0);
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-13 22:15:35 UTC (rev 3586)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-14 16:54:25 UTC (rev 3587)
@@ -87,6 +87,10 @@
return (int)(mapped.viewAddress - mapped.baseAddress) / sizeof;
}
+ public static void put_view_next(MappedObject mapped, int sizeof) {
+ mapped.setViewAddress(mapped.viewAddress + sizeof);
+ }
+
public static MappedObject dup(MappedObject src, MappedObject dst) {
dst.baseAddress = src.baseAddress;
dst.viewAddress = src.viewAddress;
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-13 22:15:35 UTC (rev 3586)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-14 16:54:25 UTC (rev 3587)
@@ -86,12 +86,7 @@
*/
public int view;
- /** Moves the current view to the next element. */
- public final void next() {
- setViewAddress(this.viewAddress + this.sizeof);
- }
-
- final void setViewAddress(final long address) {
+ public final void setViewAddress(final long address) {
if ( CHECKS )
checkAddress(address);
this.viewAddress = address;
@@ -99,8 +94,9 @@
final void checkAddress(final long address) {
final long base = MappedObjectUnsafe.getBufferBaseAddress(preventGC);
- if ( address < base || preventGC.capacity() < (address - base + this.sizeof) )
- throw new IndexOutOfBoundsException();
+ final int offset = (int)(address - base);
+ if ( address < base || preventGC.capacity() < (offset + this.sizeof) )
+ throw new IndexOutOfBoundsException(Integer.toString(offset / sizeof));
}
final void checkRange(final int bytes) {
@@ -186,6 +182,12 @@
throw new InternalError("type not registered");
}
+ /** Moves the current view to the next element. */
+ public final void next() {
+ // any method that calls this method will have its call-site modified
+ throw new InternalError("type not registered");
+ }
+
/**
* Copies and amount of <code>SIZEOF</code> bytes, from the current
* mapped object, to the specified mapped object.
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-13 22:15:35 UTC (rev 3586)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-14 16:54:25 UTC (rev 3587)
@@ -38,6 +38,9 @@
static final Map<String, MappedSubtypeInfo> className_to_subtype;
+ static final String MAPPED_OBJECT_JVM = jvmClassName(MappedObject.class);
+ static final String MAPPED_HELPER_JVM = jvmClassName(MappedHelper.class);
+
static {
className_to_subtype = new HashMap<String, MappedSubtypeInfo>();
@@ -56,7 +59,7 @@
// => IADD
// => PUTFIELD MyMappedType.view
//
- MappedSubtypeInfo info = new MappedSubtypeInfo(jvmClassName(MappedObject.class), -1, -1);
+ MappedSubtypeInfo info = new MappedSubtypeInfo(MAPPED_OBJECT_JVM, -1, -1);
className_to_subtype.put(info.className, info);
}
@@ -162,7 +165,7 @@
{
MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
- if ( mappedSubtype != null && !mappedSubtype.className.equals(jvmClassName(MappedObject.class)) ) {
+ if ( mappedSubtype != null && !mappedSubtype.className.equals(MAPPED_OBJECT_JVM) ) {
if ( "<init>".equals(name) ) {
if ( !"()V".equals(desc) )
throw new IllegalStateException(className + " can only have a default constructor, found: " + desc);
@@ -170,7 +173,7 @@
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, jvmClassName(MappedObject.class), "<init>", "()V");
+ mv.visitMethodInsn(INVOKESPECIAL, MAPPED_OBJECT_JVM, "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
@@ -181,7 +184,7 @@
}
}
- return new MappedInstanceMethodAdapter(className, name, desc, super.visitMethod(access, name, desc, signature, exceptions));
+ return new MappedInstanceMethodAdapter(access, className, name, desc, super.visitMethod(access, name, desc, signature, exceptions));
}
@Override
@@ -252,18 +255,26 @@
@Override
public void visitMethodInsn(int opcode, String className, String methodName, String signature) {
- if ( opcode == INVOKESPECIAL && className.equals(jvmClassName(MappedObject.class)) && "<init>".equals(methodName) && "()V".equals(signature) ) {
+ if ( opcode == INVOKESPECIAL && className.equals(MAPPED_OBJECT_JVM) && "<init>".equals(methodName) && "()V".equals(signature) ) {
// stack: instance
visitInsn(POP);
// stack: -
return;
}
- for ( MappedSubtypeInfo mappedType : className_to_subtype.values() ) {
- boolean isMapDirectMethod = (opcode == INVOKESTATIC && "map".equals(methodName) && className.equals(mappedType.className) && signature.equals("(JI)L" + jvmClassName(MappedObject.class) + ";"));
- boolean isMapBufferMethod = (opcode == INVOKESTATIC && "map".equals(methodName) && className.equals(mappedType.className) && signature.equals("(Ljava/nio/ByteBuffer;)L" + jvmClassName(MappedObject.class) + ";"));
- boolean isMallocMethod = (opcode == INVOKESTATIC && "malloc".equals(methodName) && className.equals(mappedType.className) && signature.equals("(I)L" + jvmClassName(MappedObject.class) + ";"));
+ MappedSubtypeInfo mappedType = className_to_subtype.get(className);
+ if ( mappedType != null && visitMappedMethod(opcode, className, methodName, signature, mappedType) )
+ return;
+ super.visitMethodInsn(opcode, className, methodName, signature);
+ }
+
+ private boolean visitMappedMethod(final int opcode, final String className, final String methodName, final String signature, final MappedSubtypeInfo mappedType) {
+ if ( opcode == INVOKESTATIC ) {
+ boolean isMapDirectMethod = "map".equals(methodName) && signature.equals("(JI)L" + MAPPED_OBJECT_JVM + ";");
+ boolean isMapBufferMethod = "map".equals(methodName) && signature.equals("(Ljava/nio/ByteBuffer;)L" + MAPPED_OBJECT_JVM + ";");
+ boolean isMallocMethod = "malloc".equals(methodName) && signature.equals("(I)L" + MAPPED_OBJECT_JVM + ";");
+
if ( (isMapDirectMethod || isMapBufferMethod) || isMallocMethod ) {
if ( isMallocMethod ) {
// stack: count
@@ -275,7 +286,7 @@
// stack: buffer
} else if ( isMapDirectMethod ) {
// stack: capacity, address
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";");
// stack: buffer
}
@@ -294,12 +305,12 @@
// stack: int, buffer, new, new
pushInt(super.mv, mappedType.sizeof);
// stack: int, int, buffer, new, new
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "setup", "(L" + jvmClassName(MappedObject.class) + ";Ljava/nio/ByteBuffer;II)V");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "setup", "(L" + MAPPED_OBJECT_JVM + ";Ljava/nio/ByteBuffer;II)V");
// stack: new
- return;
+ return true;
}
-
- if ( opcode == INVOKEVIRTUAL && "dup".equals(methodName) && className.equals(mappedType.className) && signature.equals("()L" + jvmClassName(MappedObject.class) + ";") ) {
+ } else if ( opcode == INVOKEVIRTUAL ) {
+ if ( "dup".equals(methodName) && signature.equals("()L" + MAPPED_OBJECT_JVM + ";") ) {
// stack: this
super.visitTypeInsn(NEW, className);
// stack: new, this
@@ -307,12 +318,12 @@
// stack: new, new, this
super.visitMethodInsn(INVOKESPECIAL, className, "<init>", "()V");
// stack: new, this
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "dup", "(L" + jvmClassName(MappedObject.class) + ";L" + jvmClassName(MappedObject.class) + ";)L" + jvmClassName(MappedObject.class) + ";");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "dup", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";)L" + MAPPED_OBJECT_JVM + ";");
// stack: new
- return;
+ return true;
}
- if ( opcode == INVOKEVIRTUAL && "slice".equals(methodName) && className.equals(mappedType.className) && signature.equals("()L" + jvmClassName(MappedObject.class) + ";") ) {
+ if ( "slice".equals(methodName) && signature.equals("()L" + MAPPED_OBJECT_JVM + ";") ) {
// stack: this
super.visitTypeInsn(NEW, className);
// stack: new, this
@@ -320,46 +331,55 @@
// stack: new, new, this
super.visitMethodInsn(INVOKESPECIAL, className, "<init>", "()V");
// stack: new, this
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "slice", "(L" + jvmClassName(MappedObject.class) + ";L" + jvmClassName(MappedObject.class) + ";)L" + jvmClassName(MappedObject.class) + ";");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "slice", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";)L" + MAPPED_OBJECT_JVM + ";");
// stack: new
- return;
+ return true;
}
//
- if ( opcode == INVOKEVIRTUAL && "runViewConstructor".equals(methodName) && className.equals(mappedType.className) && "()V".equals(signature) ) {
+ if ( "runViewConstructor".equals(methodName) && "()V".equals(signature) ) {
// stack: this
super.visitInsn(DUP);
// stack: this, this
super.visitMethodInsn(INVOKEVIRTUAL, className, view_constructor_method, "()V");
// stack: this
- return;
+ return true;
}
//
- if ( opcode == INVOKEVIRTUAL && "copyTo".equals(methodName) && className.equals(mappedType.className) && signature.equals("(L" + jvmClassName(MappedObject.class) + ";)V") ) {
+ if ( "copyTo".equals(methodName) && signature.equals("(L" + MAPPED_OBJECT_JVM + ";)V") ) {
// stack: target, this
pushInt(super.mv, mappedType.sizeof);
// stack: sizeof, target, this
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "copy", "(L" + jvmClassName(MappedObject.class) + ";L" + jvmClassName(MappedObject.class) + ";I)V");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "copy", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";I)V");
// stack: -
- return;
+ return true;
}
- if ( opcode == INVOKEVIRTUAL && "copyRange".equals(methodName) && className.equals(mappedType.className) && signature.equals("(L" + jvmClassName(MappedObject.class) + ";I)V") ) {
+ if ( "copyRange".equals(methodName) && signature.equals("(L" + MAPPED_OBJECT_JVM + ";I)V") ) {
// stack: instances, target, this
pushInt(super.mv, mappedType.sizeof);
// stack: sizeof, instances, target, this
super.visitInsn(IMUL);
// stack: bytes, target, this
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "copy", "(L" + jvmClassName(MappedObject.class) + ";L" + jvmClassName(MappedObject.class) + ";I)V");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "copy", "(L" + MAPPED_OBJECT_JVM + ";L" + MAPPED_OBJECT_JVM + ";I)V");
// stack: -
- return;
+ return true;
}
+
+ if ( "next".equals(methodName) && "()V".equals(signature) ) {
+ // stack: this
+ pushInt(super.mv, mappedType.sizeof);
+ // stack: sizeof, this
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "put_view_next", "(L" + MAPPED_OBJECT_JVM + ";I)V");
+ // stack: -
+ return true;
+ }
}
- super.visitMethodInsn(opcode, className, methodName, signature);
+ return false;
}
private static void throwAccessErrorOnReadOnlyField(String className, String fieldName) {
@@ -384,11 +404,11 @@
if ( false )
break outer;
else if ( className.equals(jvmClassName(MappedSet2.class)) )
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "put_views", "(L" + jvmClassName(MappedSet2.class) + ";I)V");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + jvmClassName(MappedSet2.class) + ";I)V");
else if ( className.equals(jvmClassName(MappedSet3.class)) )
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "put_views", "(L" + jvmClassName(MappedSet3.class) + ";I)V");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + jvmClassName(MappedSet3.class) + ";I)V");
else if ( className.equals(jvmClassName(MappedSet4.class)) )
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "put_views", "(L" + jvmClassName(MappedSet4.class) + ";I)V");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "put_views", "(L" + jvmClassName(MappedSet4.class) + ";I)V");
else
break outer;
// stack: -
@@ -421,7 +441,7 @@
// stack: instance
pushInt(super.mv, mappedSubtype.sizeof);
// stack: sizeof, instance
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "get_view", "(L" + jvmClassName(MappedObject.class) + ";I)I");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "get_view", "(L" + MAPPED_OBJECT_JVM + ";I)I");
// stack: view
return;
}
@@ -429,7 +449,7 @@
// stack: view, instance
pushInt(super.mv, mappedSubtype.sizeof);
// stack: sizeof, view, instance
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "put_view", "(L" + jvmClassName(MappedObject.class) + ";II)V");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "put_view", "(L" + MAPPED_OBJECT_JVM + ";II)V");
// stack: -
return;
}
@@ -494,7 +514,7 @@
// stack: long, long
super.visitInsn(L2I);
// stack: int, long
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";");
// stack: buffer
return;
}
@@ -512,7 +532,7 @@
// stack: offset, viewAddr, value
super.visitInsn(LADD);
// stack: fieldAddr, value
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), typeName.toLowerCase() + "put", "(" + typeName + "J)V");
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, typeName.toLowerCase() + "put", "(" + typeName + "J)V");
// stack -
return;
@@ -525,7 +545,7 @@
// stack: fieldOffset, viewAddr
super.visitInsn(LADD);
// stack: fieldAddr
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), typeName.toLowerCase() + "get", "(J)" + typeName);
+ super.visitMethodInsn(INVOKESTATIC, MAPPED_HELPER_JVM, typeName.toLowerCase() + "get", "(J)" + typeName);
// stack: value
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-07-13 22:15:41
|
Revision: 3586
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3586&view=rev
Author: kappa1
Date: 2011-07-13 22:15:35 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Implement Resizing Display API for OS X
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -93,6 +93,12 @@
* unlike GL, where it is typically at the bottom of the display.
*/
private static int y = -1;
+
+ /** the width of the Display window */
+ private static int width = 0;
+
+ /** the height of the Display window */
+ private static int height = 0;
/** Title of the window (never null) */
private static String title = "Game";
@@ -109,6 +115,10 @@
private static boolean window_created;
private static boolean parent_resized;
+
+ private static boolean window_resized;
+
+ private static boolean window_resizable;
/** Initial Background Color of Display */
private static float r, g, b;
@@ -295,6 +305,9 @@
DisplayMode mode = getEffectiveMode();
display_impl.createWindow(drawable, mode, tmp_parent, getWindowX(), getWindowY());
window_created = true;
+
+ width = Display.getDisplayMode().getWidth();
+ height = Display.getDisplayMode().getHeight();
setTitle(title);
initControls();
@@ -661,6 +674,13 @@
throw new RuntimeException(e);
}
}
+
+ window_resized = !isFullscreen() && parent == null && display_impl.wasResized();
+
+ if ( window_resized ) {
+ width = display_impl.getWidth();
+ height = display_impl.getHeight();
+ }
if ( parent_resized ) {
reshape();
@@ -1257,14 +1277,17 @@
* false to disable resizing on the Display window.
*/
public static void setResizable(boolean resizable) {
-
+ window_resizable = resizable;
+ if ( isCreated() ) {
+ display_impl.setResizable(resizable);
+ }
}
/**
* @return true if the Display window is resizable.
*/
public static boolean isResizable() {
- return false;
+ return window_resizable;
}
/**
@@ -1274,7 +1297,7 @@
* This will return false if running in fullscreen or with Display.setParent(Canvas parent)
*/
public static boolean wasResized() {
- return false;
+ return window_resized;
}
/**
@@ -1287,7 +1310,16 @@
* This value will be updated after a call to Display.update().
*/
public static int getWidth() {
- return 0;
+
+ if (Display.isFullscreen()) {
+ return Display.getDisplayMode().getWidth();
+ }
+
+ if (parent != null) {
+ return parent.getWidth();
+ }
+
+ return width;
}
/**
@@ -1300,6 +1332,15 @@
* This value will be updated after a call to Display.update().
*/
public static int getHeight() {
- return 0;
+
+ if (Display.isFullscreen()) {
+ return Display.getDisplayMode().getHeight();
+ }
+
+ if (parent != null) {
+ return parent.getHeight();
+ }
+
+ return height;
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -169,13 +169,8 @@
void setResizable(boolean resizable);
/**
- * @return true if the Display window is resizable.
+ * @return true if the Display window has been resized since this method was last called.
*/
- boolean isResizable();
-
- /**
- * @return true if the Display window has been resized.
- */
boolean wasResized();
/**
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -1361,10 +1361,6 @@
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
return false;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -47,6 +47,7 @@
private int width;
private int height;
private boolean context_update;
+ private boolean resized;
MacOSXCanvasListener(Canvas canvas) {
this.canvas = canvas;
@@ -102,6 +103,7 @@
public void componentResized(ComponentEvent e) {
setUpdate();
+ resized = true;
}
public void componentMoved(ComponentEvent e) {
@@ -111,4 +113,13 @@
public void hierarchyChanged(HierarchyEvent e) {
setUpdate();
}
+
+ public boolean wasResized() {
+ if (resized) {
+ resized = false;
+ return true;
+ }
+
+ return false;
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -497,11 +497,11 @@
}
public int getWidth() {
- return Display.getDisplayMode().getWidth();
+ return frame.getWidth();
}
public int getHeight() {
- return Display.getDisplayMode().getHeight();
+ return frame.getHeight();
}
public boolean isInsideWindow() {
@@ -509,15 +509,11 @@
}
public void setResizable(boolean resizable) {
-
+ frame.setResizable(resizable);
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
- return false;
+ return canvas_listener.wasResized();
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -68,7 +68,7 @@
private boolean should_release_cursor;
MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
- setResizable(false);
+ setResizable(Display.isResizable());
addWindowListener(this);
addComponentListener(this);
canvas = new MacOSXGLCanvas();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -945,10 +945,6 @@
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-13 22:15:32
|
Revision: 3585
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3585&view=rev
Author: spasi
Date: 2011-07-13 22:15:25 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Removed stride and .configure. Mapped object view updates are now 50% faster. [Riven]
org.lwjgl.util.mapped.PrintBytecode is now functional. [Riven]
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectWithLibrary.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -59,8 +59,8 @@
{
MappedFloat vecs1 = MappedFloat.malloc(1234);
- assert (vecs1.stride == MappedFloat.SIZEOF);
- assert (vecs1.stride * 1234 == vecs1.backingByteBuffer().capacity());
+ assert (vecs1.sizeof == MappedFloat.SIZEOF);
+ assert (vecs1.sizeof * 1234 == vecs1.backingByteBuffer().capacity());
assert (MappedFloat.SIZEOF * 1234 == vecs1.backingByteBuffer().capacity());
}
@@ -132,31 +132,6 @@
}
}
- // test dup
- {
- int newStride = 16;
- int doOffset = 0;
-
- vecs.view = 0;
- MappedFloat.configure(vecs, newStride, doOffset);
- MappedFloat dec2 = vecs.dup();
- MappedFloat.configure(dec2, newStride, doOffset);
-
- String s1 = vecs.baseAddress + "," + vecs.viewAddress + "," + vecs.stride + "," + vecs.SIZEOF;
- String s2 = dec2.baseAddress + "," + dec2.viewAddress + "," + dec2.stride + "," + dec2.SIZEOF;
- // System.out.println(s1);
- // System.out.println(s2);
- assert (s1.equals(s2));
-
- dec2.view++;
-
- String s3 = vecs.baseAddress + "," + vecs.viewAddress + "," + vecs.stride + "," + vecs.SIZEOF;
- String s4 = dec2.baseAddress + "," + dec2.viewAddress + "," + dec2.stride + "," + dec2.SIZEOF;
- // System.out.println(s3);
- // System.out.println(s4);
- assert (!s3.equals(s4));
- }
-
// test newBuffer
{
long addr1 = MappedObjectUnsafe.getBufferBaseAddress(bb);
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -91,40 +91,8 @@
vecs.view = 1;
long a2 = vecs.viewAddress;
assert (a2 - a1 == MappedVec3.SIZEOF);
- assert (a2 - a1 == vecs.stride);
+ assert (a2 - a1 == vecs.sizeof);
vecs.view = 0;
}
-
- int newStride = 16;
-
- MappedVec3.configure(vecs, newStride, +4);
- assert (vecs.z == 0.1234f); // vecs[1].x ended up in vecs[0].z due to 1float offset
-
- MappedVec3.configure(vecs, newStride, +8);
- assert (vecs.z == 0.0000f); // vecs[1].z ended up in vecs[0].z due to 2float offset
-
- // test new stride
- {
- long a1 = vecs.viewAddress;
- vecs.view = 1;
- long a2 = vecs.viewAddress;
- assert (a2 - a1 == newStride);
- vecs.view = 0;
- }
-
- // example: GPU => VBO => VTN
- {
- MappedVec3 v = MappedVec3.map(bb);
- MappedVec2 t = MappedVec2.map(bb);
- MappedVec3 n = MappedVec3.map(bb);
-
- int stride = MappedVec3.SIZEOF + MappedVec2.SIZEOF + MappedVec3.SIZEOF;
- assert (stride == 32);
-
- MappedVec3.configure(v, stride, 0);
- MappedVec2.configure(t, stride, MappedVec3.SIZEOF);
- MappedVec3.configure(n, stride, MappedVec3.SIZEOF + MappedVec2.SIZEOF);
- }
}
-
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectWithLibrary.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectWithLibrary.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectWithLibrary.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -4,15 +4,14 @@
package org.lwjgl.test.mapped;
+import org.lwjgl.opengl.Display;
+
import java.io.File;
-import org.lwjgl.opengl.Display;
+public class MappedObjectWithLibrary {
-public class MappedObjectWithLibrary
-{
- public static void testLWJGL() throws Exception
- {
- System.out.println(new File(System.getProperty("java.library.path")).getCanonicalPath());
- Display.create();
- }
+ public static void testLWJGL() throws Exception {
+ System.out.println(new File(System.getProperty("java.library.path")).getCanonicalPath());
+ Display.create();
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -35,6 +35,7 @@
import org.lwjgl.util.mapped.MappedObjectTransformer;
/** @author Riven */
+@SuppressWarnings("static-access")
public class TestMappedObject {
static {
@@ -49,7 +50,6 @@
MappedObjectTransformer.register(MappedVec2.class);
MappedObjectTransformer.register(MappedVec3.class);
MappedObjectTransformer.register(MappedSomething.class);
-
MappedObjectTransformer.register(MappedObjectTests3.Xyz.class);
if ( MappedObjectClassLoader.fork(TestMappedObject.class, args) ) {
@@ -70,8 +70,8 @@
MappedObjectTests3.testForeach();
MappedObjectTests3.testConstructor();
MappedObjectTests3.testMappedSet();
-
- MappedObjectWithLibrary.testLWJGL();
+
+ System.out.println("done");
}
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -58,7 +58,7 @@
}
public T next() {
- MappedHelper.put_view(mapped, this.index++);
+ MappedHelper.put_view(mapped, this.index++, mapped.sizeof);
return mapped;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -58,7 +58,7 @@
if ( sizeof % align != 0 )
throw new IllegalStateException("sizeof not a multiple of alignment");
- mo.stride = sizeof;
+ mo.sizeof = sizeof;
long addr = MappedObjectUnsafe.getBufferBaseAddress(buffer) + buffer.position();
if ( addr % align != 0 )
@@ -79,19 +79,19 @@
set.view(view);
}
- public static void put_view(MappedObject mapped, int view) {
- mapped.setViewAddress(mapped.baseAddress + view * mapped.stride);
+ public static void put_view(MappedObject mapped, int view, int sizeof) {
+ mapped.setViewAddress(mapped.baseAddress + view * sizeof);
}
- public static int get_view(MappedObject mapped) {
- return (int)(mapped.viewAddress - mapped.baseAddress) / mapped.stride;
+ public static int get_view(MappedObject mapped, int sizeof) {
+ return (int)(mapped.viewAddress - mapped.baseAddress) / sizeof;
}
public static MappedObject dup(MappedObject src, MappedObject dst) {
dst.baseAddress = src.baseAddress;
dst.viewAddress = src.viewAddress;
- dst.stride = src.stride;
dst.align = src.align;
+ dst.sizeof = src.sizeof;
dst.preventGC = src.preventGC;
return dst;
}
@@ -99,8 +99,8 @@
public static MappedObject slice(MappedObject src, MappedObject dst) {
dst.baseAddress = src.viewAddress; // !
dst.viewAddress = src.viewAddress;
- dst.stride = src.stride;
dst.align = src.align;
+ dst.sizeof = src.sizeof;
dst.preventGC = src.preventGC;
return dst;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -63,12 +63,12 @@
/** The mapped object view memory address, in bytes. Read-only. */
public long viewAddress;
- /** The mapped object stride, in bytes. Read-only. */
- public int stride;
-
/** The mapped object memory alignment, in bytes. Read-only. */
public int align;
+ /** The mapped object memory sizeof, in bytes. Read-only. */
+ public int sizeof;
+
/**
* Holds the value of sizeof of the sub-type of this MappedObject<br>
* <br>
@@ -88,7 +88,7 @@
/** Moves the current view to the next element. */
public final void next() {
- setViewAddress(this.viewAddress + this.stride);
+ setViewAddress(this.viewAddress + this.sizeof);
}
final void setViewAddress(final long address) {
@@ -99,7 +99,7 @@
final void checkAddress(final long address) {
final long base = MappedObjectUnsafe.getBufferBaseAddress(preventGC);
- if ( address < base || preventGC.capacity() < (address - base + stride) )
+ if ( address < base || preventGC.capacity() < (address - base + this.sizeof) )
throw new IndexOutOfBoundsException();
}
@@ -218,32 +218,6 @@
return new MappedForeach<T>(mapped, elementCount);
}
- /**
- * Configures a newly initiated mapped object with the specified stride and offset.
- *
- * @throws IllegalStateException if view is not at index 0
- */
- public static <T extends MappedObject> T configure(T mapped, int stride, int offset) {
- if ( mapped.baseAddress != mapped.viewAddress )
- throw new IllegalStateException("view must be zero");
-
- if ( offset < 0 )
- throw new IllegalStateException("offset must not be negative: " + offset);
- if ( offset % mapped.align != 0 )
- throw new IllegalStateException("offset not a multiple of alignment: " + offset);
-
- if ( stride < mapped.stride )
- throw new IllegalStateException("new stride must not be smaller than current stride: " + stride);
- if ( stride % mapped.align != 0 )
- throw new IllegalStateException("stride not a multiple of alignment: " + stride);
-
- mapped.baseAddress += offset;
- mapped.viewAddress += offset;
- mapped.stride = stride;
-
- return mapped;
- }
-
ByteBuffer preventGC;
/**
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -34,7 +34,7 @@
static final boolean PRINT_TIMING = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintTiming");
static final boolean PRINT_ACTIVITY = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintActivity");
- static final boolean PRINT_BYTECODE = false; //LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode");
+ static final boolean PRINT_BYTECODE = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode");
static final Map<String, MappedSubtypeInfo> className_to_subtype;
@@ -372,6 +372,7 @@
if ( mappedSubtype == null ) {
String mappedSetPrefix = jvmClassName(MappedSet.class);
+ // MappedSet.view
outer:
if ( "view".equals(fieldName) && className.startsWith(mappedSetPrefix) ) {
if ( opcode == GETFIELD )
@@ -418,17 +419,23 @@
if ( opcode == GETFIELD ) {
// stack: instance
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "get_view", "(L" + jvmClassName(MappedObject.class) + ";)I");
+ pushInt(super.mv, mappedSubtype.sizeof);
+ // stack: sizeof, instance
+ super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "get_view", "(L" + jvmClassName(MappedObject.class) + ";I)I");
+ // stack: view
return;
}
if ( opcode == PUTFIELD ) {
- // stack: int, instance
- super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "put_view", "(L" + jvmClassName(MappedObject.class) + ";I)V");
+ // stack: view, instance
+ pushInt(super.mv, mappedSubtype.sizeof);
+ // stack: sizeof, view, instance
+ super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "put_view", "(L" + jvmClassName(MappedObject.class) + ";II)V");
+ // stack: -
return;
}
}
- if ( "align".equals(fieldName) ) {
+ if ( "align".equals(fieldName) || "sizeof".equals(fieldName) ) {
if ( !"I".equals(typeName) )
throw new IllegalStateException();
@@ -436,7 +443,10 @@
// stack: instance
super.visitInsn(POP);
// stack: -
- pushInt(super.mv, mappedSubtype.align);
+ if ( "sizeof".equals(fieldName) )
+ pushInt(super.mv, mappedSubtype.sizeof);
+ else if ( "align".equals(fieldName) )
+ pushInt(super.mv, mappedSubtype.align);
// stack: int
return;
}
@@ -445,18 +455,6 @@
}
}
- if ( "stride".equals(fieldName) ) {
- if ( !"I".equals(typeName) )
- throw new IllegalStateException();
-
- if ( opcode == GETFIELD ) {
- // do not change a thing
- }
- if ( opcode == PUTFIELD ) {
- throwAccessErrorOnReadOnlyField(className, fieldName);
- }
- }
-
if ( "baseAddress".equals(fieldName) || "viewAddress".equals(fieldName) ) {
if ( !"J".equals(typeName) )
throw new IllegalStateException();
@@ -476,6 +474,8 @@
return;
}
+ // now we're going to transform ByteBuffer-typed field access
+
if ( typeName.equals("L" + jvmClassName(ByteBuffer.class) + ";") ) {
if ( opcode == PUTFIELD ) {
throwAccessErrorOnReadOnlyField(className, fieldName);
@@ -500,30 +500,34 @@
}
}
+ // we're now going to transform the field access
+
if ( opcode == PUTFIELD ) {
// stack: value, ref
super.visitInsn(SWAP);
// stack: ref, value
super.visitFieldInsn(GETFIELD, mappedSubtype.className, "viewAddress", "J");
- // stack: long, value
+ // stack: viewAddr, value
super.visitLdcInsn(fieldOffset);
- // stack: long, long, value
+ // stack: offset, viewAddr, value
super.visitInsn(LADD);
- // stack: long, value
+ // stack: fieldAddr, value
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), typeName.toLowerCase() + "put", "(" + typeName + "J)V");
// stack -
+
return;
}
if ( opcode == GETFIELD ) {
// stack: ref
super.visitFieldInsn(GETFIELD, mappedSubtype.className, "viewAddress", "J");
- // stack: long
+ // stack: viewAddr
super.visitLdcInsn(fieldOffset);
- // stack: long, long
+ // stack: fieldOffset, viewAddr
super.visitInsn(LADD);
- // stack: long
+ // stack: fieldAddr
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), typeName.toLowerCase() + "get", "(J)" + typeName);
// stack: value
+
return;
}
@@ -553,7 +557,7 @@
else if ( value >= Short.MIN_VALUE && value <= Short.MAX_VALUE )
mv.visitIntInsn(SIPUSH, value);
else
- mv.visitLdcInsn(Integer.valueOf(value));
+ mv.visitLdcInsn(value);
}
static String jvmClassName(Class<?> type) {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet2.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -44,8 +44,8 @@
public int view;
void view(int view) {
- MappedHelper.put_view(this.a, view);
- MappedHelper.put_view(this.b, view);
+ MappedHelper.put_view(this.a, view, this.a.sizeof);
+ MappedHelper.put_view(this.b, view, this.b.sizeof);
}
public void next() {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet3.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -45,9 +45,9 @@
public int view;
void view(int view) {
- MappedHelper.put_view(this.a, view);
- MappedHelper.put_view(this.b, view);
- MappedHelper.put_view(this.c, view);
+ MappedHelper.put_view(this.a, view, this.a.sizeof);
+ MappedHelper.put_view(this.b, view, this.b.sizeof);
+ MappedHelper.put_view(this.c, view, this.c.sizeof);
}
public void next() {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java 2011-07-13 19:29:15 UTC (rev 3584)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet4.java 2011-07-13 22:15:25 UTC (rev 3585)
@@ -46,10 +46,10 @@
public int view;
void view(int view) {
- MappedHelper.put_view(this.a, view);
- MappedHelper.put_view(this.b, view);
- MappedHelper.put_view(this.c, view);
- MappedHelper.put_view(this.d, view);
+ MappedHelper.put_view(this.a, view, this.a.sizeof);
+ MappedHelper.put_view(this.b, view, this.b.sizeof);
+ MappedHelper.put_view(this.c, view, this.c.sizeof);
+ MappedHelper.put_view(this.d, view, this.d.sizeof);
}
public void next() {
@@ -58,5 +58,4 @@
this.c.next();
this.d.next();
}
-
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-07-13 19:29:21
|
Revision: 3584
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3584&view=rev
Author: kappa1
Date: 2011-07-13 19:29:15 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Updated JavaDoc for the new resizing api to clarify behaviour when running in fullscreen or with Display.setParent().
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-13 12:44:25 UTC (rev 3583)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-13 19:29:15 UTC (rev 3584)
@@ -1270,6 +1270,8 @@
/**
* @return true if the Display window has been resized.
* This value will be updated after a call to Display.update().
+ *
+ * This will return false if running in fullscreen or with Display.setParent(Canvas parent)
*/
public static boolean wasResized() {
return false;
@@ -1278,6 +1280,10 @@
/**
* @return this method will return the width of the Display window.
*
+ * If running in fullscreen mode it will return the width of the current set DisplayMode.
+ * If running Display.setParent(Canvas parent) is being used, the width of the parent
+ * will be returned.
+ *
* This value will be updated after a call to Display.update().
*/
public static int getWidth() {
@@ -1286,6 +1292,10 @@
/**
* @return this method will return the height of the Display window.
+ *
+ * If running in fullscreen mode it will return the height of the current set DisplayMode.
+ * If running Display.setParent(Canvas parent) is being used, the height of the parent
+ * will be returned.
*
* This value will be updated after a call to Display.update().
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-13 12:44:31
|
Revision: 3583
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3583&view=rev
Author: spasi
Date: 2011-07-13 12:44:25 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Made MappedForeach package private (foreach returns Iterable now) and changed next() to go through the bounds check.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-12 22:07:32 UTC (rev 3582)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-13 12:44:25 UTC (rev 3583)
@@ -38,7 +38,7 @@
*
* @author Riven
*/
-public class MappedForeach<T extends MappedObject> implements Iterable<T> {
+final class MappedForeach<T extends MappedObject> implements Iterable<T> {
final T mapped;
final int elementCount;
@@ -58,8 +58,7 @@
}
public T next() {
- mapped.viewAddress = mapped.baseAddress + (this.index++) * mapped.stride;
-
+ MappedHelper.put_view(mapped, this.index++);
return mapped;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 22:07:32 UTC (rev 3582)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-13 12:44:25 UTC (rev 3583)
@@ -214,7 +214,7 @@
* For convenience you are encouraged to static-import this specific method:
* <code>import static org.lwjgl.util.mapped.MappedObject.foreach;</code>
*/
- public static <T extends MappedObject> MappedForeach<T> foreach(T mapped, int elementCount) {
+ public static <T extends MappedObject> Iterable<T> foreach(T mapped, int elementCount) {
return new MappedForeach<T>(mapped, elementCount);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-07-12 22:07:38
|
Revision: 3582
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3582&view=rev
Author: kappa1
Date: 2011-07-12 22:07:32 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Add placeholder methods for initial resizing api for the Display
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -1249,4 +1249,47 @@
}
}
}
+
+ /**
+ * Enable or disable the Display window to be resized.
+ *
+ * @param set true to make the Display window resizable;
+ * false to disable resizing on the Display window.
+ */
+ public static void setResizable(boolean resizable) {
+
+ }
+
+ /**
+ * @return true if the Display window is resizable.
+ */
+ public static boolean isResizable() {
+ return false;
+ }
+
+ /**
+ * @return true if the Display window has been resized.
+ * This value will be updated after a call to Display.update().
+ */
+ public static boolean wasResized() {
+ return false;
+ }
+
+ /**
+ * @return this method will return the width of the Display window.
+ *
+ * This value will be updated after a call to Display.update().
+ */
+ public static int getWidth() {
+ return 0;
+ }
+
+ /**
+ * @return this method will return the height of the Display window.
+ *
+ * This value will be updated after a call to Display.update().
+ */
+ public static int getHeight() {
+ return 0;
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -159,4 +159,32 @@
* @return number of icons used.
*/
int setIcon(ByteBuffer[] icons);
+
+ /**
+ * Enable or disable the Display window to be resized.
+ *
+ * @param set true to make the Display window resizable;
+ * false to disable resizing on the Display window.
+ */
+ void setResizable(boolean resizable);
+
+ /**
+ * @return true if the Display window is resizable.
+ */
+ boolean isResizable();
+
+ /**
+ * @return true if the Display window has been resized.
+ */
+ boolean wasResized();
+
+ /**
+ * @return this method will return a the width of the Display window.
+ */
+ int getWidth();
+
+ /**
+ * @return this method will return a the height of the Display window.
+ */
+ int getHeight();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -1356,6 +1356,18 @@
public boolean isInsideWindow() {
return mouseInside;
}
+
+ public void setResizable(boolean resizable) {
+
+ }
+
+ public boolean isResizable() {
+ return false;
+ }
+
+ public boolean wasResized() {
+ return false;
+ }
/**
* Helper class for managing Compiz's workarounds. We need this to enable Legacy
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -504,7 +504,20 @@
return Display.getDisplayMode().getHeight();
}
- public boolean isInsideWindow() {
- return true;
- }
+ public boolean isInsideWindow() {
+ return true;
+ }
+
+ public void setResizable(boolean resizable) {
+
+ }
+
+ public boolean isResizable() {
+ return false;
+ }
+
+ public boolean wasResized() {
+ return false;
+ }
+
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -935,11 +935,23 @@
return -1;
}
- private native boolean nTrackMouseEvent(long hwnd);
+ private native boolean nTrackMouseEvent(long hwnd);
- public boolean isInsideWindow() {
- return mouseInside;
- }
+ public boolean isInsideWindow() {
+ return mouseInside;
+ }
+
+ public void setResizable(boolean resizable) {
+
+ }
+
+ public boolean isResizable() {
+ return false;
+ }
+
+ public boolean wasResized() {
+ return false;
+ }
private static final class Rect {
public int top;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-12 21:30:55
|
Revision: 3581
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3581&view=rev
Author: spasi
Date: 2011-07-12 21:30:48 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Fixed stackmap and classloading bugs.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 20:59:27 UTC (rev 3580)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 21:30:48 UTC (rev 3581)
@@ -51,7 +51,7 @@
*/
public class MappedObject {
- static final boolean CHECKS = false;//LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.Checks");
+ static final boolean CHECKS = LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.Checks");
public MappedObject() {
//
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 20:59:27 UTC (rev 3580)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 21:30:48 UTC (rev 3581)
@@ -8,13 +8,13 @@
import org.objectweb.asm.*;
import org.objectweb.asm.util.TraceClassVisitor;
-import java.io.PrintWriter;
-import java.io.StringWriter;
+import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
+import java.util.StringTokenizer;
import static org.objectweb.asm.Opcodes.*;
@@ -32,8 +32,8 @@
*/
public class MappedObjectTransformer {
- static final boolean PRINT_TIMING = false;//LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintTiming");
- static final boolean PRINT_ACTIVITY = false;//LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintActivity");
+ static final boolean PRINT_TIMING = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintTiming");
+ static final boolean PRINT_ACTIVITY = LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintActivity");
static final boolean PRINT_BYTECODE = false; //LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode");
static final Map<String, MappedSubtypeInfo> className_to_subtype;
@@ -138,13 +138,24 @@
}
}
- static final String view_constructor_method = "_construct_view_";
+ static boolean is_currently_computing_frames = false;
+ static final String view_constructor_method = "_construct_view_";
static byte[] transformFieldAccess(final String className, byte[] bytecode) {
- int flags = 0;//ClassWriter.COMPUTE_FRAMES;
+ int flags = ClassWriter.COMPUTE_FRAMES;
- ClassWriter writer = new ClassWriter(flags);
+ ClassWriter writer = new ClassWriter(flags) {
+ // HACK: prevent user-code static-initialization-blocks to be executed
+ @Override
+ protected String getCommonSuperClass(String a, String b) {
+ if ( is_currently_computing_frames )
+ if ( !a.startsWith("java/") || !b.startsWith("java/") )
+ return "java/lang/Object";
+ return super.getCommonSuperClass(a, b);
+ }
+ };
+
ClassAdapter adapter = new ClassAdapter(writer) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
@@ -192,14 +203,14 @@
bytecode = writer.toByteArray();
if ( PRINT_BYTECODE )
- printBytecode(bytecode, adapter);
+ printBytecode(bytecode);
return bytecode;
}
- private static void printBytecode(byte[] bytecode, ClassAdapter adapter) {
+ private static void printBytecode(byte[] bytecode) {
StringWriter sw = new StringWriter();
- ClassVisitor tracer = new TraceClassVisitor(adapter, new PrintWriter(sw));
+ ClassVisitor tracer = new TraceClassVisitor(new ClassWriter(0), new PrintWriter(sw));
new ClassReader(bytecode).accept(tracer, 0);
String dump = sw.toString();
@@ -227,13 +238,16 @@
super.visitTypeInsn(opcode, typeName);
}
-
- private int requireExtraStack = 0;
-
+
@Override
- public void visitMaxs(int maxStack, int maxLocals)
- {
- super.visitMaxs(maxStack+this.requireExtraStack, maxLocals);
+ public void visitMaxs(int a, int b) {
+ try {
+ is_currently_computing_frames = true;
+
+ super.visitMaxs(a, b);
+ } finally {
+ is_currently_computing_frames = false;
+ }
}
@Override
@@ -252,7 +266,7 @@
if ( (isMapDirectMethod || isMapBufferMethod) || isMallocMethod ) {
if ( isMallocMethod ) {
- // stack: count
+ // stack: count
pushInt(super.mv, mappedType.sizeof);
// stack: sizeof, count
super.visitInsn(IMUL);
@@ -282,7 +296,6 @@
// stack: int, int, buffer, new, new
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "setup", "(L" + jvmClassName(MappedObject.class) + ";Ljava/nio/ByteBuffer;II)V");
// stack: new
- this.requireExtraStack = 5;
return;
}
@@ -296,7 +309,6 @@
// stack: new, this
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "dup", "(L" + jvmClassName(MappedObject.class) + ";L" + jvmClassName(MappedObject.class) + ";)L" + jvmClassName(MappedObject.class) + ";");
// stack: new
- this.requireExtraStack = 3;
return;
}
@@ -310,7 +322,6 @@
// stack: new, this
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "slice", "(L" + jvmClassName(MappedObject.class) + ";L" + jvmClassName(MappedObject.class) + ";)L" + jvmClassName(MappedObject.class) + ";");
// stack: new
- this.requireExtraStack = 3;
return;
}
@@ -322,7 +333,6 @@
// stack: this, this
super.visitMethodInsn(INVOKEVIRTUAL, className, view_constructor_method, "()V");
// stack: this
- this.requireExtraStack = 2;
return;
}
@@ -334,7 +344,6 @@
// stack: sizeof, target, this
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "copy", "(L" + jvmClassName(MappedObject.class) + ";L" + jvmClassName(MappedObject.class) + ";I)V");
// stack: -
- this.requireExtraStack = 3;
return;
}
@@ -346,7 +355,6 @@
// stack: bytes, target, this
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "copy", "(L" + jvmClassName(MappedObject.class) + ";L" + jvmClassName(MappedObject.class) + ";I)V");
// stack: -
- this.requireExtraStack = 4;
return;
}
}
@@ -488,13 +496,12 @@
// stack: int, long
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), "newBuffer", "(JI)L" + jvmClassName(ByteBuffer.class) + ";");
// stack: buffer
- this.requireExtraStack = 4;
return;
}
}
if ( opcode == PUTFIELD ) {
- // stack: value, ref
+ // stack: value, ref
super.visitInsn(SWAP);
// stack: ref, value
super.visitFieldInsn(GETFIELD, mappedSubtype.className, "viewAddress", "J");
@@ -505,11 +512,10 @@
// stack: long, value
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), typeName.toLowerCase() + "put", "(" + typeName + "J)V");
// stack -
- this.requireExtraStack = 4+(int)(mappedSubtype.fieldToLength.get(fieldName).longValue()>>2);
return;
}
if ( opcode == GETFIELD ) {
- // stack: ref
+ // stack: ref
super.visitFieldInsn(GETFIELD, mappedSubtype.className, "viewAddress", "J");
// stack: long
super.visitLdcInsn(fieldOffset);
@@ -518,7 +524,6 @@
// stack: long
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), typeName.toLowerCase() + "get", "(J)" + typeName);
// stack: value
- this.requireExtraStack = 4;
return;
}
@@ -576,4 +581,59 @@
}
}
+ public static String exportConfiguration() {
+ StringBuilder sb = new StringBuilder();
+
+ for ( MappedSubtypeInfo info : className_to_subtype.values() ) {
+ sb.append("class\t" + info.className + "\t" + info.sizeof + "\t" + info.align + "\r\n");
+
+ for ( String fieldName : info.fieldToOffset.keySet() ) {
+ sb.append("field\t" + info.className + "\t" + fieldName + "\t" + info.fieldToOffset.get(fieldName) + "\t" + info.fieldToLength.get(fieldName) + "\r\n");
+ }
+ }
+
+ className_to_subtype.clear();
+
+ return sb.toString();
+ }
+
+ public static void importConfigation(String input) {
+ className_to_subtype.clear();
+
+ try {
+ BufferedReader br = new BufferedReader(new StringReader(input));
+
+ while ( true ) {
+ String line = br.readLine();
+ if ( line == null )
+ break;
+ if ( (line = line.trim()).isEmpty() )
+ continue;
+
+ StringTokenizer st = new StringTokenizer(line, "\t");
+
+ String type = st.nextToken();
+ if ( type.equals("class") ) {
+ String className = st.nextToken();
+ int sizeof = Integer.parseInt(st.nextToken());
+ int align = Integer.parseInt(st.nextToken());
+
+ className_to_subtype.put(className, new MappedSubtypeInfo(className, sizeof, align));
+ } else if ( type.equals("field") ) {
+ MappedObjectTransformer.MappedSubtypeInfo info = className_to_subtype.get(st.nextToken());
+ String methodName = st.nextToken();
+ int off = Integer.parseInt(st.nextToken());
+ int len = Integer.parseInt(st.nextToken());
+
+ info.fieldToOffset.put(methodName, Long.valueOf(off));
+ info.fieldToLength.put(methodName, Long.valueOf(len));
+ } else {
+ throw new IllegalStateException(type);
+ }
+ }
+ } catch (IOException exc) {
+ throw new IllegalStateException("never happens");
+ }
+ }
+
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-12 20:59:34
|
Revision: 3580
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3580&view=rev
Author: spasi
Date: 2011-07-12 20:59:27 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Added some new ES extensions.
Added Paths:
-----------
trunk/LWJGL/src/templates/org/lwjgl/opengles/EXT_unpack_subimage.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_draw_buffers.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_read_depth_stencil.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_texture_compression_s3tc_update.java
trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_texture_npot_2D_mipmap.java
Added: trunk/LWJGL/src/templates/org/lwjgl/opengles/EXT_unpack_subimage.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengles/EXT_unpack_subimage.java (rev 0)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengles/EXT_unpack_subimage.java 2011-07-12 20:59:27 UTC (rev 3580)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2002-2011 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.opengles;
+
+public interface EXT_unpack_subimage {
+
+ /**
+ * Accepted by the <pname> parameters of PixelStorei, GetIntegerv, and
+ * GetFloatv:
+ */
+ int GL_UNPACK_ROW_LENGTH = 0x0CF2,
+ GL_UNPACK_SKIP_ROWS = 0x0CF3,
+ GL_UNPACK_SKIP_PIXELS = 0x0CF4;
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_draw_buffers.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_draw_buffers.java (rev 0)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_draw_buffers.java 2011-07-12 20:59:27 UTC (rev 3580)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2002-2011 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.opengles;
+
+import org.lwjgl.util.generator.Alternate;
+import org.lwjgl.util.generator.AutoSize;
+import org.lwjgl.util.generator.Const;
+import org.lwjgl.util.generator.Constant;
+import org.lwjgl.util.generator.opengl.GLenum;
+import org.lwjgl.util.generator.opengl.GLsizei;
+
+import java.nio.IntBuffer;
+
+public interface NV_draw_buffers {
+
+ /**
+ * Accepted by the <pname> parameters of GetIntegerv, GetFloatv,
+ * and GetDoublev:
+ */
+ int GL_MAX_DRAW_BUFFERS_NV = 0x8824,
+ GL_DRAW_BUFFER0_NV = 0x8825,
+ GL_DRAW_BUFFER1_NV = 0x8826,
+ GL_DRAW_BUFFER2_NV = 0x8827,
+ GL_DRAW_BUFFER3_NV = 0x8828,
+ GL_DRAW_BUFFER4_NV = 0x8829,
+ GL_DRAW_BUFFER5_NV = 0x882A,
+ GL_DRAW_BUFFER6_NV = 0x882B,
+ GL_DRAW_BUFFER7_NV = 0x882C,
+ GL_DRAW_BUFFER8_NV = 0x882D,
+ GL_DRAW_BUFFER9_NV = 0x882E,
+ GL_DRAW_BUFFER10_NV = 0x882F,
+ GL_DRAW_BUFFER11_NV = 0x8830,
+ GL_DRAW_BUFFER12_NV = 0x8831,
+ GL_DRAW_BUFFER13_NV = 0x8832,
+ GL_DRAW_BUFFER14_NV = 0x8833,
+ GL_DRAW_BUFFER15_NV = 0x8834;
+
+ /** Accepted by the <bufs> parameter of DrawBuffersNV: */
+ int GL_COLOR_ATTACHMENT0_NV = 0x8CE0,
+ GL_COLOR_ATTACHMENT1_NV = 0x8CE1,
+ GL_COLOR_ATTACHMENT2_NV = 0x8CE2,
+ GL_COLOR_ATTACHMENT3_NV = 0x8CE3,
+ GL_COLOR_ATTACHMENT4_NV = 0x8CE4,
+ GL_COLOR_ATTACHMENT5_NV = 0x8CE5,
+ GL_COLOR_ATTACHMENT6_NV = 0x8CE6,
+ GL_COLOR_ATTACHMENT7_NV = 0x8CE7,
+ GL_COLOR_ATTACHMENT8_NV = 0x8CE8,
+ GL_COLOR_ATTACHMENT9_NV = 0x8CE9,
+ GL_COLOR_ATTACHMENT10_NV = 0x8CEA,
+ GL_COLOR_ATTACHMENT11_NV = 0x8CEB,
+ GL_COLOR_ATTACHMENT12_NV = 0x8CEC,
+ GL_COLOR_ATTACHMENT13_NV = 0x8CED,
+ GL_COLOR_ATTACHMENT14_NV = 0x8CEE,
+ GL_COLOR_ATTACHMENT15_NV = 0x8CEF;
+
+ void glDrawBuffersNV(@AutoSize("bufs") @GLsizei int n, @Const @GLenum IntBuffer bufs);
+
+ @Alternate("glDrawBuffersNV")
+ void glDrawBuffersNV(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, buf), 0", keepParam = true) int buf);
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_read_depth_stencil.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_read_depth_stencil.java (rev 0)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_read_depth_stencil.java 2011-07-12 20:59:27 UTC (rev 3580)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2002-2011 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.opengles;
+
+public interface NV_read_depth_stencil {
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_texture_compression_s3tc_update.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_texture_compression_s3tc_update.java (rev 0)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_texture_compression_s3tc_update.java 2011-07-12 20:59:27 UTC (rev 3580)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2002-2011 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.opengles;
+
+public interface NV_texture_compression_s3tc_update {
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_texture_npot_2D_mipmap.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_texture_npot_2D_mipmap.java (rev 0)
+++ trunk/LWJGL/src/templates/org/lwjgl/opengles/NV_texture_npot_2D_mipmap.java 2011-07-12 20:59:27 UTC (rev 3580)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2002-2011 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.opengles;
+
+public interface NV_texture_npot_2D_mipmap {
+
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-12 20:47:52
|
Revision: 3579
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3579&view=rev
Author: spasi
Date: 2011-07-12 20:47:46 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Added support for EXT_atomic_counter_32/64.
Added Paths:
-----------
trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_atomic_counters_32.java
trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_atomic_counters_64.java
Added: trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_atomic_counters_32.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_atomic_counters_32.java (rev 0)
+++ trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_atomic_counters_32.java 2011-07-12 20:47:46 UTC (rev 3579)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2002-2010 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.opencl;
+
+import org.lwjgl.util.generator.opencl.CLDeviceExtension;
+
+@CLDeviceExtension
+public interface EXT_atomic_counters_32 {
+
+ /** CLDevice query: Max number of atomic counters that can be used by a kernel. */
+ int CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT = 0x4032;
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_atomic_counters_64.java
===================================================================
--- trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_atomic_counters_64.java (rev 0)
+++ trunk/LWJGL/src/templates/org/lwjgl/opencl/EXT_atomic_counters_64.java 2011-07-12 20:47:46 UTC (rev 3579)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2002-2010 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.opencl;
+
+import org.lwjgl.util.generator.opencl.CLDeviceExtension;
+
+@CLDeviceExtension
+public interface EXT_atomic_counters_64 {
+
+ /** CLDevice query: Max number of atomic counters that can be used by a kernel. */
+ int CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT = 0x4032;
+
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-12 20:40:11
|
Revision: 3578
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3578&view=rev
Author: spasi
Date: 2011-07-12 20:40:05 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Added bounds check to copyRange.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-12 19:29:15 UTC (rev 3577)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-12 20:40:05 UTC (rev 3578)
@@ -106,6 +106,11 @@
}
public static void copy(MappedObject src, MappedObject dst, int bytes) {
+ if ( MappedObject.CHECKS ) {
+ src.checkRange(bytes);
+ dst.checkRange(bytes);
+ }
+
MappedObjectUnsafe.INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 19:29:15 UTC (rev 3577)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 20:40:05 UTC (rev 3578)
@@ -33,6 +33,7 @@
import org.lwjgl.LWJGLUtil;
+import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
/**
@@ -97,10 +98,19 @@
}
final void checkAddress(final long address) {
- if ( preventGC.capacity() < (address - MappedObjectUnsafe.getBufferBaseAddress(preventGC) + stride) )
+ final long base = MappedObjectUnsafe.getBufferBaseAddress(preventGC);
+ if ( address < base || preventGC.capacity() < (address - base + stride) )
throw new IndexOutOfBoundsException();
}
+ final void checkRange(final int bytes) {
+ if ( bytes < 0 )
+ throw new IllegalArgumentException();
+
+ if ( preventGC.capacity() < (viewAddress - MappedObjectUnsafe.getBufferBaseAddress(preventGC) + bytes) )
+ throw new BufferOverflowException();
+ }
+
/**
* Creates a MappedObject instance, mapping the memory region of the specified direct ByteBuffer.
* <p/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|