Advertisement

SDL/OpenGL rendering on Linux

Started by February 02, 2005 09:38 AM
7 comments, last by Mazer 19 years, 9 months ago
Some time ago, I began programming a sequel to a little game I made using SDL (for windowing and loading textures) and OpenGL (for actual rendering) on Windows. Now that I have my own computer I switched over to Linux and I want to continue working on this game. After a little work with the makefile and fixing include paths in my source files I've managed to get the program to compile without error. However, I can't manage to get it to run properly. Something about the flags I pass to SDL_SetVideoMode(). If I use SDL_HWSURFACE|SDL_OPENGL (which I originally used on Windows), no window will open up and in the console I have a message saying "Couldn't find matching GLX visual" but the rest of the program will run alright. If I use SDL_HWSURFACE (without the SDL_OPENGL) the window will open and I won't get an error message, but nothing renders (just a black screen, no doubt because I'm trying to use OpenGL commands without having the SDL_OPENGL flag). When I was installing the latest drivers for my nVidia graphics card there was some mention of GLX so I'll look into that. But has anybody else encountered this problem before (and managed to solve it, hopefully)? I get the same problem if I try to compile and run the Linux/SDL ports of the NeHe lessons. Little help, please? Thanks in advance. -Nick
take out hwsurface flag
Advertisement
also, make sure u have 3d drivers installed, (i hope for your sake you have an nvidia card) otherwise 3d performance will suck bigtime, as it uses a software renderer (mesaGL or mesa3D, depending on what version you have)
Quote: Original post by Anonymous Poster
take out hwsurface flag

Sorry, I should have mentioned that with SDL_OPENGL only, it doesn't open the window either.

Quote: Original post by Anonymous Poster
also, make sure u have 3d drivers installed, (i hope for your sake you have an nvidia card) otherwise 3d performance will suck bigtime, as it uses a software renderer (mesaGL or mesa3D, depending on what version you have)

I could use some clarification here. Yes, I have an nVidia card (hence the downloading of nVidia drivers). I've heard about mesaGL/mesa3D but I don't actually know about them. Could you explain them and their relevance to my situation please?
hmm well my SDL/OpenGL Loading flags are
flags = SDL_OPENGL;
if(isFullscreen)
{
flags = flags | SDL_FULLSCREEN | SDL_NOFRAME;
}
you should be able to pick what the if statement does

anyway, i know for certain that works on both windows AND linux.

Mesa3D and MesaGL are one and the same, it used to be GL but was forced to change its name for legal reasons, hence it is now 3D. it is a software renderer, and it's api is a replica of the OpenGL API, and is basically like the 3d part of a driver, cept it doesn't send it to the video card. it works fine, just very slow.
it must be a problem with your driver, what version and distro of linux are you running? btw, all these AP's are one and the same ;)
Advertisement
Make sure use are using the nvidia drivers.

1. Check that the nvidia module is loaded (lsmod)
2. Look in your xorg.conf, make sure 'Load "glx"' is in the "Module" section,
and that the Driver option in section "Device" is "nvidia" (NOT nv!)
3. If using gentoo, try `opengl-update nvidia`

If youre sure of all that, then:
Does glxgears work? If not show the error message.
- Jezper Blixt
Quote: Original post by Anonymous Poster
it must be a problem with your driver, what version and distro of linux are you running? btw, all these AP's are one and the same ;)

I'm currently (at home) running Slackware. I have friends with other distros, and I'm trying to get them to test it and see what output they get.

Quote: Original post by qbic
Make sure use are using the nvidia drivers.

1. Check that the nvidia module is loaded (lsmod)
2. Look in your xorg.conf, make sure 'Load "glx"' is in the "Module" section,
and that the Driver option in section "Device" is "nvidia" (NOT nv!)
3. If using gentoo, try `opengl-update nvidia`

If youre sure of all that, then:
Does glxgears work? If not show the error message.

- Jezper Blixt

I'll check all of that out at home. Though glxgears did work (and the SDL code it was using was pretty much the same as mine).

Thanks for the help so far.

-Nick
OK, I did lsmod, and it shows the nvidia module is loaded. I have everything set up like you said in the xorg.conf. glxgears does work with no error messages.

EDIT: ZOMG wow! Should I feel stupid? I had this code in my SDL initialisation:

	SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );	SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );	SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );	SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 5 );	SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 32 );	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

I can't say I understand what it actually does... I just remember reading somewhere that I needed it (it worked fine under Windows). But I just commented it out on a whim and it works now! (using either SDL_HWSURFACE|SDL_OPENGL or just SDL_OPENGL flags). Thanks anyways guys, I totally appreciate the time you took to help me!

-Nick (yay!)

This topic is closed to new replies.

Advertisement