How to control the speed of the OpenGL thread?

Problems with Canvas, OpenGL, etc...

How to control the speed of the OpenGL thread?

Postby MobileVisuals » Mon Sep 05, 2011 1:40 pm

I want to make the Open GL thread sleep for a certain amount of time.
The documentation says that I should use an approach like

queueEvent(new Runnable() {
public void run() {
mMyRenderer.handleDpadCenter();
}});

to communicate with the GL thread. But how can I instruct the thread
to sleep with this approach? How do I get a handle to the thread?
MobileVisuals
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sun Sep 26, 2010 3:19 pm

Top

Re: How to control the speed of the OpenGL thread?

Postby roopa » Fri Sep 23, 2011 8:07 am

If you are targeting certain frame rate, the basic idea is that you should have a timer or thread that executes your game's tick method at desired intervals. With timers the implementation is pretty trivial: just schedule a timer to execute at regular intervals. When using threads you have to put the thread to sleep between consecutive ticks if it runs faster than the desired frame rate.

However, this alone doesn't lead to the best possible results as the interval can vary a bit between the frames. There is a very good article on this issue: http://gafferongames.com/game-physics/f ... -timestep/.

Also, there are already slower and faster Android phones than the dev phone 1. So you have to prepare for the both cases if you are targeting all Android devices. If your game is not that CPU heavy, it might be that you can achieve the desired frame rate on all the devices. But if you don't limit the frame rate, your game will be too fast on the faster Android phones.
roopa
Developer
Developer
 
Posts: 27
Joined: Wed Sep 14, 2011 6:46 am

Re: How to control the speed of the OpenGL thread?

Postby loosi007 » Sun Jan 01, 2012 3:56 pm

Great post...
loosi007
Freshman
Freshman
 
Posts: 6
Joined: Sun Jan 01, 2012 3:29 pm

Re: How to control the speed of the OpenGL thread?

Postby samstephan9 » Wed Jan 04, 2012 12:18 pm

I am also interested to know about open GL thread.
samstephan9
Junior Developer
Junior Developer
 
Posts: 20
Joined: Wed Jul 13, 2011 12:11 pm
Location: California

Re: How to control the speed of the OpenGL thread?

Postby flygirl » Fri Jan 06, 2012 4:32 am

MTS to MOV Converter is a powerful and easy-to-use MPEG to AVI converter, which enables you to effortlessly convert MTS to AVI, MTS to MPEG, MTS to MP4, MTS to 3GP, MTS to WMV, MTS to RM, MTS to RMVB, MTS to FLV(flash), MTS to VCD/SVCD/DVD, MTS to iPod MP4, MTS to PSP MP4 and so forth with high quality. It supports adding watermarks,subtitles to the videos.
MTS to MP4
MTS to WMV
MTS to MPG
flygirl
Freshman
Freshman
 
Posts: 9
Joined: Fri Jan 06, 2012 4:19 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 5 guests