Advertisement

Measuring FPS and more... plz help

Started by July 07, 2003 05:26 AM
8 comments, last by themule 21 years, 7 months ago
Firstly could anyone tell me what is the standard way of measuring FPS (frames per second) accurately. I had thought of just using a counter alongwith a timer in the function that gets called every time a frame is displayed. Could anyone tell me if this is ok or some other method is normally used. I am new to this so ppl might find this question stupid, but plz bear with me and enlighten me. thanks. Secondly, I have created a display list with the following code: could anyone plz tell me if there is some portion in it that is sucking too much processing power everytime the display list is called later on, coz what i think is that it is just generating thousands of polygons (triangles) and storing their data (vertices and normals) in the display list so that it can render all the triangles quickly in real time using just the display list. But I am not getting real time results, every time i change the view of the scene using the standard keyboard and mouse input for the ''camera view'' the scene takes a few seconds to change the view.. it is not real time as i said. So could anyone tell me what is actually happening when the display list is built and what is happening everytime the display list is called. Heres the code:

triangleCount = 0;
		linklist = glGenLists(1);
		glNewList(linklist, GL_COMPILE);
			glColor3ub(255, 255, 255);
			while(head->next!=NULL)
			{	glBegin(GL_TRIANGLES); // Drawing Using Triangles

				glNormal3f( dummy.getNorm00(), dummy.getNorm01(), dummy.getNorm02());
				glVertex3f( dummy.getVal00(), dummy.getVal01(), dummy.getVal02());
			//	glNormal3f(dummy.getNorm10(),dummy.getNorm11(), dummy.getNorm12());

				glVertex3f(dummy.getVal10(),dummy.getVal11(), dummy.getVal12());
			//	glNormal3f( dummy.getNorm20(),dummy.getNorm21(), dummy.getNorm22());

				glVertex3f( dummy.getVal20(),dummy.getVal21(), dummy.getVal22());
				glEnd(); // Finished Drawing The Triangle

				triangleCount++;
				dummy.eraseOne();
			}

		glEndList();
My processor speed is 733MHz and 128 MB RAM. And Finally I wanted to ask about something less ppl might know about: I am doing an implementation similar to the isosurfacing algorithm ''Marching Cubes''. I had read that for data of the order 10 to the power 7 to 9 the number of triangles generated should be in the range of 10 to the power of 3 to 4. But my problem is that with data of 1000 x 1000 x 20 = 20 000 000 which is of order 10 to the power of 7, I am getting way too many triangles: order of 10 to the power of 6, which it seems is too much for the processing power I have: 733 MHz. Please guide me if anyone has any clue where i may be going wrong or if any improvements are possible. Also, could anyone tell me what is the number of polygons that can be rendered in real time using display lists with the limited processing speed i have thanks. I''d really appreciate any help in these regards.
There's a few ways to measure fps. The simplest way should be:

-Measure time one frame takes to render in seconds. Now display the reverse. This value will jump around a lot, so it's not really usefull. (eg: one frame takes 0.02s -> 1/0.02 = 50 fps)

-Accumulate the time and frames. Once the time is above or equal to one second display frames/seconds. Now reset time and frames back to zero. This will give you the average fps over the last second. Much better for reading.

Nehe has an example for fps on his site somewhere

I've got no time right now for a lengthy description of what a display list does. Here's a few pointers though:

-Make sure you only create the display list outside the main loop and only call it during the main loop.

-What graphics card do you have? My 800MHz Athlon ran 8k-Triangles+ easily, with it's GF2.

I'll try to give an explanation once I got more time, in case no one else answered by then.

[edited by - Wildfire on July 7, 2003 6:49:16 AM]
How do I set my laser printer on stun?
Advertisement
Using display lists, i can push my 450mhz with a TnT to 18k polygons per frame which is about 1m/s. This is without much CPU tasks though, with things like collission detection disabled.
well, i dont know if i''m right...anyway i''ll try:

each time you call a display list you''ll repeat that code,
for example instead of calling 3 times getNorm or getVal
create a single function wich return an array of 3 floats
and you could use glvertex3fv (or grnormal3fv) so you should call 8 functions less for each triangle

i''m not really experienced...but i''ll delete things OUT of a display list (eraseOne())
in the displist i''ll make only things to draw, so for trianglecount do it somewhere else...
i think the lesser code the displist contains the better is, because it has to be called a lot of times (usually)

i learned this in the previous my topic...



There aren''''t problems that can''''t be solved with a gun...
There aren''t problems that can''t be solved with a gun...
quote:

Also, could anyone tell me what is the number of polygons that can be rendered in real time using display lists with the limited processing speed i have thanks.



Try looking up your graphics card on your vendors homepage. They usually feature figures like 'Vertices per Second'.

Here's an example for the GF4 Ti4800:

- 136M vertices / second @ 25 fps ~ 5.44M vertices / frame
- A triangle uses three vertices (if you do not uses triangle-strips and the like)
- 5.44M vertices / frame ~ 1.8M triangles / frame
- In reality you'll never reach this number (take a look here)
- If you reach 10% of that value, you're still at 180k triangles / frame -> 4.5M / second

This numbers will greatly change if you're cpu-limited, memory-bandwidth limited etc...

quote:

Please guide me if anyone has any clue where i may be going wrong or if any improvements are possible.



Without seeing your actual implementation of the algorithm this is gonna be pretty hard But since you yourself said the number of triangles you get is too high, I'd take a closer look at the triangle generation.

Does the number of triangles change a lot? Do you re-generate the display list each time it does? Display list generation and compilation is relatively slow, and should only happen outside the main loop.

[edited by - Wildfire on July 7, 2003 10:39:02 AM]
How do I set my laser printer on stun?
For the FPS measuring stuff...

I do like this:

In INIT() I set:
FPScounter = 0;
FPSdisplay = 0;
OneSecond = GetTime() + 1000.0f; //remember GetTime() gives miliseconds!

...

Then in Main Loop:

if (GetTime() > OneSecond) //If one second has passed...
{
FPSdisplay = FPScounter; //we know how many frames has passed
FPScounter = 0; //and set counter to zero
onesecond = GetTime() + 1000.0f; //and set our future second
}

//Here you place all draw, input, and extra calculations stuff
//where you can use FPSdisplay to show FPS on screen

fpscounter++; //we count one more frame


That''s all!
It''s easy... count how many frames you have in one second!!

"You take The Blue Book and the story ends. You wake in your bed and you believe whatever you want to believe. You take The Red Book and you stay in Wonderland and I show you how deep the rabbit-hole goes."

"You take The Blue Book and the story ends. You wake in your bed and you believe whatever you want to believe. You take The Red Book and you stay in Wonderland and I show you how deep the rabbit-hole goes."
Advertisement
Firstly, I don''t have a graphics card on my system... is it a prereq for doing OpenGL rendering? i mean is the rendering always going to be pathetic without a graphics card?
But I have also tried running my code in my univ. lab, there it is faster because the machines are faster but still not real time, I''ll check if the lab systems have any graphics cards on them and then post here so that ppl can give me better advice.
[the number of triangles is in the range 50k to 500k] depending on the input data; and needless to say, the program speed is inversely proportional to the number of triangles generated in that run of the program with the given input data.

Let me rephrase my display list question: Look at the code in my display list and tell me which line of code translates to what when the display list is called and which line of code is not executed at all when the display list is called. And yes i build the display list outside the mainloop, i am only generating the display list while initializing; and only call the display list inside the mainloop. And so wildfire the problem is not of repeatedly compiling the display list, its that of it being too heavy even if i call the display list. And calling the display list is the only thing i am doing in the mainloop - in my drawing function. I have read up from the Red Book about display lists and from what i gather from it, the display list that i have generated and am just calling should give very fast results because i think all it should be doing is to calculate the normals and vertices while the display list is built and then just use the already computed values for the triangles for displaying them.. that shouldnt be slow i thought, and yet...

The algorithm that i am implementing involves computing many small triangles to represent 3D input data e.g. medical CT scan data. All this computing takes place in the initializing phase of the program. then in the mainloop only the display list to show the generated triangles is called. and yes the camera view can be changed but that doesnt need the triangles to be recomputed, its just for viewing the same triangles with a different view point.

thanks for the help i''ve got so far (especially the fps measurement), but more will be highly appreciated, as i still have no clue why is it so slow.
quote:

Firstly, I don't have a graphics card on my system... is it a prereq for doing OpenGL rendering? i mean is the rendering always going to be pathetic without a graphics card?



Surely you must have some form of graphics card in your system... otherwise it'd be a bit hard reading the forums? (Maybe you have one of those Braille Monitors though?)
What you're probably asking about is a graphics card that offers 3D acceleration. While it is not a prereq for doing OpenGL, it is a tremendous speedup .

Here's some specs from my old system @ 2k triangles:
no hw-acceleration: < 9-10 fps
with hw-acceleration: > 200fps (geforce2)
[this values are from my memory but should be mostly correct]

quote:

the number of triangles is in the range 50k to 500k



In my previous post I wrote that a GeForce4 should be able to do 100k triangles @ 25 fps without problems if you're not cpu limited. Your system seems to be both cpu and graphicscard-limited so 500k triangles is a hell of a lot to do per frame...

quote:

thanks for the help i've got so far (especially the fps measurement), but more will be highly appreciated, as i still have no clue why is it so slow.


Hate to say it, but if the triangle generation is completely outside the mainloop, and the only thing you're calling inside the mainloop is the list... well, either you have to get yourself a decent 3D-accelerated graphics card, or use way less triangles...

A GeForce3 or above is most likely oversized for your computer, since it won't be able to deliver data fast enough. Something along the lines of GF2 should do just fine, and should also be very afordable by now. (If they're still in the stores, otherwise look at ebay)

[edited by - Wildfire on July 8, 2003 3:28:28 AM]
How do I set my laser printer on stun?
hey Wildfire thanks a bunch...
and yes thanku for clearing up this graphics cards thing to me... till now i thought that the 3D accelerated cards are the ''graphics cards'' and the other non 3D accelerated ones which have to be there in the system are just called ''video cards'' and are for different purposes. therefore i thought that i didn''t have any graphics card.. hehe.. i can imagine how funny it must have been for the reader.
... silly me... doing OpenGL and not knowing this stuff
No problem I wasn''t trying to mock you, but the thought of not having a graphicscard was funny indeed

I think there was a time when videocard and graphicscard was simply two words for the same thing. But then cards with hw-acceleration for video-editing came along, which could be called videocards. Then came those 3D-addon cards like the 3dfx voodoo, which were for 3D acceleration only. Today most cards offer pretty much anything in one.
How do I set my laser printer on stun?

This topic is closed to new replies.

Advertisement