Page Flipping in SDL

Started by
10 comments, last by sevensevens 17 years, 2 months ago
Quote:Original post by Mogthew
Vsync was off. If my app was doing nothing and using all cpu, thats pretty silly. Doesn't leave any room for actual calculations in the game.

As for vysnc, I have the refresh rate override, so it would be capped at 100, it never _usually_ goes above 95.


Override? Often the settings you put in your video card drivers only apply to OpenGL. I seem to recall that DirectX tends to be application defined, and I don't recall SDL giving you control over that in fullscreen mode. Run it in Windowed mode, and I expect you'll see it run faster.

As for the CPU, your app wasn't "doing nothing". It was just doing something simple, over and over, in all the time available to it. It's not a symptom of a bug or a deficiency in the library.
Advertisement
Back to the OP's question - You may be filling the back buffer with black, so when you flip, you cannot see any difference. I noticed the line

SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, 0, 0,0xFF));

uses an 8-bit hex value, if the underlying format was in RGBA (red, blue, green, alpha), you may be filling the alpha bits, and not the color bits. You could try changing 0xFF to 0xFFFF (a 16-bit value), or you could try loading a bitmap, and displaying that.

Since you're new to C++, you might want to pick up a good C++ book (learn C++ in 21 days is good), and come back to SDL when you understand C++ better.

This topic is closed to new replies.

Advertisement