Hi!
I tried to use the Java NIO buffers in a real simple way and it didn´t work
I am doing this on the c++ side:
/*
* Class: Renderer_RenderDevice
* Method: setModelViewProjectionMatrix
* Signature: (Ljava/nio/FloatBuffer;)V
*/
JNIEXPORT void JNICALL Java_Renderer_RenderDevice_setModelViewProjectionMatrix
(JNIEnv* env, jclass c, jobject matrixBuffer) {
float* matrix = (float*)env->GetDirectBufferAddress(matrixBuffer);
//glLoadMatrixf( matrix );
if ( matrix == 0 ) {
std::cout << "Error" << std::endl;
return;
}
for(int i=0; i<16; i++) {
std::cout << matrix[i] << std::endl;
}
}
and that on the java side:
RenderDevice.setModelViewProjectionMatrix(FloatBuffer.allocate(16));
This is MEANT to work, but it will always return “Error” because matrix* is null.
All code examples I found on the net were not different to mine.
I am using java 1.6 and other libs like lwjgl work - so its not the runtime.
But where is my mistake ? I am puzzled - theres not much to do wrong.
Help is very appreciated,
Frederick
[EDIT: I am using MSVC++ Express Edition to compile the c++]