Sign in to follow this  
39ster

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

Recommended Posts

39ster    145
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 this post


Link to post
Share on other sites
39ster    145
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 this post


Link to post
Share on other sites
Kylotan    9872
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 this post


Link to post
Share on other sites
39ster    145
Quote:
Original post by dopefish
Does 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 this post


Link to post
Share on other sites
39ster    145
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this