Archived

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

I need to improve my engine

This topic is 5114 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

Hi, i am a newbie in game programming and i made a strategic game that uses SDL libs. My problem is that i get a low frame rate and i am not sure about what can i do to improve it. I have thought that maybe threading is a good choice (now, all the game runs in a single thread, running first the game engine and then drawing the images on the screen). I am not sure about what can happend if i run my game engine and the drawing functions into two different threads. Could it help some?? Because i need to increase fps about 50% (at least) What do u think about that??? i am wrong??? what else can i do??? Thank u all!

Share this post


Link to post
Share on other sites
Threading will not magically makes your game faster, in fact with the added syncronisation code you''ll be lucky to get it the same speed if you split things up like you suggest.

First rule of optimising: Run your code (release build!) though a profiler to see what takes the most time, otherwise you''re just guessing. And optimising something you''ve guessed at is just wasted time and effort.

Share this post


Link to post
Share on other sites
Yup, you need to figure out what''s taking up your time before you try optimizing it.

Try reading the Enginuity articles, there''s a section which discusses a quick-and-dirty runtime profiler you can use to see where your code is slowing down.

Richard "Superpig" Fine
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Enginuity1 | Enginuity2 | Enginuity3 | Enginuity4 | Enginuity5
ry. .ibu cy. .y''ybu. .abu ry. dy. "sy. .ubu py. .ebu ry. py. .ibu gy." fy. .ibu ny. .ebu
"Don''t document your code; code your documentation." -me
"I''m not a complete idiot; parts of me are missing." -}}i{{

Share this post


Link to post
Share on other sites
Besides the profiler, you need to figure out if you actually need to improve the frame rate: 60 fps is perfectly acceptable, you don''t have to have blazing speeds of 350 fps. That said, if you have onboard video like I do, it''s impossible to get the fps too high due to whatever constraints I haven''t discovered yet, so depending on your hardware you might be stuck.

Share this post


Link to post
Share on other sites
i actually have the same problem.. i use SDL for 2d graphics, and i understand that my program doesnst have to run att 500 FPS, but atm my particle system runs at 20 fps with just a few particles on my 400 mhz celeron, and at 25 fps on my 2.4 GHz laptop. it is not the particles as just a few pixels and clearing the screen dosnt improve speed. the resolution is 640x480x32.
it doesnt matter if it is SDL_HWSURFACE or SDL_SWSURFACE, or SDL_DOUBLEBUF. i tried most different sdl surface settings, no difference.

i suppose that it *could* be my FPS-counting routines that slow it down, but i doubt it.

would be really thankful is this problem could be solved, as i want my game to run on linux, dont want to use dx.

Share this post


Link to post
Share on other sites
Find a profiler tool or make your own. Amd has a free profiler avail. Two things to look for is xform or fill rate limited. If you decrease the screen resolution and you''ll see your app speed up then you''re fill rate limited. If you increase the screen res. and you''re rendering fps doesn''t change then you''re xform limited. You might also have inefficient data structures or traversing, etc. Kind of hard w/o a profiler. It''s like shooting darts blind folded.

Share this post


Link to post
Share on other sites