SDL Full screen slowdown (fixed - was using 24 bit)

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

Recommended Posts

I have a game that runs at 60 frames per second. I removed the frame rate limiting to see how fast it could run when the game is maximized (but not fullscreen) and i get 102 fps. When i press F4 (which switches it to fullscreen, but still the exact same resolution when its maximized) the fps drops to 45-48 fps. Heres the log:
//Game first starts it runs at around 300+ fps
New resolution: 512x448
FPS: 105
FPS: 315
FPS: 279
FPS: 322
FPS: 324
//I press maximize button, game runs at 102 fps
New resolution: 1024x721
FPS: 275
FPS: 79
FPS: 102
FPS: 102
FPS: 101
FPS: 102
//I press F4 (to switch to fullscreen) fps drops to 45-48
New resolution: 1024x721
FPS: 79
FPS: 48
FPS: 49
FPS: 46
FPS: 47

And heres the "F4" code:
    else if(keyCode == keyMap[SDLK_F4])
{
if(videoFlags & SDL_FULLSCREEN)
videoFlags &= ~SDL_FULLSCREEN;
else videoFlags |= SDL_FULLSCREEN;
resizeWindow(view.w, view.h, bpp, videoFlags);
}
and the resizeWindow()
bool CGame::resizeWindow(int width, int height, int bpp, int flags)
{
view.w = width;
view.h = height;
backBuffer = SDL_SetVideoMode(width, height, bpp, flags | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE);
targetBuffer = backBuffer;
return backBuffer != 0;
}
[Edited by - 39ster on April 16, 2008 3:08:27 AM]

Share on other sites
Hmm, so no one knows why? I get huge FPS drops when i change to fullscreen. Is this normal? Remember, the resolution is exactly the same as it is when the window is maximized, but the fps drop is massive.

Share on other sites
If you're not calling SDL_DisplayFormat on your surfaces when you change the display format, it's quite likely that the blit rate will drop.

Share on other sites
Does the framerate go back to normal when you change back to windowed mode?

Share on other sites
Quote:
 Original post by dopefishDoes the framerate go back to normal when you change back to windowed mode?

Yes.

@Kylotan

I dont call that at all. I actually need to use both 8 bit sprites and 24 bit sprites. Why doesnt it slow down when maximized? It doesnt change the bpp when it goes to fullscreen. I get above 100 fps when maximized, but as soon as its fullscreen it slows down ALOT.

Share on other sites
There is more to pixel format than just the bits per pixel.

Share on other sites
Ok i figured it out. I was using 24 bpp for the video surface. When i changed it to 32 it runs much faster. Im guessing this is because the tiles that are rendered are 8-bit which indexes 32-bit colours. Still not sure why it only happened in full screen. Changing it to 32 probably improved the speed when it runs in windowed mode also.

EDIT: Yup i now get over 200 fps in both windowed and full screen.
The cpu usage also went from 30% to 10% =D

[Edited by - 39ster on April 16, 2008 2:20:44 AM]

Share on other sites
This is why calling SDL_DisplayFormat on sprites is a good idea.

1. 1
Rutin
24
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 19
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631760
• Total Posts
3002176
×