I am building an augmented reality application using the Android SDK/NDK and the qualcomm AR SDK. Part of my application requires me to pass multiple float arrays over to the native side of the program to deal with model dimensions.
My problem is that when I pass them as parameters, they seem to be coming out differently at the other side. I will post a stripped down version of my code:
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , "NATIVE LOG", __VA_ARGS__)
float* vertArray;
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_loadModelDimensions(JNIEnv* env, jobject obj, jfloatArray tVertices)
{
//used to free the memory at the end
int verticesLength = env->GetArrayLength(tVertices);
//the float* where the jfloatArray passes the elements
vertArray = env->GetFloatArrayElements(tVertices, 0);
//testing purposes below
char bufferResult[200];
sprintf(bufferResult, "Array: %f", vertArray[0]);
LOGE(bufferResult);
}
The LOGE method just allows me to post back a string to the android logcat, the vertArray[0] element is 11.2222 but so far I have been getting results such as:
Array: 3.365105 Array: 3.270681 Array: 3.280375
So far I have tested using a normal C array to check sprintf works and it does, I have also passed over a jint instead of a jfloatArray and that also displays correctly.
Is there a reason why it would be returning ~3 everytime, no matter what element in the array I am asking for? (I am passing in 4 arrays and they all do the same thing)
EDIT: Java call:
//native call to load dimensions
loadModelDimensions(Vertices);