Archived

This topic is now archived and is closed to further replies.

Optimizing

This topic is 5305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey Iam sorta new at this OpenGL stuff I finished reading "OpenGL Game programming" which is the book made by this site or something a few weeks ago. But anyhow I noticed all of these OpenGL game developers having framerates of 90+ on a game with displaying many Faces/Traingles at a time. And me having problems getting my fps up to 30 I was wondering how do you people optimize your codes?. Like what kind of stuff do you look for and how do you arrive at optimizing is there anything special some of you do I should know?. If so please give me some tips on optimizing my codes. -Please talk to me if I was some kind of idiot. Give me any type of optimizing process I should know, even if its really obvious. [edited by - Majin Gotenks200 on June 4, 2003 5:09:49 PM]

Share this post


Link to post
Share on other sites
Optimization is a HUGE topic. There are a lot of articles out there about how to improve performance, but here''s an overview of the main areas you need to consider:

- You need to include some kind of culling mechanism to allow you to quickly eliminate large chunks of data that you know aren''t visible before sending them down the pipeline. This is usually done through quadtrees, octrees, BSP trees, etc. There are many different ways to do this, though, and the way commercial games do it is constantly evolving.

- Use the fastest available means to pass data to the video card. Immediate mode (i.e. glBegin()... glVertex()... glEnd()), which is what most of the book uses, is conceptually easy to grasp, but SLOW. At the very least, you should use vertex arrays, but if the hardware supports it, you should use vertex buffer objects (or their vendor-specific predecessors).

- You may want to use some level-of-detail system so that objects that are far away from the camera are drawn with models that use fewer polygons.

- Batch your data, and try to minimize state changes. Modern GPUs like to get a LOT of data at once - on the order of hundreds or even thousands of triangles at once. State changes are bad because some of them perform at least a partial flush of the pipeline, so for the more expensive ones, you want to group all of the data that uses a particular state when you can.

Anyway, there''s way too much to say about optimization to fit in a single post, but this should give you an idea of what kinds of articles to look for. We have some articles covering these topics here, I know there have been tons of threads about them here and in the graphics forum, and the nVIDIA and ATI websites have a lot of information as well.

Share this post


Link to post
Share on other sites
this one should be obvious- but you should profile your code and see what functions/processes are taking up the most of your time, then try to figure out why. perhaps you have a function inside a loop that you meant to put outside, or whatever... profiling should be the first step to general optimization.

-eldee
;another space monkey;
[ Forced Evolution Studios ]


::evolve::

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by eldee
this one should be obvious- but you should profile your code and see what functions/processes are taking up the most of your time, then try to figure out why. perhaps you have a function inside a loop that you meant to put outside, or whatever... profiling should be the first step to general optimization.

-eldee
;another space monkey;
<small>[ <a href="http://www.forced-evolution.com/" target="_blank">Forced Evolution Studios </a> ] </small></p>
<p><a href="http://www.forced-evolution.com" target="_blank"><img src="http://www.forced-evolution.com/images/skullsig.gif" border="0" alt="::evolve::"></a>
<SPAN CLASS=smallfont>
Do NOT let Dr. Mario touch your genitals. He is not a real doctor!
</span>



Not everyone has 1000€ to spare for Visual C++ PRO edition. And not everyone wants to use Dev-c++.

Share this post


Link to post
Share on other sites
Seeing as how there''s a topic already started, I''ll tag my question onto here. I believe I''ve sort of asked this before, but with unsatisfactory results. Since they were brought up, is there any guide or article available that teaches how to use vertex arrays with the specific intention of game programming? I have the "OpenGL Programming Guide," and they discuss vertex arrays, but only with small examples, such as drawing a single cube that won''t change dynamically. I was just hoping someone would know of an article which focused on vertex arrays for large scenes with multiple textures, with dynamic objects moving in the scene, and so on.

Thanks,
Elijah

Share this post


Link to post
Share on other sites
Then download one of the free profilers, nobody is forcing you to switch compilers OR shell out more cash.

Take this one for example (from AMD):
http://www.amd.com/us-en/Processors/DevelopWithAMD/0,,30_2252_3604,00.html

Sure it''s made by AMD, but the basic profiling works with anything. Intel has VTune, but they charge you for it. Like I said, no need to shell out more cash, or switch compilers.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Not everyone has 1000€ to spare for Visual C++ PRO edition. And not everyone wants to use Dev-c++.



and not everyone has to get microsoft or bloodshed to write their profiler for them. i said "profile your code" i didnt say "go buy MSVC pro so you can have the profiler option".

-eldee
;another space monkey;
[ Forced Evolution Studios ]


::evolve::

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
How do you use VC++ with profiling?


go to the project options and check "enable profiling", then under the "build" menu, hit "profile"

-eldee
;another space monkey;
[ Forced Evolution Studios ]


::evolve::

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

Share this post


Link to post
Share on other sites
Just make your own profiler that shows the execution time in ms for all your major functions (AI, rendering, etc) on the screen. That''s what I do for all of my projects. That way you can easily see where you are getting slowdowns... for example, you might see your rendering time increase from 2 ms per frame to 20 ms per frame when staring into a toliet. Then you cut down on the toliet''s polys.

Share this post


Link to post
Share on other sites