SDL + OpenGL, no hardware acceleration

I’m trying to use OpenGL with SDL, but i whaterever I do I can’t get hardware acceleration with OpenGL. Not even for a simple textureless glQUAD rendering. And it also makes X to eat up the CPU.
First before anyone says: I have hardware acceleration on: Compiz works fluently on a full HD resolution with many effekts turned on such as the water (rain) effect. glxinfo also says that I have direct rendering enabled. Extreme Tux Racer also works fluently.
I’m using Ubuntu 9.04 Jaunty. And I have an nVIDIA 9600M GT (512MB).
I have g++ 4.3.3

I used up a whole day googling up tutorials and rosurces, I tried out many other flags to initialize SDL but nothing seams to work and I’m out of ideas and rosurces. I may try to compile my code on an other computer if my roommate arrive and allow it to me.
I tried out NeHe tutorial 6 linux/SDL version and it gives the same result: no software rendering and lagging X.

This is how I initialize SDL:

Code:

static const UInt SDL_INIT_FLAGS = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTTHREAD;

result = SDL_Init(SDL_INIT_FLAGS);

//Set SDL OpenGL attributes
SDL_GL_SetAttribute(SDL_GL_RED_SIZE,     8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,   8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,    8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,   8);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

//Set video mode.
smScreenSurface = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);

And the OpenGL initialization:

Code:

glEnable(GL_TEXTURE_2D); 
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_DITHER);

I’m linking with this libs: SDL, pthread, SDL_image, GL

Have you tried with the SDL test program “testgl”?On Wed, Sep 23, 2009 at 6:52 AM, TomCatFort wrote:

I’m trying to use OpenGL with SDL, but i whaterever I do I can’t get
hardware acceleration with OpenGL. Not even for a simple textureless glQUAD
rendering. And it also makes X to eat up the CPU.
First before anyone says: I have hardware acceleration on: Compiz works
fluently on a full HD resolution with many effekts turned on such as the
water (rain) effect. glxinfo also says that I have direct rendering enabled.
Extreme Tux Racer also works fluently.
I’m using Ubuntu 9.04 Jaunty. And I have an nVIDIA 9600M GT (512MB).
I have g++ 4.3.3

I used up a whole day googling up tutorials and rosurces, I tried out many
other flags to initialize SDL but nothing seams to work and I’m out of ideas
and rosurces. I may try to compile my code on an other computer if my
roommate arrive and allow it to me.
I tried out NeHe tutorial 6 linux/SDL version and it gives the same result:
no software rendering and lagging X.

This is how I initialize SDL:

Code:

static const UInt SDL_INIT_FLAGS = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK |

SDL_INIT_EVENTTHREAD;

result = SDL_Init(SDL_INIT_FLAGS);

//Set SDL OpenGL attributes
SDL_GL_SetAttribute(SDL_GL_RED_SIZE,     8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,   8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,    8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,   8);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

//Set video mode.
smScreenSurface = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);

And the OpenGL initialization:

Code:

glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_DITHER);

I’m linking with this libs: SDL, pthread, SDL_image, GL


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


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Have you tried temporarily disabling Compiz? I know you stated that
TuxRacer works, but in my experience Compiz interferes with many things.
And just because one OpenGL program works fine doesn’t mean all others
will. I suggest disabling Compiz, if for no other reason than to
eliminate it as a possibility.

SAOn September 23, 2009, TomCatFort wrote:

I’m trying to use OpenGL with SDL, but i whaterever I do I can’t get
hardware acceleration with OpenGL. Not even for a simple textureless
glQUAD rendering. And it also makes X to eat up the CPU. First before
anyone says: I have hardware acceleration on: Compiz works fluently on
a full HD resolution with many effekts turned on such as the water
(rain) effect. glxinfo also says that I have direct rendering enabled.
Extreme Tux Racer also works fluently. I’m using Ubuntu 9.04 Jaunty.
And I have an nVIDIA 9600M GT (512MB). I have g++ 4.3.3

I tried disabling Compiz but OpenGL still goes software and makes X lag. I also tried to run it on my roommates computer, but he get the same software rendering and lagging X. He has the same Ubuntu and he also uses Compiz, but he never experienced this problem.

For testgl: I can’T find it. I tried to google it, tried the search on the libsdl website and also tried it find in the repository but the only thing i found is some broken link and some text mentioning it.

Maybe your app is linking to the wrong (ie. Mesa) GL library. What
parameters did you use for compiling? Also run “ldd” on your binary to
see exactly which GL library it links to on your system.–

  • SR

On Thu, Sep 24, 2009 at 10:06, TomCatFort wrote:

I tried disabling Compiz but OpenGL still goes software and makes X lag. I
also tried to run it on my roommates computer, but he get the same software
rendering and lagging X. He has the same Ubuntu and he also uses Compiz, but
he never experienced this problem.

For testgl: I can’T find it. I tried to google it, tried the search on the
libsdl website and also tried it find in the repository but the only thing i
found is some broken link and some text mentioning it.


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

Download the SDL source, look in the test directory for testgl.cOn Thu, Sep 24, 2009 at 7:06 AM, TomCatFort wrote:

I tried disabling Compiz but OpenGL still goes software and makes X lag. I
also tried to run it on my roommates computer, but he get the same software
rendering and lagging X. He has the same Ubuntu and he also uses Compiz, but
he never experienced this problem.

For testgl: I can’T find it. I tried to google it, tried the search on the
libsdl website and also tried it find in the repository but the only thing i
found is some broken link and some text mentioning it.


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


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

ldd and glxinfo | grep NV should help tooOn Thu, 24 Sep 2009, Simon Roby wrote:

Maybe your app is linking to the wrong (ie. Mesa) GL library. What
parameters did you use for compiling? Also run “ldd” on your binary to
see exactly which GL library it links to on your system.