Hello, I am currently using the Android NDK and Qualcomm AR SDK to build an AR application. When drawing the models on screen, I am passing the floats from the java calls to the JNI.
the vertArray is a jfloatArray, I have pinned the problem down to this not being a standard C array. Is there a way to allow a jfloatArray to be passed in instead? If not, could somebody with C++ experience help me out.
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &vertArray[0]);
I have tried for days now to have a global array at the top (size will be unknown until start-up as it is passed from the Java side) which then copies the jfloatArray over. People are suggesting malloc, pointers and GetFloatArrayElements() but my attempts are failing badly due to my lack of knowledge.
Explanation of code (only showing 1 array and not the entire method code):
jfloatArray vertArray;
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv *, jobject)
{ //this is called in a loop after loadModelDimensions
//use the jfloatArray (and the other model dimensions) to render the model
}
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_loadModelDimensions(JNIEnv* env,jobject obj, jint tVERTEX, jint tINDEX, jfloatArray tVertices, jfloatArray tCoords, jfloatArray tNormals, jshortArray tIndices)
{
//jint tVERTEX and tINDEX assign so not a problem here with assignments/ being null
vertArray = tVertices;
}
If I put the values in a normal array at the top then I have no problems rendering the model. I also don’t receive any error messages and the application is still running but I only see a very small flicker where the model should be.
Any help is very much appreciated, if you require any more information then I will be happy to supply it.