FPS |
Thiago Nunes Leite
Guest
|
How do i create a fps count for my 2d game using sdl, also what can i do to lock it? thanks...
-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060121/49116968/attachment.htm |
|||||||||||
|
FPS |
FPS |
Thiago Nunes Leite
Guest
|
Yes I know, I'm using SFont for handling fonts. My problem is how do i count
fps? ----- Original Message ----- From: "Mike Powell" <belar at sevensouth.com> To: "A list for developers using the SDL library. (includes SDL-announce)" <sdl at libsdl.org> Sent: Saturday, January 21, 2006 4:09 AM Subject: Re: [SDL] FPS
|
|||||||||||||||
|
FPS |
Brian Barrett
Guest
|
On 1/21/06, Thiago Nunes Leite <luthi at sili.com.br> wrote:
each time you draw thats a frame. so just make an int outside the loop, increment it every frame. store SDL_GetTicks() when you just enter the mainloop. so your main loop looks something like this: int numFrames = 0; Uint32 startTime = SDL_GetTicks(); while( gameRunning() ) { getInput(); updateObjects(); drawObjects(); ++numFrames; } at any point when you want to know the average fames per second, use this calculation float fps = ( numFrames/(float)(SDL_GetTicks() - startTime) )*1000; |
|||||||||||||
|
FPS |
Martin Wegner
Guest
|
Hello.
Thiago Nunes Leite wrote:
I guess you have a main loop in your game. Each iteration the screen is cmopletely redrawn so the only thing you have to do is count the iterations per second (using ctime, ticks, whatever). Regards, martin
-- Get my public GPG key from pgp.mit.edu or wwwkeys.pgp.net Key ID: 0x44085D12 -- Homepage: http://mroot.net/ Powered by Gentoo Linux (http://gentoo.org/) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 890 bytes Desc: OpenPGP digital signature Url : http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060121/360951b5/attachment.pgp |
|||||||||||||||
|
FPS |
Alan Wolfe
Guest
|
You can use SDL_GetTicks() every frame to measure the number of miliseconds
between frames, then you divide 1000 by that number to get your frames per second, super simple (: ----- Original Message ----- From: "Thiago Nunes Leite" <luthi at sili.com.br> To: "A list for developers using the SDL library. (includesSDL-announce)" <sdl at libsdl.org> Sent: Saturday, January 21, 2006 7:03 AM Subject: Re: [SDL] FPS
|
|||||||||||||||||
|