how to change fps in openGL

Problems with Canvas, OpenGL, etc...

how to change fps in openGL

Postby Vziuh » Thu Jun 09, 2011 6:13 pm

hi people.

i need to set number of frames per second, for example 30 or 20.

if anyone did something like this, can you share your experience.
Vziuh
Freshman
Freshman
 
Posts: 8
Joined: Fri May 27, 2011 11:55 am

Top

Re: how to change fps in openGL

Postby MichaelEGR » Sat Jun 11, 2011 12:05 am

How I accomplish this in TyphonRT is through a callback clock / timing system. Essentially it's sort of like a do while thread sleep(1) loop. Kind of a spin wait, but the sleep will yield as necessary. In the old days we used the yield() method instead of sleep, but that increases processor usage especially for laptops and most definitely for Android devices. In the TyphonRT clocking system there is a subdivided int clock. Essentially you can set the min subdivision to 60hz and 2 subdivisions are 30hz, 3 = 20hz, 4 = 15hz, etc. It's fast and accurate enough and you can not only adjust the callbacks, but you can have callbacks at different FPS / ratios (IE maybe AI running at 15hz callbacks). If you want to render at 20hz you assign the callback that does the GL rendering and eglSwapBuffers call to the 3rd subdivision. I'll be releasing TyphonRT soon...
Founder & Principal Architect; EGR Software LLC
http://www.typhonrt.org
http://www.egrsoftware.com
User avatar
MichaelEGR
Senior Developer
Senior Developer
 
Posts: 147
Joined: Thu Jan 21, 2010 5:30 am
Location: San Francisco, CA

Re: how to change fps in openGL

Postby Vziuh » Sat Jun 11, 2011 6:31 am

thx for answer.
i thought that if i can't set fps, function onDrawFrame will be called so many times as processor can. In this case game speed will depend on Android device power.
Also i want to do the possibility for multiplayer, in that case i need to synchronize game.

few hours ago, on another forum for game developers. i've get an advice, to separate all my calculation and changes in game, from output on the screen , in this case program will do all calculations 20 times per second, and i don't care how many times function onDrawFraame will be called, because this function have no effect on game world.
Vziuh
Freshman
Freshman
 
Posts: 8
Joined: Fri May 27, 2011 11:55 am

Top

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

Who is online

Users browsing this forum: No registered users and 4 guests