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.
This commit is contained in:
Ioannis Tsakpinis 2011-07-12 14:21:29 +00:00
parent fa31e0f9cb
commit e174bf3bc8
3 changed files with 15 additions and 2 deletions

View File

@ -117,6 +117,19 @@ public class MappedObjectTests1 {
} 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

View File

@ -60,7 +60,7 @@ public class MappedHelper {
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");

View File

@ -62,7 +62,7 @@ public class MappedObjectTransformer {
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.");
}
}