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: <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.
|
|
From: <sp...@us...> - 2011-07-12 19:29:22
|
Revision: 3577
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3577&view=rev
Author: spasi
Date: 2011-07-12 19:29:15 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Added friendly error message when a non-static inner class is registered with the transformer.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.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 18:30:56 UTC (rev 3576)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-12 19:29:15 UTC (rev 3577)
@@ -40,8 +40,8 @@
*/
public class MappedForeach<T extends MappedObject> implements Iterable<T> {
- private final T mapped;
- private final int elementCount;
+ final T mapped;
+ final int elementCount;
MappedForeach(T mapped, int elementCount) {
this.mapped = mapped;
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 18:30:56 UTC (rev 3576)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 19:29:15 UTC (rev 3577)
@@ -36,7 +36,7 @@
static final boolean PRINT_ACTIVITY = false;//LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintActivity");
static final boolean PRINT_BYTECODE = false; //LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode");
- private static final Map<String, MappedSubtypeInfo> className_to_subtype;
+ static final Map<String, MappedSubtypeInfo> className_to_subtype;
static {
className_to_subtype = new HashMap<String, MappedSubtypeInfo>();
@@ -80,6 +80,9 @@
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);
MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, mapped.sizeof(), mapped.align());
@@ -88,7 +91,7 @@
for ( Field field : type.getDeclaredFields() ) {
// static fields are never mapped
- if ( (field.getModifiers() & Modifier.STATIC) != 0 )
+ if ( Modifier.isStatic(field.getModifiers()) )
continue;
// we only support primitives and ByteBuffers
@@ -135,7 +138,7 @@
}
}
- private static final String view_constructor_method = "_construct_view_";
+ static final String view_constructor_method = "_construct_view_";
static byte[] transformFieldAccess(final String className, byte[] bytecode) {
int flags = 0;//ClassWriter.COMPUTE_FRAMES;
@@ -525,7 +528,7 @@
}
}
- private static void pushInt(MethodVisitor mv, int value) {
+ static void pushInt(MethodVisitor mv, int value) {
if ( value == -1 )
mv.visitInsn(ICONST_M1);
else if ( value == 0 )
@@ -548,7 +551,7 @@
mv.visitLdcInsn(Integer.valueOf(value));
}
- private static String jvmClassName(Class<?> type) {
+ static String jvmClassName(Class<?> type) {
return type.getName().replace('.', '/');
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <riv...@us...> - 2011-07-12 18:31:02
|
Revision: 3576
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3576&view=rev
Author: riven-lwjgl
Date: 2011-07-12 18:30:56 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
First attempt at manual computation of stack frames
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-12 17:49:58 UTC (rev 3575)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 18:30:56 UTC (rev 3576)
@@ -138,7 +138,7 @@
private static final String view_constructor_method = "_construct_view_";
static byte[] transformFieldAccess(final String className, byte[] bytecode) {
- int flags = ClassWriter.COMPUTE_FRAMES;
+ int flags = 0;//ClassWriter.COMPUTE_FRAMES;
ClassWriter writer = new ClassWriter(flags);
@@ -224,6 +224,14 @@
super.visitTypeInsn(opcode, typeName);
}
+
+ private int requireExtraStack = 0;
+
+ @Override
+ public void visitMaxs(int maxStack, int maxLocals)
+ {
+ super.visitMaxs(maxStack+this.requireExtraStack, maxLocals);
+ }
@Override
public void visitMethodInsn(int opcode, String className, String methodName, String signature) {
@@ -241,7 +249,7 @@
if ( (isMapDirectMethod || isMapBufferMethod) || isMallocMethod ) {
if ( isMallocMethod ) {
- // stack: count
+ // stack: count
pushInt(super.mv, mappedType.sizeof);
// stack: sizeof, count
super.visitInsn(IMUL);
@@ -271,6 +279,7 @@
// 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;
}
@@ -284,6 +293,7 @@
// 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;
}
@@ -297,6 +307,7 @@
// 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;
}
@@ -308,6 +319,7 @@
// stack: this, this
super.visitMethodInsn(INVOKEVIRTUAL, className, view_constructor_method, "()V");
// stack: this
+ this.requireExtraStack = 2;
return;
}
@@ -319,6 +331,7 @@
// 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;
}
@@ -330,6 +343,7 @@
// 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;
}
}
@@ -458,30 +472,50 @@
if ( opcode == GETFIELD ) {
Long fieldLength = mappedSubtype.fieldToLength.get(fieldName);
+ // stack: ref
super.visitFieldInsn(GETFIELD, mappedSubtype.className, "viewAddress", "J");
+ // stack: long
super.visitLdcInsn(fieldOffset);
+ // stack: long, long
super.visitInsn(LADD);
+ // stack: long
super.visitLdcInsn(fieldLength);
+ // stack: long, long
super.visitInsn(L2I);
+ // 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
super.visitInsn(SWAP);
+ // stack: ref, value
super.visitFieldInsn(GETFIELD, mappedSubtype.className, "viewAddress", "J");
+ // stack: long, value
super.visitLdcInsn(fieldOffset);
+ // stack: long, long, value
super.visitInsn(LADD);
+ // 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
super.visitFieldInsn(GETFIELD, mappedSubtype.className, "viewAddress", "J");
+ // stack: long
super.visitLdcInsn(fieldOffset);
+ // stack: long, long
super.visitInsn(LADD);
+ // stack: long
super.visitMethodInsn(INVOKESTATIC, jvmClassName(MappedHelper.class), typeName.toLowerCase() + "get", "(J)" + typeName);
+ // stack: value
+ this.requireExtraStack = 4;
return;
}
@@ -511,7 +545,7 @@
else if ( value >= Short.MIN_VALUE && value <= Short.MAX_VALUE )
mv.visitIntInsn(SIPUSH, value);
else
- mv.visitLdcInsn(value);
+ mv.visitLdcInsn(Integer.valueOf(value));
}
private static String jvmClassName(Class<?> type) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <riv...@us...> - 2011-07-12 17:50:04
|
Revision: 3575
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3575&view=rev
Author: riven-lwjgl
Date: 2011-07-12 17:49:58 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Test case showing problems on loading library (64 vs 32 bit)
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectWithLibrary.java
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectWithLibrary.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectWithLibrary.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectWithLibrary.java 2011-07-12 17:49:58 UTC (rev 3575)
@@ -0,0 +1,18 @@
+/*
+ * Created on Jul 12, 2011
+ */
+
+package org.lwjgl.test.mapped;
+
+import java.io.File;
+
+import org.lwjgl.opengl.Display;
+
+public class MappedObjectWithLibrary
+{
+ 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-12 15:36:16 UTC (rev 3574)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-12 17:49:58 UTC (rev 3575)
@@ -44,7 +44,7 @@
throw new RuntimeException("Asserts must be enabled for this test.");
}
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception {
MappedObjectTransformer.register(MappedFloat.class);
MappedObjectTransformer.register(MappedVec2.class);
MappedObjectTransformer.register(MappedVec3.class);
@@ -70,6 +70,8 @@
MappedObjectTests3.testForeach();
MappedObjectTests3.testConstructor();
MappedObjectTests3.testMappedSet();
+
+ MappedObjectWithLibrary.testLWJGL();
}
}
\ 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-12 15:36:16 UTC (rev 3574)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 17:49:58 UTC (rev 3575)
@@ -50,7 +50,7 @@
*/
public class MappedObject {
- static final boolean CHECKS = LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.Checks");
+ static final boolean CHECKS = false;//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 15:36:16 UTC (rev 3574)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 17:49:58 UTC (rev 3575)
@@ -32,8 +32,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 = 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_BYTECODE = false; //LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode");
private static final Map<String, MappedSubtypeInfo> className_to_subtype;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-12 15:36:22
|
Revision: 3574
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3574&view=rev
Author: spasi
Date: 2011-07-12 15:36:16 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Added GLES classes on which Display depends to the main jar.
Modified Paths:
--------------
trunk/LWJGL/build.xml
trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGL.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableLWJGL.java
trunk/LWJGL/src/java/org/lwjgl/opengl/PixelFormatLWJGL.java
Modified: trunk/LWJGL/build.xml
===================================================================
--- trunk/LWJGL/build.xml 2011-07-12 14:21:29 UTC (rev 3573)
+++ trunk/LWJGL/build.xml 2011-07-12 15:36:16 UTC (rev 3574)
@@ -143,6 +143,12 @@
<!-- Create lwjgl.jar -->
<jar destfile="${lwjgl.temp}/jar/lwjgl.jar" taskname="lwjgl.jar">
<fileset refid="lwjgl.fileset" />
+ <fileset dir="${lwjgl.bin}"> <!-- Display has a dependency on these -->
+ <patternset>
+ <include name="org/lwjgl/opengles/ContextAttribs.*"/>
+ <include name="org/lwjgl/opengles/PixelFormat.*"/>
+ </patternset>
+ </fileset>
<manifest>
<attribute name="Sealed" value="true"/>
</manifest>
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGL.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGL.java 2011-07-12 14:21:29 UTC (rev 3573)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGL.java 2011-07-12 15:36:16 UTC (rev 3574)
@@ -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.opengl;
import org.lwjgl.LWJGLException;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java 2011-07-12 14:21:29 UTC (rev 3573)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableGLES.java 2011-07-12 15:36:16 UTC (rev 3574)
@@ -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.opengl;
import org.lwjgl.LWJGLException;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableLWJGL.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableLWJGL.java 2011-07-12 14:21:29 UTC (rev 3573)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DrawableLWJGL.java 2011-07-12 15:36:16 UTC (rev 3574)
@@ -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.opengl;
import org.lwjgl.LWJGLException;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/PixelFormatLWJGL.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/PixelFormatLWJGL.java 2011-07-12 14:21:29 UTC (rev 3573)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/PixelFormatLWJGL.java 2011-07-12 15:36:16 UTC (rev 3574)
@@ -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.opengl;
/**
@@ -4,7 +35,6 @@
* [INTERNAL USE ONLY]
*
* @author Spasi
- * @since 15/5/2011
*/
public interface PixelFormatLWJGL {
// Marker interface
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-12 14:21:36
|
Revision: 3573
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3573&view=rev
Author: spasi
Date: 2011-07-12 14:21:29 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Changed mapping behavior to be consistent with the LWJGL API; it now starts at the buffer's current .position().
Reverted client JVM warning to use serr instead of LWJGLUtil.log, for extra visibility when Debug is disabled.
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/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-12 13:44:13 UTC (rev 3572)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-12 14:21:29 UTC (rev 3573)
@@ -117,6 +117,19 @@
} catch (IndexOutOfBoundsException e) {
// expected, ignore
}
+
+ try {
+ ByteBuffer posTest = ByteBuffer.allocateDirect(200);
+ posTest.position(10 * MappedFloat.SIZEOF); // position > 0
+
+ MappedFloat vecs2 = MappedFloat.map(posTest);
+ vecs2.view = 39;
+ assert vecs2.view == 39;
+ vecs2.view = 40;
+ System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
+ } catch (IndexOutOfBoundsException e) {
+ // expected, ignore
+ }
}
// test dup
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-12 13:44:13 UTC (rev 3572)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-12 14:21:29 UTC (rev 3573)
@@ -60,7 +60,7 @@
throw new IllegalStateException("sizeof not a multiple of alignment");
mo.stride = sizeof;
- long addr = MappedObjectUnsafe.getBufferBaseAddress(buffer);
+ long addr = MappedObjectUnsafe.getBufferBaseAddress(buffer) + buffer.position();
if ( addr % align != 0 )
throw new IllegalStateException("buffer address not aligned on " + align + " bytes");
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 13:44:13 UTC (rev 3572)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 14:21:29 UTC (rev 3573)
@@ -62,7 +62,7 @@
String vmName = System.getProperty("java.vm.name");
if ( vmName != null && !vmName.contains("Server") ) {
- LWJGLUtil.log("Warning: " + MappedObject.class.getSimpleName() + "s have inferiour performance on Client VMs, please consider switching to a Server VM.");
+ System.err.println("Warning: " + MappedObject.class.getSimpleName() + "s have inferiour performance on Client VMs, please consider switching to a Server VM.");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-12 13:44:19
|
Revision: 3572
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3572&view=rev
Author: spasi
Date: 2011-07-12 13:44:13 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Fixed bounds checking to work with .sliced mapped objects.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-12 13:29:04 UTC (rev 3571)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-12 13:44:13 UTC (rev 3572)
@@ -89,17 +89,34 @@
vecs.view = 0;
}
- // test bound check
+ // test bounds checking
{
assert (vecs.view == 0);
try {
+ vecs.view = 49;
+ assert vecs.view == 49;
+ vecs.view = 0;
vecs.view = 50;
System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
vecs.view = 0;
} catch (IndexOutOfBoundsException e) {
// expected, ignore
}
+
assert (vecs.view == 0);
+
+ try {
+ vecs.view = 10;
+ MappedFloat vecs2 = vecs.slice();
+ vecs.view = 0;
+
+ vecs2.view = 39;
+ assert vecs2.view == 39;
+ vecs2.view = 40;
+ System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
+ } catch (IndexOutOfBoundsException e) {
+ // expected, ignore
+ }
}
// test dup
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 13:29:04 UTC (rev 3571)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 13:44:13 UTC (rev 3572)
@@ -97,7 +97,7 @@
}
final void checkAddress(final long address) {
- if ( preventGC.capacity() < (address + stride - baseAddress) )
+ if ( preventGC.capacity() < (address - MappedObjectUnsafe.getBufferBaseAddress(preventGC) + stride) )
throw new IndexOutOfBoundsException();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-12 13:29:14
|
Revision: 3571
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3571&view=rev
Author: spasi
Date: 2011-07-12 13:29:04 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Mapped object code improvements: added license, additional documentation, reformatted code, now using LWJGLUtil.log instead of System.err.
Added system properties for bytecode transformer debug output. (org.lwjgl.util.mapped.PrintTiming & org.lwjgl.util.mapped.PrintActivity)
Added support for bounds checking the view of mapped objects. Enabled with org.lwjgl.util.mapped.Checks
Added tests for mapped objects. (org.lwjgl.test.mapped package)
Added "[LWJGL] " prefix to all LWJGL generated debug messages.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.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/MappedObjectUnsafe.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedSet.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
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedType.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.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/test/mapped/MappedObjectTests2.java
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.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
Modified: trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2011-07-12 07:27:00 UTC (rev 3570)
+++ trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -448,7 +448,7 @@
/**
* Gets a boolean property as a privileged action.
*/
- private static boolean getPrivilegedBoolean(final String property_name) {
+ public static boolean getPrivilegedBoolean(final String property_name) {
Boolean value = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
return Boolean.getBoolean(property_name);
@@ -464,7 +464,7 @@
*/
public static void log(String msg) {
if (DEBUG) {
- System.err.println(msg);
+ System.err.println("[LWJGL] " + msg);
}
}
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedFloat.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -0,0 +1,56 @@
+/*
+ * 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.util.mapped.MappedObject;
+import org.lwjgl.util.mapped.MappedType;
+
+/** @author Riven */
+@MappedType(sizeof = 4)
+public class MappedFloat extends MappedObject {
+
+ public MappedFloat() {
+ this.test();
+ }
+
+ public float value;
+
+ public void test() {
+ this.value = 4;
+ }
+
+ @Override
+ public String toString() {
+ return "MappedFloat[" + value + "]";
+ }
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectBench.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -0,0 +1,237 @@
+/*
+ * 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.util.mapped.MappedObjectUnsafe;
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import static org.lwjgl.util.mapped.MappedHelper.*;
+
+/** @author Riven */
+@SuppressWarnings("static-access")
+public class MappedObjectBench {
+
+ static class InstanceVec3 {
+
+ float x, y, z;
+
+ @Override
+ public String toString() {
+ return "InstanceVec3[" + x + ", " + y + ", " + z + "]";
+ }
+ }
+
+ static class ArrayVec3 {
+
+ float[] a;
+ int i;
+
+ @Override
+ public String toString() {
+ return "ArrayVec3[" + a[i * 3 + 0] + ", " + a[i * 3 + 1] + ", " + a[i * 3 + 2] + "]";
+ }
+ }
+
+ static void benchmarkInstances() {
+ final int runs = 64;
+ final int iterations = 64 * 1024;
+
+ InstanceVec3 vec1 = new InstanceVec3();
+ InstanceVec3 vec2 = new InstanceVec3();
+ InstanceVec3 vec3 = new InstanceVec3();
+
+ long[] took = new long[runs];
+ for ( int run = 0; run < runs; run++ ) {
+ long t0 = System.nanoTime();
+ for ( int iteration = 0; iteration < iterations; iteration++ ) {
+ vec1.x = 13;
+ vec1.y += vec1.y * vec1.x + 0.3f;
+ vec1.z += vec2.y + vec1.x + 0.3f;
+ vec2.z += vec2.y + vec1.x;
+ vec3.z += vec2.z + vec1.y;
+ }
+ long t1 = System.nanoTime();
+ took[run] = t1 - t0;
+ }
+
+ Arrays.sort(took);
+ System.out.println("instance took: " + took[took.length / 2] / 1024 + "us");
+
+ System.out.println(vec1);
+ System.out.println(vec2);
+ System.out.println(vec3);
+ }
+
+ static void benchmarkMapped() {
+ final int runs = 64;
+ final int iterations = 64 * 1024;
+
+ ByteBuffer bb = ByteBuffer.allocateDirect(200);
+
+ MappedVec3 vecs = MappedVec3.map(bb);
+
+ MappedVec3 vec1 = vecs.dup();
+ MappedVec3 vec2 = vecs.dup();
+ MappedVec3 vec3 = vecs.dup();
+
+ vec1.view = 0;
+ vec2.view = 1;
+ vec3.view = 2;
+
+ long[] took = new long[runs];
+ for ( int run = 0; run < runs; run++ ) {
+ long t0 = System.nanoTime();
+ for ( int iteration = 0; iteration < iterations; iteration += 2 ) {
+ vec1.x = 13;
+ vec1.y += vec1.y * vec1.x + 0.3f;
+ vec1.z += vec2.y + vec1.x + 0.3f;
+ vec2.z += vec2.y + vec1.x;
+ vec3.z += vec2.z + vec1.y;
+
+ vec1.x = 13;
+ vec1.y += vec1.y * vec1.x + 0.3f;
+ vec1.z += vec2.y + vec1.x + 0.3f;
+ vec2.z += vec2.y + vec1.x;
+ vec3.z += vec2.z + vec1.y;
+ }
+ long t1 = System.nanoTime();
+ took[run] = t1 - t0;
+ }
+
+ Arrays.sort(took);
+ System.out.println("mapped took: " + took[took.length / 2] / 1024 + "us");
+
+ System.out.println(vec1);
+ System.out.println(vec2);
+ System.out.println(vec3);
+
+ System.out.println(bb);
+ }
+
+ static void benchmarkIndirectArray() {
+ final int runs = 64;
+ final int iterations = 64 * 1024;
+
+ float[] bb = new float[200];
+
+ ArrayVec3 vec1 = new ArrayVec3();
+ ArrayVec3 vec2 = new ArrayVec3();
+ ArrayVec3 vec3 = new ArrayVec3();
+
+ vec1.a = bb;
+ vec2.a = bb;
+ vec3.a = bb;
+
+ vec1.i = 0;
+ vec2.i = 1;
+ vec3.i = 2;
+
+ long[] took = new long[runs];
+ for ( int run = 0; run < runs; run++ ) {
+ long t0 = System.nanoTime();
+ for ( int iteration = 0; iteration < iterations; iteration++ ) {
+ vec1.a[vec1.i * 3 + 0] = 13;
+ vec1.a[vec1.i * 3 + 1] += vec1.a[vec1.i * 3 + 1] * vec1.a[vec1.i * 3 + 0] + 0.3f;
+ vec1.a[vec1.i * 3 + 2] += vec2.a[vec2.i * 3 + 1] + vec1.a[vec1.i * 3 + 0] + 0.3f;
+ vec2.a[vec2.i * 3 + 2] += vec2.a[vec2.i * 3 + 1] + vec1.a[vec1.i * 3 + 0];
+ vec3.a[vec3.i * 3 + 2] += vec2.a[vec2.i * 3 + 2] + vec2.a[vec2.i * 3 + 1];
+ }
+ long t1 = System.nanoTime();
+ took[run] = t1 - t0;
+ }
+
+ Arrays.sort(took);
+ System.out.println("array took: " + took[took.length / 2] / 1024 + "us");
+
+ System.out.println(vec1);
+ System.out.println(vec2);
+ System.out.println(vec3);
+
+ System.out.println(bb);
+ }
+
+ static void benchmarkDirectArray() {
+ final int runs = 64;
+ final int iterations = 64 * 1024;
+
+ float[] bb = new float[200];
+
+ long[] took = new long[runs];
+ for ( int run = 0; run < runs; run++ ) {
+ long t0 = System.nanoTime();
+ for ( int iteration = 0; iteration < iterations; iteration++ ) {
+ bb[1 * 3 + 0] = 13;
+ bb[1 * 3 + 1] += bb[1 * 3 + 1] * bb[1 * 3 + 0] + 0.3f;
+ bb[1 * 3 + 2] += bb[2 * 3 + 1] + bb[1 * 3 + 0] + 0.3f;
+ bb[2 * 3 + 2] += bb[2 * 3 + 1] + bb[1 * 3 + 0];
+ bb[3 * 3 + 2] += bb[2 * 3 + 2] + bb[2 * 3 + 1];
+ }
+ long t1 = System.nanoTime();
+ took[run] = t1 - t0;
+ }
+
+ Arrays.sort(took);
+ System.out.println("array2 took: " + took[took.length / 2] / 1024 + "us");
+
+ System.out.println(bb);
+ }
+
+ static void benchmarkUnsafe() {
+ final int runs = 64;
+ final int iterations = 64 * 1024;
+
+ ByteBuffer bb = ByteBuffer.allocateDirect(200);
+ long addr = MappedObjectUnsafe.getBufferBaseAddress(bb);
+
+ long[] took = new long[runs];
+ for ( int run = 0; run < runs; run++ ) {
+ long t0 = System.nanoTime();
+ for ( int iteration = 0; iteration < iterations; iteration++ ) {
+ fput(13, addr + (1 * 3 + 0) * 4);
+ fput(fget(addr + (1 * 3 + 1) * 4) + fget(addr + (1 * 3 + 1) * 4) * fget(addr + (1 * 3 + 0) * 4) + 0.3f, addr + (1 * 3 + 1) * 4);
+ fput(fget(addr + (1 * 3 + 2) * 4) + fget(addr + (2 * 3 + 1) * 4) + fget(addr + (1 * 3 + 0) * 4) + 0.3f, addr + (1 * 3 + 2) * 4);
+ fput(fget(addr + (2 * 3 + 2) * 4) + fget(addr + (2 * 3 + 1) * 4) + fget(addr + (1 * 3 + 0) * 4), addr + (2 * 3 + 2) * 4);
+ fput(fget(addr + (3 * 3 + 2) * 4) + fget(addr + (2 * 3 + 2) * 4) + fget(addr + (2 * 3 + 1) * 4), addr + (3 * 3 + 2) * 4);
+ }
+ long t1 = System.nanoTime();
+ took[run] = t1 - t0;
+ }
+
+ Arrays.sort(took);
+ System.out.println("unsafe took: " + took[took.length / 2] / 1024 + "us");
+
+ System.out.println(bb);
+ }
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -0,0 +1,159 @@
+/*
+ * 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.util.mapped.MappedHelper;
+import org.lwjgl.util.mapped.MappedObjectUnsafe;
+
+import java.nio.ByteBuffer;
+
+/** @author Riven */
+@SuppressWarnings("static-access")
+public class MappedObjectTests1 {
+
+ static class Test {
+
+ int value;
+ }
+
+ static void testViewField() {
+ Test test = new Test();
+ test.value = 13;
+ test.value += 1;
+ test.value++;
+ System.out.println(test);
+
+ ByteBuffer bb = ByteBuffer.allocateDirect(200);
+ MappedFloat vecs = MappedFloat.map(bb);
+
+ // verify 'malloc' and SIZEOF
+ {
+ MappedFloat vecs1 = MappedFloat.malloc(1234);
+
+ assert (vecs1.stride == MappedFloat.SIZEOF);
+ assert (vecs1.stride * 1234 == vecs1.backingByteBuffer().capacity());
+ assert (MappedFloat.SIZEOF * 1234 == vecs1.backingByteBuffer().capacity());
+ }
+
+ // manipulate 'mapped.value'
+ {
+ assert (vecs.value == 0.0f); // 4.0 is set in constructor, but runViewConstructor is not called
+ vecs.value = 1.1f;
+ assert (vecs.value == 1.1f);
+ }
+
+ // manipulate 'view' with assignment
+ {
+ assert (vecs.view == 0);
+ vecs.view = 1;
+ assert (vecs.view == 1);
+ assert (vecs.value != 1.1f); // old view
+ vecs.view = 0;
+ }
+
+ // manipulate 'view' with iinc
+ {
+ assert (vecs.view == 0);
+ vecs.view++;
+ assert (vecs.view == 1);
+ assert (vecs.value != 1.1f); // old view
+ vecs.view = 0;
+ }
+
+ // test bound check
+ {
+ assert (vecs.view == 0);
+ try {
+ vecs.view = 50;
+ System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
+ vecs.view = 0;
+ } catch (IndexOutOfBoundsException e) {
+ // expected, ignore
+ }
+ assert (vecs.view == 0);
+ }
+
+ // 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);
+ ByteBuffer bb2 = MappedHelper.newBuffer(addr1, bb.capacity());
+ long addr2 = MappedObjectUnsafe.getBufferBaseAddress(bb);
+
+ System.out.println(bb);
+ System.out.println(bb2);
+ System.out.println(addr1);
+ System.out.println(addr2);
+ }
+
+ // test 'copy'
+ {
+ vecs.value = 13.37f;
+ MappedFloat dec2 = vecs.dup();
+ dec2.view = 1;
+ System.out.println(vecs);
+ System.out.println(dec2);
+ vecs.copyTo(dec2);
+ System.out.println(vecs);
+ System.out.println(dec2);
+ assert (dec2.value == 13.37f);
+
+ vecs.value = 73.31f;
+ vecs.copyRange(dec2, 1);
+ assert (dec2.value == 73.31f);
+ }
+ }
+}
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests2.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -0,0 +1,130 @@
+/*
+ * 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 java.nio.ByteBuffer;
+
+/** @author Riven */
+@SuppressWarnings("static-access")
+public class MappedObjectTests2 {
+
+ static void testWriteFieldAccess(MappedVec3 vecs) {
+ // write access results into a transform-time IllegalAccessException
+
+ System.out.println(vecs.baseAddress); // test read-access
+
+ System.out.println(vecs.viewAddress); // test read-access
+
+ System.out.println(vecs.align); // test read-access
+
+ System.out.println(MappedVec3.SIZEOF); // test read-access
+ }
+
+ static void testFields() {
+ ByteBuffer bb = ByteBuffer.allocateDirect(200);
+ MappedVec3 vecs = MappedVec3.map(bb);
+
+ testWriteFieldAccess(vecs);
+
+ vecs.x = 13.13f;
+ vecs.y = 14.14f;
+ vecs.z = 15.15f;
+
+ System.out.println(vecs.viewAddress);
+
+ assert (vecs.x == 13.13f);
+ assert (vecs.y == 14.14f);
+ assert (vecs.z == 15.15f);
+
+ vecs.view = 0;
+
+ assert (vecs.x == 13.13f);
+ assert (vecs.y == 14.14f);
+ assert (vecs.z == 15.15f);
+
+ System.out.println(vecs);
+ vecs.view = 1;
+ System.out.println(vecs);
+
+ assert (vecs.x == 0.0f);
+ assert (vecs.y == 0.0f);
+ assert (vecs.z == 0.0f);
+
+ // now it becomes weird: offsets and strides
+
+ vecs.view = 1;
+ vecs.x = 0.1234f;
+ vecs.view = 0;
+
+ // test stride & sizeof
+ {
+ long a1 = vecs.viewAddress;
+ vecs.view = 1;
+ long a2 = vecs.viewAddress;
+ assert (a2 - a1 == MappedVec3.SIZEOF);
+ assert (a2 - a1 == vecs.stride);
+ 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
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests3.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -0,0 +1,123 @@
+/*
+ * 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.util.mapped.*;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+import static org.lwjgl.util.mapped.MappedObject.*;
+
+/** @author Riven */
+@SuppressWarnings("static-access")
+public class MappedObjectTests3 {
+
+ static void testMappedBuffer() {
+ int elementCount = 4;
+
+ MappedSomething some = MappedSomething.malloc(elementCount);
+
+ assert (some.data != some.data);
+
+ long addr1 = MappedObjectUnsafe.getBufferBaseAddress(some.backingByteBuffer());
+
+ ByteBuffer mapped = some.data; // creates new ByteBuffer instance
+ long addr2 = MappedObjectUnsafe.getBufferBaseAddress(mapped);
+
+ assert (addr2 - addr1 == 4);
+ assert (mapped.capacity() == MappedSomething.SIZEOF - 4);
+
+ some.view++;
+ mapped = some.data; // creates new ByteBuffer instance
+
+ long addr3 = MappedObjectUnsafe.getBufferBaseAddress(mapped);
+ assert (addr3 - addr1 == 4 + MappedSomething.SIZEOF);
+ assert (addr3 - addr2 == 0 + MappedSomething.SIZEOF);
+ assert (mapped.capacity() == MappedSomething.SIZEOF - 4);
+ }
+
+ static void testForeach() {
+ int elementCount = 4;
+ MappedSomething some = MappedSomething.malloc(elementCount);
+
+ int i = 0;
+ for ( MappedSomething item : foreach(some, elementCount) ) {
+ assert (item.view == i++);
+ }
+ assert (some.view != elementCount);
+ System.out.println("current.view=" + some.view + ", not " + elementCount + ", as you might expect");
+ }
+
+ @MappedType(sizeof = 12)
+ public static class Xyz extends MappedObject {
+
+ int x, y, z;
+ }
+
+ static void testConstructor() {
+ int capacity = 1024;
+ ByteBuffer bb = ByteBuffer.allocateDirect(capacity).order(ByteOrder.nativeOrder());
+ long address = MappedObjectUnsafe.getBufferBaseAddress(bb);
+
+ MappedFloat mf = MappedFloat.map(address, capacity);
+
+ assert (address == mf.baseAddress);
+
+ assert (mf.value == 0.0f);
+ mf.view = 1;
+ assert (mf.value == 0.0f);
+ mf.runViewConstructor();
+ assert (mf.value == 4.0f);
+
+ Xyz.malloc(3);
+ }
+
+ static void testMappedSet() {
+ MappedVec2 vec2 = MappedVec2.malloc(3);
+ MappedVec3 vec3 = MappedVec3.malloc(3);
+
+ MappedSet2 set = MappedSet.create(vec2, vec3);
+
+ assert (vec2.view == 0);
+ assert (vec3.view == 0);
+
+ set.view = 2;
+ assert (vec2.view == 2);
+ assert (vec3.view == 2);
+
+ set.view = 0;
+ assert (vec2.view == 0);
+ assert (vec3.view == 0);
+ }
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedSomething.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -0,0 +1,55 @@
+/*
+ * 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.util.mapped.MappedField;
+import org.lwjgl.util.mapped.MappedObject;
+import org.lwjgl.util.mapped.MappedType;
+
+import java.nio.ByteBuffer;
+
+/** @author Riven */
+@MappedType(sizeof = 64)
+public class MappedSomething extends MappedObject {
+
+ @MappedField(byteOffset = 0)
+ public int used;
+
+ @MappedField(byteOffset = 4, byteLength = 64 - 4)
+ public ByteBuffer data;
+
+ @Override
+ public String toString() {
+ return "MappedSomething[" + used + "]";
+ }
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec2.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -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.test.mapped;
+
+import org.lwjgl.util.mapped.MappedObject;
+import org.lwjgl.util.mapped.MappedType;
+
+/** @author Riven */
+@MappedType(sizeof = 8)
+public class MappedVec2 extends MappedObject {
+
+ public float x;
+
+ public float y;
+
+ @Override
+ public String toString() {
+ return "MappedVec2[" + x + "," + y + "]";
+ }
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedVec3.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -0,0 +1,52 @@
+/*
+ * 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.util.mapped.MappedObject;
+import org.lwjgl.util.mapped.MappedType;
+
+/** @author Riven */
+@MappedType(sizeof = 12)
+public class MappedVec3 extends MappedObject {
+
+ public float x;
+
+ public float y;
+
+ public float z;
+
+ @Override
+ public String toString() {
+ return "[" + x + "," + y + "," + z + "]";
+ }
+
+}
\ No newline at end of file
Added: trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/TestMappedObject.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -0,0 +1,75 @@
+/*
+ * 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.util.mapped.MappedObjectClassLoader;
+import org.lwjgl.util.mapped.MappedObjectTransformer;
+
+/** @author Riven */
+public class TestMappedObject {
+
+ static {
+ boolean assertsEnabled = false;
+ assert assertsEnabled = true; // Intentional side effect!!!
+ if ( !assertsEnabled )
+ throw new RuntimeException("Asserts must be enabled for this test.");
+ }
+
+ public static void main(String[] args) {
+ MappedObjectTransformer.register(MappedFloat.class);
+ MappedObjectTransformer.register(MappedVec2.class);
+ MappedObjectTransformer.register(MappedVec3.class);
+ MappedObjectTransformer.register(MappedSomething.class);
+
+ MappedObjectTransformer.register(MappedObjectTests3.Xyz.class);
+
+ if ( MappedObjectClassLoader.fork(TestMappedObject.class, args) ) {
+ return;
+ }
+
+ MappedObjectTests1.testViewField();
+
+ MappedObjectTests2.testFields();
+
+ // MappedObjectBench.benchmarkMapped();
+ // MappedObjectBench.benchmarkInstances();
+ // MappedObjectBench.benchmarkIndirectArray();
+ // MappedObjectBench.benchmarkDirectArray();
+ // MappedObjectBench.benchmarkUnsafe();
+
+ MappedObjectTests3.testMappedBuffer();
+ MappedObjectTests3.testForeach();
+ MappedObjectTests3.testConstructor();
+ MappedObjectTests3.testMappedSet();
+ }
+
+}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java 2011-07-12 07:27:00 UTC (rev 3570)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedField.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -1,19 +1,65 @@
/*
- * Created on Jun 24, 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 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 fields of {@link MappedType} classes,
+ * 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.
+ *
* @author Riven
*/
-
@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
public @interface MappedField {
- long byteOffset();
- long byteLength() default -1;
-}
+ /**
+ * Specifies the field byte offset within the mapped object.
+ *
+ * @return the field byte offset
+ */
+ long byteOffset();
+
+ /**
+ * Specifies the field byte length. Required for {@link java.nio.ByteBuffer} fields.
+ *
+ * @return the field byte length
+ */
+ long byteLength() default -1;
+
+}
\ 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-12 07:27:00 UTC (rev 3570)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -1,52 +1,72 @@
/*
- * Created on Jul 4, 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 java.util.Iterator;
/**
+ * Iterable implementation for {@link MappedObject}.
+ *
* @author Riven
*/
+public class MappedForeach<T extends MappedObject> implements Iterable<T> {
-public class MappedForeach<T extends MappedObject> implements Iterable<T>
-{
- final T mapped;
- final int elementCount;
+ private final T mapped;
+ private final int elementCount;
- MappedForeach(T mapped, int elementCount)
- {
- this.mapped = mapped;
- this.elementCount = elementCount;
- }
+ MappedForeach(T mapped, int elementCount) {
+ this.mapped = mapped;
+ this.elementCount = elementCount;
+ }
- @Override
- public Iterator<T> iterator()
- {
- return new Iterator<T>()
- {
- private int index = 0;
+ public Iterator<T> iterator() {
+ return new Iterator<T>() {
- @Override
- public boolean hasNext()
- {
- return this.index < (MappedForeach.this.elementCount);
- }
+ private int index;
- @Override
- public T next()
- {
- mapped.viewAddress = mapped.baseAddress + (this.index++) * mapped.stride;
+ public boolean hasNext() {
+ return this.index < (MappedForeach.this.elementCount);
+ }
- return mapped;
- }
+ public T next() {
+ mapped.viewAddress = mapped.baseAddress + (this.index++) * mapped.stride;
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- };
- }
-}
+ return mapped;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+}
\ 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-12 07:27:00 UTC (rev 3570)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedHelper.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -1,181 +1,188 @@
/*
- * Created on Jun 28, 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 java.nio.ByteBuffer;
/**
+ * [INTERNAL USE ONLY]
+ * <p/>
+ * Helper class used by the bytecode transformer.
+ *
* @author Riven
*/
+public class MappedHelper {
-public class MappedHelper
-{
- public static void setup(MappedObject mo, ByteBuffer buffer, int align, int sizeof)
- {
- if (mo.baseAddress != 0L)
- throw new IllegalStateException("this method should not be called by user-code");
+ public static void setup(MappedObject mo, ByteBuffer buffer, int align, int sizeof) {
+ if ( 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())
- throw new IllegalArgumentException("bytebuffer must be direct");
- mo.preventGC = buffer;
+ if ( buffer == null )
+ throw new NullPointerException("buffer");
+ if ( !buffer.isDirect() )
+ throw new IllegalArgumentException("bytebuffer must be direct");
+ mo.preventGC = buffer;
- if (align <= 0)
- throw new IllegalArgumentException("invalid alignment");
- mo.align = align;
+ if ( align <= 0 )
+ throw new IllegalArgumentException("invalid alignment");
+ mo.align = align;
- if (sizeof % align != 0)
- throw new IllegalStateException("sizeof not a multiple of alignment");
- mo.stride = sizeof;
+ if ( sizeof % align != 0 )
+ throw new IllegalStateException("sizeof not a multiple of alignment");
+ mo.stride = sizeof;
- long addr = MappedObjectUnsafe.getBufferBaseAddress(buffer);
- if (addr % align != 0)
- throw new IllegalStateException("buffer address not aligned on " + align + " bytes");
+ long addr = MappedObjectUnsafe.getBufferBaseAddress(buffer);
+ if ( addr % align != 0 )
+ throw new IllegalStateException("buffer address not aligned on " + align + " bytes");
- mo.baseAddress = mo.viewAddress = addr;
- }
+ mo.baseAddress = mo.viewAddress = addr;
+ }
- public static void put_views(MappedSet2 set, int view)
- {
- set.view(view);
- }
+ public static void put_views(MappedSet2 set, int view) {
+ set.view(view);
+ }
- public static void put_views(MappedSet3 set, int view)
- {
- set.view(view);
- }
+ public static void put_views(MappedSet3 set, int view) {
+ set.view(view);
+ }
- public static void put_views(MappedSet4 set, int view)
- {
- set.view(view);
- }
+ public static void put_views(MappedSet4 set, int view) {
+ set.view(view);
+ }
- public static void put_view(MappedObject mapped, int view)
- {
- mapped.viewAddress = mapped.baseAddress + view * mapped.stride;
- }
+ public static void put_view(MappedObject mapped, int view) {
+ mapped.setViewAddress(mapped.baseAddress + view * mapped.stride);
+ }
- public static int get_view(MappedObject mapped)
- {
- return (int) (mapped.viewAddress - mapped.baseAddress) / mapped.stride;
- }
+ public static int get_view(MappedObject mapped) {
+ return (int)(mapped.viewAddress - mapped.baseAddress) / mapped.stride;
+ }
- 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.preventGC = src.preventGC;
- return dst;
- }
+ 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.preventGC = src.preventGC;
+ return dst;
+ }
- 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.preventGC = src.preventGC;
- return dst;
- }
+ 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.preventGC = src.preventGC;
+ return dst;
+ }
- public static void copy(MappedObject src, MappedObject dst, int bytes)
- {
- MappedObjectUnsafe.INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes);
- }
+ public static void copy(MappedObject src, MappedObject dst, int bytes) {
+ MappedObjectUnsafe.INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes);
+ }
- public static ByteBuffer newBuffer(long address, int capacity)
- {
- return MappedObjectUnsafe.newBuffer(address, capacity);
- }
+ public static ByteBuffer newBuffer(long address, int capacity) {
+ return MappedObjectUnsafe.newBuffer(address, capacity);
+ }
- // ---- primitive fields read/write
+ // ---- primitive fields read/write
- // byte
+ // byte
- public static void bput(byte value, long addr)
- {
- MappedObjectUnsafe.INSTANCE.putByte(addr, value);
- }
+ public static void bput(byte value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putByte(addr, value);
+ }
- public static byte bget(long addr)
- {
- return MappedObjectUnsafe.INSTANCE.getByte(addr);
- }
+ public static byte bget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getByte(addr);
+ }
- // short
+ // short
- public static void sput(short value, long addr)
- {
- MappedObjectUnsafe.INSTANCE.putShort(addr, value);
- }
+ public static void sput(short value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putShort(addr, value);
+ }
- public static short sget(long addr)
- {
- return MappedObjectUnsafe.INSTANCE.getShort(addr);
- }
+ public static short sget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getShort(addr);
+ }
- // char
+ // char
- public static void cput(char value, long addr)
- {
- MappedObjectUnsafe.INSTANCE.putChar(addr, value);
- }
+ public static void cput(char value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putChar(addr, value);
+ }
- public static char cget(long addr)
- {
- return MappedObjectUnsafe.INSTANCE.getChar(addr);
- }
+ public static char cget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getChar(addr);
+ }
- // int
+ // int
- public static void iput(int value, long addr)
- {
- MappedObjectUnsafe.INSTANCE.putInt(addr, value);
- }
+ 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 int iget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getInt(addr);
+ }
- // float
+ // float
- public static void fput(float value, long addr)
- {
- MappedObjectUnsafe.INSTANCE.putFloat(addr, value);
- }
+ public static void fput(float value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putFloat(addr, value);
+ }
- public static float fget(long addr)
- {
- return MappedObjectUnsafe.INSTANCE.getFloat(addr);
- }
+ public static float fget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getFloat(addr);
+ }
- // long
+ // long
- public static void jput(long value, long addr)
- {
- MappedObjectUnsafe.INSTANCE.putLong(addr, value);
- }
+ public static void jput(long value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putLong(addr, value);
+ }
- public static long jget(long addr)
- {
- return MappedObjectUnsafe.INSTANCE.getLong(addr);
- }
+ public static long jget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getLong(addr);
+ }
- // double
+ // double
- public static void dput(double value, long addr)
- {
- MappedObjectUnsafe.INSTANCE.putDouble(addr, value);
- }
+ public static void dput(double value, long addr) {
+ MappedObjectUnsafe.INSTANCE.putDouble(addr, value);
+ }
- public static double dget(long addr)
- {
- return MappedObjectUnsafe.INSTANCE.getDouble(addr);
- }
+ public static double dget(long addr) {
+ return MappedObjectUnsafe.INSTANCE.getDouble(addr);
+ }
+
}
\ 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-12 07:27:00 UTC (rev 3570)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 13:29:04 UTC (rev 3571)
@@ -1,185 +1,248 @@
/*
- * Created on Jun 25, 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 java.nio.ByteBuffer;
/**
+ * Base superclass of all mapped objects. Classes that require
+ * data mapping should extend this class and also be annotated
+ * with {@link MappedType}.
+ * <p/>
+ * Subclasses may only specify the default constructor. Any code
+ * inside that constructor is optional, but will not run when the
+ * view is instantiated, see {@link #runViewConstructor()}.
+ * <p/>
+ * Bounds checking may be enabled through a JVM system property: org.lwjgl.util.mapped.Checks=true
+ *
* @author Riven
*/
+public class MappedObject {
-public class MappedObject
-{
- public MappedObject()
- {
- //
- }
+ static final boolean CHECKS = LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.Checks");
- // these fields are not assignable/writable by user-code
- public long baseAddress;
- public long viewAddress;
- public int stride;
- public int align;
+ public MappedObject() {
+ //
+ }
- /**
- * Holds the value of sizeof of the sub-type of this MappedObject<br>
- * <br>
- * The behavior of this (transformed) method does not follow the normal Java behavior.<br>
- * <code>Vec2.SIZEOF</code> will yield 8 (2 floats)<br>
- * <code>Vec3.SIZEOF</code> will yield 12 (3 floats)<br>
- * This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access").<br>
- * Using Java 5.0's static-import on this method will break functionality.
- */
+ /** The mapped object base memory address, in bytes. Read-only. */
+ public long baseAddress;
- // any method that calls these field will have its call-site modified
- public static int SIZEOF = -1; // 'final' per subtype
- public int view; // read/write
+ /** The mapped object view memory address, in bytes. Read-only. */
+ public long viewAddress;
- public final void next()
- {
- this.viewAddress += this.stride;
- }
+ /** The mapped object stride, in bytes. Read-only. */
+ public int stride;
- /**
- * Creates a MappedObject instance, mapping the memory region of the specified direct ByteBuffer.<br>
- * <br>
- * The behavior of this (transformed) method does not follow the normal Java behavior.<br>
- * <code>Vec2.map(buffer)</code> will return a mapped Vec2 instance.<br>
- * <code>Vec3.map(buffer)</code> will return a mapped Vec3 instance.<br>
- * This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access").<br>
- * Using Java 5.0's static-import on this method will break functionality.
- */
+ /** The mapped object memory alignment, in bytes. Read-only. */
+ public int align;
- @SuppressWarnings("unused")
- public static <T extends MappedObject> T map(ByteBuffer bb)
- {
- // any method that calls this method will have its call-site modified
- throw new InternalError("type not registered");
- }
+ /**
+ * Holds the value of sizeof of the sub-type of this MappedObject<br>
+ * <br>
+ * The behavior of this (transformed) method does not follow the normal Java behavior.<br>
+ * <code>Vec2.SIZEOF</code> will yield 8 (2 floats)<br>
+ * <code>Vec3.SIZEOF</code> will yield 12 (3 floats)<br>
+ * This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access").<br>
+ * Using Java 5.0's static-import on this method will break functionality.
+ */
+ public static int SIZEOF = -1; // any method that calls these field will have its call-site modified ('final' per subtype)
- @SuppressWarnings("unused")
- public static <T extends MappedObject> T map(long address, int capacity)
- {
- // any method that calls this method will have its call-site modified
- throw new InternalError("ty...
[truncated message content] |
|
From: <ma...@us...> - 2011-07-12 07:27:06
|
Revision: 3570
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3570&view=rev
Author: matzon
Date: 2011-07-12 07:27:00 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
reverse merging r3567
Removed Paths:
-------------
LWJGL/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|