Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid NDK JNI Call Returning Different Values
    primarykey
    data
    text
    <p>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. </p> <p>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:</p> <pre><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-&gt;GetArrayLength(tVertices); //the float* where the jfloatArray passes the elements vertArray = env-&gt;GetFloatArrayElements(tVertices, 0); //testing purposes below char bufferResult[200]; sprintf(bufferResult, "Array: %f", vertArray[0]); LOGE(bufferResult); } </code></pre> <p>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:</p> <p>Array: 3.365105 Array: 3.270681 Array: 3.280375</p> <p>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.</p> <p>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)</p> <p>EDIT: Java call:</p> <pre><code>//native call to load dimensions loadModelDimensions(Vertices); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload