Sorry guys, this is not a specific LWJGL question, but I know you use a lot of JNI in LWJGL, so I thought you guys might be able to point me in the right direction. I have a piece of code that is getting an exception access violation an I can't figure out why. I am trying to get the address of a ByteBuffer and that's when it dies.
JNIEXPORT jlong JNICALL Java_BufferTest(JNIEnv *env , jclass clazz, jobject testBuffer) {
if(testBuffer== NULL) {
printf("Buffer is null %d", testBuffer);
return 1;
}
printf("Here 1\r\n");
void* cVertexStreamZeroData = env->GetDirectBufferAddress(testBuffer);
printf("Here 2\r\n");
return 0;
}
Here is the calling code.
ByteBuffer testBuffer = ByteBuffer.allocateDirect(72).order(ByteOrder.nativeOrder());;
testBuffer.putFloat(1.0f);
testBuffer.putFloat(2.0f);
testBuffer.putFloat(3.0f);
testBuffer.putFloat(4.0f);
testBuffer.putLong(0xffffffff);
testBuffer.putFloat(5.0f);
testBuffer.putFloat(6.0f);
testBuffer.putFloat(7.0f);
testBuffer.putFloat(8.0f);
testBuffer.putLong(0xffffffff);
testBuffer.putFloat(9.0f);
testBuffer.putFloat(10.0f);
testBuffer.putFloat(11.0f);
testBuffer.putFloat(12.0f);
testBuffer.putLong(0xffffffff);
testBuffer.rewind();
Test.BufferTest(testBuffer);
Here 1 gets printed, then the exception occurs. Any suggestions? I am kind of a novice with C++, so I am not sure how I can debug this.
Thanks.