SDL 2 / blitting too slow

Hey guys,

First, I'm new to the forum and hope it's the right section.
I'm tryin' to code a simple SDL2 program, that uses an own mouse cursor and animates a model. I wrote the code all by myself (except for the SDL library ^^)

The program's got a typical game loop -> draw() function and update() function. It detects the time it needs for drawing and updates the game for that time step, like most games do. The program always draws. The cursor updates its' position every (1000 / fps)ms.

My screen is set to 60 fps. The program also shows the actual fps it does. no matter whether i set my screen to 60 fps or 75 fps (it's possible), the programs' fps is always near to the screens' fps setting.

The problem:

the screen will not render correctly. the model animation always looks fuzzy / blurry. Same problem with the cursor. The background is set to black. So why is that? Other forums were no help yet.

What i tried:

the graphics use transparent background. it has no effect to set a transparent color (like 0xff, 0x00, 0x00) to make it transparent by SDL2 (what i thought could run faster).

What i found out:

when i set the background to white, at least the cursor is drawn correctly and looks good, no matter how fast i move it. and as you can see when you run the program: the model is better drawn, when it moves slower, than when it's moving fast. (that's why the model moves fast right, and left slow, to demonstrate it)

I use visual studio 2013. you can download the whole project here to test it:
http://www.wp1105995.server-he.de/project.zip

problem summarized:

SDL does not draw fast enough for any reason. my screen works fine for any other applications (like other games). i would appreciate any help...
Last edited on
Could you post a/some screenshot/s? I'm not sure what you mean by "fuzzy/blurry", or what the drawing speed could have to do with it.
You won't see any mistakes on the screenshot. The screenshot looks the way it should be. The fuzzy / flurry effect just happens, when I run the program.
Could you include the dependencies in the ZIP?
I included the .lib files. It's the same link: http://www.wp1105995.server-he.de/project.zip

Thanks for tryin'
Looks alright to me, although it crashes halfway through on release. Perhaps the "blur" you're seeing is the LCD delay?
Hmm. You're right. When i run it on other devices, like my Notebook, it works fine. is there any way to handle the lcd delay? it must be possible somehow. i just want my application look equal, no matter on which device I run it.
It's simply impossible. What if the screen is broken and only shows the red channel? What if the user is color blind? Ultimately, there comes a point where you have to relinquish control of your data and trust that the hardware can do a good job faithfully transmitting it to a human brain. Hardware limitations are called "limitations" for a reason.
The best you can do is maintain consistency up to the edge of the output device (GPU, sound card, etc.).
Hmm. But it really does not look good on my lcd Screen. Why do other applications then run without any visible frame delays? there must be a magical way, well if there is one with SDL.
It depends heavily on the rate of motion. Movement at a constant speed and direction is easy to track with the eye. In most games you have stuff moving in all directions at different speeds with complex trajectories.
Also, highly contrasting colors require the LCD cells to travel a longer "distance" between activation levels, so switching a pixel from white to black will take longer than switching from gray black. Also also, darkening a subpixel takes longer than brightening it by the same amount because fully bright is the default (power off) state.

The point is, in a picture with lots of movement and colors, LCD delay is harder to notice.
Don't get me wrong. I wouldn't bother any small blitting problems in fast animations. But the cursor disappears when i move it fast from one Position to another and appears at the end Location, where i stop.

The model is more a spot of soft drawn Pixels than beein recognized as a ship.
And as i mentioned, and i think, that's what u meant too: when i set the Background to White, the Cursor at least got no Problems. so some Color combinations don't work on my Screen and i have to fix it somehow, no matter if that is the "normal" Setting of my Screen.

is there any possibility to update rectangles instead of blitting to the whole Screen in SDL2? maybe that would save Performance?
But the cursor disappears when i move it fast from one Position to another and appears at the end Location, where i stop.
I don't see that, although I do see some latency between input and movement. That's probably caused by the vsync.

And as i mentioned, and i think, that's what u meant too: when i set the Background to White, the Cursor at least got no Problems. so some Color combinations don't work on my Screen and i have to fix it somehow, no matter if that is the "normal" Setting of my Screen.

is there any possibility to update rectangles instead of blitting to the whole Screen in SDL2? maybe that would save Performance?
If you show me a video of your screen (that is, point a camera at your physical monitor) I could give you a better informed opinion, but I'm fairly confident that the problem is your screen. Definitely not the speed at which pixels are sent to it or anything like that. The program has 16.6 ms to complete drawing operations and write to the secondary buffer. That's plenty, plenty of time to do what you're doing. Even if we assume that it's not, you wouldn't see a blurry image, you'd see an image with tearing:
http://upload.wikimedia.org/wikipedia/commons/0/03/Tearing_%28simulated%29.jpg
I kind of solved it now. I set the background color to 0x0f, 0x0f, 0x0f, so it's a bit lighter. Then I changed the cursors FPS to 40 and it's fine now. So the cursor does not disappear when i move the cursor faster. I'm sure the model will behave the same now. By the way:

SDL vsync works well. When i turn it off, FPS is about 1500... and stays at 60, when it is turned on. Didn't recognize that before. But thanks for your help. Nice tearing example, didn't know that either.
Topic archived. No new replies allowed.