Log in or register to post comments

native function renderFrame to return jstring

March 19, 2012 - 4:55am #1

Hello, i'm trying to modify the renderFrame function to return me the trackable name as jstring

the changes:

JNIEXPORT jstring JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv* env, jobject obj)
{
jstring nameJ;
nameJ = env->NewStringUTF("empty");

for(int tIdx = 0; tIdx {
....
nameJ = env->NewStringUTF(trackable->getName());
....
}
...

...
Log("Done");
return nameJ;
}

I get an fatal
from the logcat:

03-19 13:46:42.179: I/IMAGE_TARGETS(19903): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_initRendering
03-19 13:46:42.218: D/QCAR(19903): GLRenderer::onSurfaceChanged
03-19 13:46:42.218: I/IMAGE_TARGETS(19903): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_updateRendering
03-19 13:46:42.218: I/IMAGE_TARGETS(19903): Configure Video Background : Video (640,480), Screen (1196,720), mSize (1196,897)
03-19 13:46:42.226: I/IMAGE_TARGETS(19903): Done
03-19 13:46:42.226: A/libc(19903): Fatal signal 11 (SIGSEGV) at 0x0000001f (code=1)

Any ideas how this can be done will be very helpful , Thanks from advance.

Re: native function renderFrame to return jstring

March 20, 2012 - 4:44am #3

Thanks, i tried again and it worked.. don't think i changed anything..

Re: native function renderFrame to return jstring

March 19, 2012 - 7:24pm #2

That's strange, I just tested this on a few different devices and it seems to work fine. Have you changed anything else? Did you update the method signature in the ImageTargetsRenderer class to reflect the new return type?

/** The native render function. */    
public native String renderFrame();


/** Called to draw the current frame. */
public void onDrawFrame(GL10 gl)
{
    if (!mIsActive)
        return;

    // Call our native function to render content
    String name = renderFrame();
    DebugLog.LOGI("name: " + name);
}

- Kim

Log in or register to post comments