SDL in Linux with X window system

It is nice to have my programs run in Windows and Linux. SDL can help here.

There was one frustrating thing, when running a first example in linux: I got tearing-effects and couldn’t get rid of them for a few days.

I read, that SDL doesn’t support vsync in Linux, becouse X11 doesn’t and root rights would be requiered to get a direct hardware surface. And of course, no app should run with root rights, if it doesn’t really need to.

There was another hint, that using OpenGL with SDL could help around that problem. And it does! using double buffering within OpenGL enables vsync by default. But, only if your Grafics-driver is setup to do that. And mine per default was not.

In the “NVIDIA X Server Settings > OpenGL Settings” I could setup “Sync to VBlank” and after that: I could setup with SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); wheater or not I want to have vsync. I think 1 is default. But it only helps, when your graphics-driver is correctly setup. And I also read about graphic-drivers which don’t support this. I hope they are dying out.

Maybe this helps someone.

But I also have a question. Since I just start experimenting:
Are there other features, I would get problems within Linux?
Is it for some case bad to have no hardware-surface even with using OpenGL?

Greetings
Oliver

Hi,

I’ve worked on this very issue for a while, and have a possible solution.
Look up the glXSwapIntervalSGI() function. As far as I know, it’s not part
of either SDL or the OpenGL standard, but is an extension provided by my
NVIDIA drivers. Whether or not you can use the same or a similar function if
you have ATI or integrated graphics is a mystery to me because all my
machines happen to be NVIDIA. A similar function, wglSwapIntervalEXT, seems
to do the exact same thing in windows, although requires more effort to be
able to use it.

Let us know if that helped!

ChristianOn Tue, Jul 13, 2010 at 10:44 AM, Ollbert wrote:

It is nice to have my programs run in Windows and Linux. SDL can help
here.

There was one frustrating thing, when running a first example in linux: I
got tearing-effects and couldn’t get rid of them for a few days.

I read, that SDL doesn’t support vsync in Linux, becouse X11 doesn’t and
root rights would be requiered to get a direct hardware surface. And of
course, no app should run with root rights, if it doesn’t really need to.

There was another hint, that using OpenGL with SDL could help around that
problem. And it does! using double buffering within OpenGL enables vsync by
default. But, only if your Grafics-driver is setup to do that. And mine per
default was not.

In the “NVIDIA X Server Settings > OpenGL Settings” I could setup “Sync to
VBlank” and after that: I could setup with
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); wheater or not I want to have
vsync. I think 1 is default. But it only helps, when your graphics-driver is
correctly setup. And I also read about graphic-drivers which don’t support
this. I hope they are dying out.

Maybe this helps someone.

But I also have a question. Since I just start experimenting:
Are there other features, I would get problems within Linux?
Is it for some case bad to have no hardware-surface even with using OpenGL?

Greetings
Oliver


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Something is wrong with the vsync on mac os x 10.6 also, luckily
there’s a workaround in coregraphics:
CGLSetParameter(CGLGetCurrentContext(), 222, @one);
I suggest that you open a bug like
http://bugzilla.libsdl.org/show_bug.cgi?id=1002 and maybe link yours
as a parent of mine.
bye
VittorioOn Fri, Jul 16, 2010 at 11:25 AM, Christian Leger <chrism.leger at gmail.com> wrote:

Hi,

I’ve worked on this very issue for a while, and have a possible solution.
Look up the glXSwapIntervalSGI() function. As far as I know, it’s not part
of either SDL or the OpenGL standard, but is an extension provided by my
NVIDIA drivers. Whether or not you can use the same or a similar function if
you have ATI or integrated graphics is a mystery to me because all my
machines happen to be NVIDIA. A similar function, wglSwapIntervalEXT, seems
to do the exact same thing in windows, although requires more effort to be
able to use it.

Let us know if that helped!

Christian

On Tue, Jul 13, 2010 at 10:44 AM, Ollbert wrote:

It is nice to have my programs run in Windows and Linux. SDL can help
here.

There was one frustrating thing, when running a first example in linux: I
got tearing-effects and couldn’t get rid of them for a few days.

I read, that SDL doesn’t support vsync in Linux, becouse X11 doesn’t and
root rights would be requiered to get a direct hardware surface. And of
course, no app should run with root rights, if it doesn’t really need to.

There was another hint, that using OpenGL with SDL could help around that
problem. And it does! using double buffering within OpenGL enables vsync by
default. But, only if your Grafics-driver is setup to do that. And mine per
default was not.

In the “NVIDIA X Server Settings > OpenGL Settings” I could setup “Sync to
VBlank” and after that: I could setup with
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); wheater or not I want to have
vsync. I think 1 is default. But it only helps, when your graphics-driver is
correctly setup. And I also read about graphic-drivers which don’t support
this. I hope they are dying out.

Maybe this helps someone.

But I also have a question. Since I just start experimenting:
Are there other features, I would get problems within Linux?
Is it for some case bad to have no hardware-surface even with using
OpenGL?

Greetings
Oliver


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org