Log in or register to post comments

update GUI with ImageTargetsRenderer

August 16, 2012 - 5:00am #1

Hey,

I have few issues concerning graphic interface. I would like to change a TextView depending on the image tracked (with ImageTargets sample).

I've added a GUIManager as in VirtualButton & this works fine.

However, i want to change a text from a TewtView (from the GUIManager) depending on what is currently tracked.

I have tried to add the GUIManager object to the renderer &, in the function onDrawFrame, I tried mGUIManager.updateText(), but i receive "callfromWrongThreadException" exception (which I understand).

However, i don't know how to fix this, maybe create an event in the renderer thread which tells the main thread each time the function onDrawFrame is called, but I don't manage to do it ( I don't know how to do this..).

Thanks by advance for your time.

update GUI with ImageTargetsRenderer

August 21, 2012 - 7:51pm #4

Good. You can use that same approach, by implementing a handler to call across threads, for more sophisticated updating of views as well.

In the Android samples, most native methods can be divided into two categories: those called from the main ( aka UI ) thread and those called from the GL thread. In ImageTargets.cpp, for example, any method that starts with Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer is called from the GL thread. These methods are called from the onSurfaceCreated, onSurfaceChanged, or onDrawFrame callback methods in ImageTargetsRenderer.java, which are called by Android on a separate OpenGL thread. Most of the methods that start with Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets are called from the main thread. One exception is the loadTrackerData method, which is called from an AsyncTask in ImageTargets.java.

update GUI with ImageTargetsRenderer

August 21, 2012 - 5:08am #3

Hey,

by using sendThreadSafeGUIMessage(message), it worked !

Thanks you David.

update GUI with ImageTargetsRenderer

August 20, 2012 - 12:18pm #2

Have you tried using mGUIManager.sendThreadSafeGUIMessage(message)? This passes the message using a registered handler to accomplish what you're describing.

Log in or register to post comments