[pkg-nvidia-devel] Bug#445363: nvidia-glx incompatible to xlibmesa-gl-dev
bug-nvidia-glx at karimmi.de
bug-nvidia-glx at karimmi.de
Fri Oct 5 10:06:52 UTC 2007
Package: nvidia-glx
Version: 1.0.7174-3
Tags: patch
When one has nvidia-glx installed and compiles programs which use libGL,
compilation works but the resulting program often does not. Below an
example program.
The reason seems to be that when both xlibmesa-gl-dev and nvidia-glx are
installed, then the symlink /usr/lib/libGL.so is broken. Replacing this
link by a link to the correct libGL.so.xxx fixes the bug. (I think the
package nvidia-glx should care about this.)
I am using Sarge, but as far as I can tell, the bug is still there in
Etch.
Example program follows (code copy-pasted out of sdl examples and out of
extreme-tuxracer). Compile the program with
g++ -I../include -g test.cc -L../lib -lGLU -lGL -lpthread -lSDL -o test
The program outputs
vendor: (null)
renderer: (null)
version: (null)
extensions: (null)
when it does not work and correct information after bugfix.
-----
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <cstdarg>
#include <cstdlib>
#include <cstdio>
#include <cstring>
static SDL_Surface *screen = NULL;
/* Extension func ptrs *must* be initialized to NULL */
PFNGLLOCKARRAYSEXTPROC glLockArraysEXT_p = NULL;
PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT_p = NULL;
typedef void (*(*get_gl_proc_fptr_t)(const GLubyte *))();
void init_opengl_extensions()
{
get_gl_proc_fptr_t get_gl_proc;
get_gl_proc = (get_gl_proc_fptr_t) SDL_GL_GetProcAddress;
if ( get_gl_proc ) {
glLockArraysEXT_p = (PFNGLLOCKARRAYSEXTPROC)
(*get_gl_proc)( (GLubyte*) "glLockArraysEXT" );
glUnlockArraysEXT_p = (PFNGLUNLOCKARRAYSEXTPROC)
(*get_gl_proc)( (GLubyte*) "glUnlockArraysEXT" );
if ( glLockArraysEXT_p != NULL && glUnlockArraysEXT_p != NULL )
{
} else {
glLockArraysEXT_p = NULL;
glUnlockArraysEXT_p = NULL;
}
}
}
void print_gl_info()
{
fprintf( stderr, " vendor: %s\n", glGetString( GL_VENDOR ) );
fprintf( stderr, " renderer: %s\n", glGetString( GL_RENDERER ) );
fprintf( stderr, " version: %s\n", glGetString( GL_VERSION ) );
fprintf( stderr, " extensions: %s\n", glGetString( GL_EXTENSIONS )
);
}
void setup_sdl_video_mode()
{
Uint32 video_flags = SDL_OPENGL;
int bpp = 0;
int width, height;
video_flags |= SDL_RESIZABLE;
bpp = 0;
width = 800;
height = 600;
if ((screen = SDL_SetVideoMode(width, height, bpp, video_flags)) ==
NULL){
exit(1);
}
glViewport(0,0,width,height);
}
void winsys_init( int *argc, char **argv, char *window_title,
char *icon_title ) {
Uint32 sdl_flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
if ( SDL_Init( sdl_flags ) < 0 ) { exit(1); }
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
setup_sdl_video_mode();
SDL_WM_SetCaption( window_title, icon_title );
}
int main( int argc, char *argv[] ) {
winsys_init( &argc, argv, "test", "test" );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
init_opengl_extensions();
print_gl_info();
return 0;
}
More information about the Pkg-nvidia-devel
mailing list