Advertisement

SDL Optimizations?

Started by December 12, 2004 03:25 PM
29 comments, last by GameDev.net 19 years, 9 months ago
Quote: Original post by Spudder
I've noticed with my own projects using SDL switching to fullscreen often gave a significant performance increase, SDL is somewhat famous for reduced performance within a windowed application so the switch might be worth it if it's possible.


The reason is because SDL was developed for O/S's not as feature rich as windows. So it simply is not optimized for windows.

As for your windows demo here are a few things:
* The back in options does not work
* I'd suggest making an -apply- button so when the user changes the display mode, they are not looped through each display.
* I found a bug, when input grab is on and you choose software mode, the game works nice and fast, however when it is off and you choose software mode, the game runs slower than a 1 legged sloth, I think it hits fps of below 2. I dont know if this is a windows problem or game, but it happens on my comp.
* Other than that, it looks very nice! It a great start, I like the minimap, production queues, and the ai that keeps on killing me [WINK]. Keep up the good work!
Quote: Original post by graveyard filla
be sure you are converting all your surface's to the screens format BEFORE you blit any of them.

Yeah, I discovered this during my last game. Right now I have a function that loads the image, converts it and sets the color key.

Quote: also, in OpenGL, try using vertex arrays. stuff all your tiles into one vertex array with all the texture coordinates / positions and call glDrawArrays(). this should give a nice increase (depending on if your fill rate limited or geomoetry limited).

also, try running the game in fullscreen. this should give a nice boost in OpenGL. not only that, but try running the game in 16 bit color, in fullscreen. this should definetly show a nice boost in frame-rate. (again, depending on if its fill-rate or not, im betting it is though).

also, if you don't want to use vertex arrays, at least try to make GL function calls a minimum. that is, you might be doing something like this:

for each tile   gltextcoord()   glcolor3f()   glBegin()   draw_quad()   glEnd()


instead, do this:

gltextcoord()glcolor3f()glBegin()for each tile   draw_quad();glEnd()

Thanks for the suggestions, I'll look into them. I suspect the reason it's so slow (around 2 FPS from what some people are telling me) in GL mode with ATI cards is because of all the GL calls I make when drawing the tiles.

I pretty much taught myself just enough GL to get it to draw sprites from coordinates I pass the draw function. On that note, I'd appreciate any advice anybody can give me on how to draw a texture to another texture in GL so I can fix the mini map.
Advertisement
Quote: Original post by Drew_Benton
As for your windows demo here are a few things:
* The back in options does not work
* I'd suggest making an -apply- button so when the user changes the display mode, they are not looped through each display.

Thanks, I'll fix that here in a minute.

Quote: * I found a bug, when input grab is on and you choose software mode, the game works nice and fast, however when it is off and you choose software mode, the game runs slower than a 1 legged sloth, I think it hits fps of below 2. I dont know if this is a windows problem or game, but it happens on my comp.

That's really odd, I've never seen input grab effect the frame rate before. Unless somebody has an idea of what's going on there, I don't think there's much I can do about that.
well... unless the map is dynamic, why are you re-drawing the mini-map each frame? why not render the mini-map a single time, onto an SDL_Surface. then, just blit this surface each frame (in software). in OpenGL, just turn this surface into a texture, and render the texutre onto a quad each frame. then, the only thing you have to render with the mini-map is the little dots that represent the characters. if you need more details, just ask.
FTA, my 2D futuristic action MMORPG
Quote: Original post by graveyard filla
well... unless the map is dynamic, why are you re-drawing the mini-map each frame? why not render the mini-map a single time, onto an SDL_Surface. then, just blit this surface each frame (in software). in OpenGL, just turn this surface into a texture, and render the texutre onto a quad each frame. then, the only thing you have to render with the mini-map is the little dots that represent the characters. if you need more details, just ask.


Wow, I feel rather stupid at the moment. I was drawing both the terrain and units onto one texture and redrawing the terrain pixels when a unit moved. Obviously the terrain isn't going to change in mid game, so I can just draw that at startup and then draw the units on top of that with little or no performance drop. Thanks, that should make things much simpler.
Just a quick question but how do you draw text to the screen? I have noticed that drawing/updating text every frame can be pretty costly. It usually isn't a problem for just displaying the fps but if you can draw it to a surface first and only update that surface with the new fps once every second or 2 instead of every frame it might help with the frame rate. Like I said, I don't know how you are rendering your text but it has been my own experience that text is a big performance hit. I don't have access to a decent machine so I am stuck with my 500MHZ AMD machine to develop on so the little things do get noticed on my machine :)
Evillive2
Advertisement
Usually by starting a new thread.
Or viewing an old one, here or here or here
or here
or here
or here
or here.
Quote: Original post by evillive2
Just a quick question but how do you draw text to the screen? I have noticed that drawing/updating text every frame can be pretty costly. It usually isn't a problem for just displaying the fps but if you can draw it to a surface first and only update that surface with the new fps once every second or 2 instead of every frame it might help with the frame rate. Like I said, I don't know how you are rendering your text but it has been my own experience that text is a big performance hit. I don't have access to a decent machine so I am stuck with my 500MHZ AMD machine to develop on so the little things do get noticed on my machine :)


I made a function that draws a chunk of a surface that contains the alphabet plus some other characters for each letter in a string you pass it. It shouldn't be any slower than any other series of blits.

I tried commenting out all the parts that draw text, but it doesn't seem to make much if any difference.
Quote: Original post by aaron_ds
Usually by starting a new thread.
Or viewing an old one, here or here or here or here
or here
or here
or here
or here.


Well, those old threads aren't going to be terribly useful for finding out how this particular person is drawing their text, are they?
There is no readme.txt in the Windows .zip (and it's a bit hard to read the Linux one)

Also, sometimes I get a constant frame rate of 6, whereas normally it is 32. I haven't been able to reproduce it consistently but once it happens it happens a few times in a row; exiting and restarting will still be 6 fps. It might be related to when I change options and all text boxs go white. When that happens I can start the game and that screen is white too. Both bugs happen when changing the rendering mode, but I can't pin it to a specific mode.

Edit - white text box bug happens like this: run game; options; rendering mode to OpenGL; apply; back; quit; run; options; rendering mode to software; and clicking apply makes the text boxs white. Still not able to pin down the 6 fps bug.

W2k, ATI 9600xt, P4 2.66, windowed mode, 32 bits, 640 x 480, and if it matters, using mouse not keyboard :D

This topic is closed to new replies.

Advertisement