Advertisement

How can I show the fps ?

Started by February 06, 2001 05:29 AM
10 comments, last by Arlo 23 years, 9 months ago
Hello, First, excuse me for my english, I''m french and I''am begin in the Sheakspear''s language I looking for how to show the fps in my OpenGL scene, can you help me ? Thanks !
Hi Arlo,

Okay, you''ll need these things before you can display the frames per second.

1. A timer so you know how long the last frame took to execute. This is pretty standard, and you can use the windows performance counter for this. If you''re stuck as to how to use it, go to this site, and read up:
http://msdn.microsoft.com/library/psdk/winui/timers_3mr7.htm

2. A method to print text to the screen. This is a bit annoying in OpenGL, but what I would do is set up a texture with a font on it, and draw your text as texturemapped quads. As is often the case, there are good tutorials at NeHe''s site:
http://nehe.gamedev.net/tutorials/lesson17.asp

3. Ahh the easy bit. Once you know how long the last frame took, in seconds, then fps = (1 / frame_time).

Hope this helps.

- Peter
peter@digital-animations.com
Advertisement
Or you could go to the site of GLvelocity(you can find the link at gamedev at the left) and download his fps code to us in your program.
Salut,

Moi je suis un p''tit belge.

Visite mon site : http://slug-production.ibelgique.com

J''ai un exemple qui affiche un compteur de FPS et ça marche sous Visual C++ 5.0

Tiens moi au courant ...

========================
Leyder Dylan
Site : http://slug-production.ibelgique.com
E-Mail : dylan.leyder@ibelgique.com

========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
hi, i've found that updating the window title can be quite slow, so i wrote a piece of code to use nehe's TimerGetTime() function and draw a quad on the screen to act as a fps gauge (its also easier to read than text)

you will find it at: http://freespace.virginnet.co.uk/al.braidwood/html/tutorials.html
its in the section called "Frames-per-second Display" (surprise!)

hope it helps

alistair


Edited by - alistair b on February 9, 2001 8:58:34 PM
i tried the microsoft timer at
http://msdn.microsoft.com/library/psdk/winui/timers_3mr7.htm
and i couldn''t get it to work.

here''s what i''m doing, maybe i''m missing something:
i declare a global timer
UINT_PTR IDT_TIMER1; // timer

and in my init function, i added
SetTimer(hWnd, // handle to main window
IDT_TIMER1, // timer identifier
1000, // 1-second interval
(TIMERPROC) NULL); // no timer callback

then i added
	case WM_TIMER:							// receive timer msg		{					//switch (wParam) 					{ 				//case IDT_TIMER1: 				{					frameD = frame - frameD;					fps = frameD/1000.0f;					frameD = frame;									return 0; 				}							} 		} 

in my WndProc function.
am i missing something? seems like the program never gets to recieve this WM_TIMER call


thuned



life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
Advertisement
or what do i have to include to get
timeGetTime() to work?

i get
Lesson1.obj : error LNK2001: unresolved external symbol __imp__timeGetTime@0
Debug/cv1.exe : fatal error LNK1120: 1 unresolved externals

when i try to compile it

life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
i think you need to have link with winmm.lib, the command is in winperf.h, but thats automatically included by windows unless you use #define WIN32_LEAN_AND_MEAN

alistair
thanks, it worked

thuned

life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
one of the options in my appwizard program is a fps counter.
ill post a page concerning it on my site tonight

http://members.xoom.com/myBollux

This topic is closed to new replies.

Advertisement