Micro stuttering while moving SDL_Surfaces |
jannik93
|
Oh, BTW: I am using SDL 2.0.3, just in case that it matters
|
|||||||||||
|
Nathaniel J Fries
|
1) Try not limiting FPS.
2) Use the new render API instead of surfaces. Much faster. |
|||||||||||
|
jannik93
|
Hey,
thanks for the answer. How to do that without a fps limitation? Without a fps limitation it would be sometimes faster, sometimes slower, wouldnt it? Further more, I dont know the new API, are there tutorials? All I've seen on youtube was using the old SDL_Surface way etc. Some more infos would be great, for example what exactly I have to change etc? |
|||||||||||
|
Micro stuttering while moving SDL_Surfaces |
Jonny D
|
There is another consideration here, depending on what you're experiencing. Â I would expect that the program is running fine with respect to FPS.
You are storing your sprite position in an SDL_Rect (Credits[i].Dest), which is a struct of integers. Â When you apply your SPEED to the position, you will get aliasing to integer positions. Â If you want smoother motion, store your positions in floating point (x,y) pairs and use a floating point SPEED. Similarly, you may not be able to get perfectly smooth motion at all with the built-in SDL rendering functions because they don't directly support subpixel positioning. Â I wrote SDL_gpu, which addresses that issue in case you run into it. Jonny D |
|||||||||||
|
jannik93
|
I figured out some things:
I rewrote my three methods now, I am using SDL_Textures now and SDL_Renderer and it appears to be working like a charm. But I have another question in my mind: How do I get the clip_rect from the Texture? |
|||||||||||
|