Log in or register to post comments

how can i change the texture dynamically using thread

April 10, 2012 - 7:46pm #1

Hi,i want to uss the thread to change the texture dynamically,but there is something wrong in my code, when i debug the example imagetarget, it didn't work, how should i modify my code?

    /** Called when the activity first starts or the user navigates back
     * to an activity. */
    protected void onCreate(Bundle savedInstanceState)
    {
        DebugLog.LOGD("ImageTargets::onCreate");
        super.onCreate(savedInstanceState);
        
        // Set the splash screen image to display during initialization:
        mSplashScreenImageResource = R.drawable.splash_screen_image_targets;
        
        // Load any sample specific textures:  
        mTextures = new Vector<Texture>();
        loadTextures();
        // Query the QCAR initialization flags:
        mQCARFlags = getInitializationFlags();
        
        // Update the application status to start initializing application
        updateApplicationStatus(APPSTATUS_INIT_APP);
Here is my code:        
new Thread(){
        	public void run(){
        		while(true){
                  Texture temp = mTextures.elementAt(0);
                  mTextures.set(0, mTextures.elementAt(1));
                  mTextures.set(1, temp);	
                  deinitApplicationNative();
                  initApplicationNative(mScreenWidth, mScreenHeight);
                  mRenderer.initRendering();
                  try{
                	  Thread.sleep(3000);
                  }
                  catch(InterruptedException e){
                	  
                	  e.printStackTrace();
                  }
        		}
        	}
        }.start();
    }

Re: how can i change the texture dynamically using thread

April 23, 2012 - 4:24am #5

Just a quick explanation:

mTimer = new Timer();

mTask = new TimerTask() {
public void run() {
[INDENT]Log.d(TAG, "Running procedure");
}[/INDENT]
};

mTimer.schedule(mTask, delay, period);

Hope this helps somewhat.
Rob.

Re: how can i change the texture dynamically using thread

April 12, 2012 - 6:59pm #4

Perhaps using a timer? This is rather outside of the scope of this forum.

- Kim

Re: how can i change the texture dynamically using thread

April 11, 2012 - 11:15pm #3

Thank you !
This Code use the onTouchEvent ,but how can i make the texture change dynamically like Gallery without the onTouchEvent ?

Re: how can i change the texture dynamically using thread

April 11, 2012 - 9:18pm #2

mRenderer.initRendering needs to be called from the GL thread. See this post for more info:

http://ar.qualcomm.at/node/2000659

- Kim

Log in or register to post comments