Sdl Hickups


panik

Member
Joined
Sep 21, 2008
Messages
187
Age
53
Location
Netherlands
[Edit: solved: Ubuntu + Nvidia Fail]

I've been experimenting with the LazyFoo tutorials. They're great, but I find the drawing of moving images somewhat "choppy".
I tried on Linux and Windows.

It's best seen on "Lesson21 - Scrolling" (http://lazyfoo.net/SDL_tutorials/lesson21/index.php)

First I thought it was the SDL rendering. Changing the drawing methods to OpenGL didn't help, it's still "choppy".
I used this code for drawing: http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL
Also I changed to OpenGL to be able to rotate surfaces more easily (that works great by the way).

Using "Frame independent movement" (Lesson32 on LazyFoo) also doesn't help against choppiness.

I get over 850 FPS on my Ubuntu machine. However: it's choppy. As if every couple of hundred milliseconds a "hickup" occurs.
In the gameloop, there's also a "SDL_Delay(1)". A delay of 1 millisecond to release burden on the processor somewhat.

Please find my project here:
Choppy SDL project

A Makefile is included. After "make", start "./game" from the commandline. It probably runs on Linux only though (I use Ubuntu).
Use the arrow-keys to move the arrow, escape to quit.

I mostly did Java before, and this is my first project ever written in C++/SDL. It's in its *very* early stages.
I would love feedback on all aspects of the code, but mostly would like to hear your thoughts on the "choppinness".

Thanks in advance!

Edit:
Also found this topic:
http://www.gp32x.de/board/index.php?/topic/49951-sdl-smooth-scrolling-tips/
And tried the demos at:
http://olofson.net/examples.html
But I think they're not that smooth as well.
 
Last edited by a moderator:
It seems pretty smooth when I try it.

I've used the following makefile to get it to compile under mingw:
http://queenofbuckets.com/makefile_choppy_sdl.zip

I can't help you much other than that, I'm just starting out with C++ and SDL myself.
 
hisaki said:
It seems pretty smooth when I try it.

I've used the following makefile to get it to compile under mingw:
http://queenofbuckets.com/makefile_choppy_sdl.zip

I can't help you much other than that, I'm just starting out with C++ and SDL myself.
Thanks much for trying it out and for the makefile!

I just installed the game "Kobo Deluxe" (apt-get install kobodeluxe) on Ubuntu. It's written by this guy Olofson, and it seems he knows what he's talking about.
It has the same kind of "choppinness".

This is what he writes here: http://lists.libsdl.org/pipermail/sdl-libsdl.org/2003-September/037731.html
...your "problem" is that you expect scrolling to be perfectly smooth, arcade machine style. However, there are various problems that makes this very hard to achieve on PC style platforms...
I'm not involved in that discussion, but maybe this is just the best it gets (hope I'm wrong though, and it runs better on the Pandora).
Thanks again.
 
Last edited by a moderator:
Thanks guys, this is quite a relief.
It's definitely playable at my end. I will stop worrying about it and implement the rest of the classes, which brings me to:

Sphinxter said:
Grievous overkill.
By "overkill", do you mean: "All these classes only to make a programmer art arrow move along the screen, this could be done in a fifth of the amount of code!" ?
If you do, then I wholeheartedly agree. It *is* overkill.

However, what I hope to achieve with this is (in the end) a generic game engine that is scriptable by either Lua or Javascript and I don't want the code to turn into spaghetticode on day 1. I will probably make another topic about that in due time. Also, I only know how to think in objects. That's what Java does to a person. :)

I really appreciate the time you took to have a look at it.
 
Last edited by a moderator:
Choppy?

Do you mean tearing (vsync related), or do you mean it's missing the occasional frame? (also vsync related - many displays are 59.94hz instead of 60hz... but don't advertise it)
 
Yeah, "choppy" :)

Sorry, I don't really know how to describe it.

It might be vsync. I don't see how it might miss a frame.
I'll need to read in to that and experiment.

Thanks!
 
Nvidia user? Uninstall nvidia driver and use nouveau. Magic!

2D rendering, with or without opengl is choppy on ubuntu, specially with composition (compiz). Try disabling compiz. 2D with or without opengl will work better.

note: ubuntu nouveau driver still does not support opengl 3d acceleration
 
fdelapena said:
Nvidia user?
That's it. Thank you so much.

Uninstalling the Nvidia driver didn't help though. It was still choppy, but now at 38 FPS :)

Your comments made me plug in a *very* old computer I have. It's silky smooth on that old machine at 150 FPS!
Strange, because that's also Ubuntu (7.04) + Nvidia.

Anyway, I know where to look now. Thanks again, made my day.
 
Last edited by a moderator:
good to hear it, hardware can make choppy performance... in my case, integrated graphics on the mainboard and bad bios setup configuration between northbridge, southbridge and processor can do bottlenecks. Nouveau driver is available out of the box since ubuntu 10.04 and pretty fast 2D acceleration. My laptop with geforce 7300 runs light fast, my atx tower with geforce 6100 is slower but works fine and very better than nvidia driver. VESA or NV drivers are not good for 2D today, but the 2D performance without acceleration is better than nvidia.
 
I had to specifically enable and disable the "Special Effects" for the driver to install, but now it runs great!
My eeepc is also very happy with this fix.

Also:
fdelapena said:
note: ubuntu nouveau driver still does not support opengl 3d acceleration
I guess it does, Sauerbraten runs better than ever! :)
 
Last edited by a moderator:
panik said:
fdelapena said:
note: ubuntu nouveau driver still does not support opengl 3d acceleration
I guess it does, Sauerbraten runs better than ever! :)
It seems to support it on the NV40 GPUs and newer. I should try it on my Arch Linux Geforce 7900 GS...
The really old GPUs, like in the 4000-series and older, still don't have 3D support IIRC.

http://nouveau.freedesktop.org/wiki/FeatureMatrix
 
Last edited by a moderator:
Back
Top