Help: glewInit() fails in GLX + xlib app

I had to switch over from GLEE to GLEW a while back, because GLEE is falling behind (not supporting the latest versions of OpenGL). When I did this, the win32 version of my program still runs, but the linux version generates a segment violation when it calls glXChooseFBConfig() — apparently because the code loads a function address of zero for glXChooseFGConfig().

I’ve driven myself nuts trying to figure out why this problem occurs. I have some results, but I don’t understand them.

Before it does much of anything else, and certainly before it calls any xlib, GLX or OpenGL functions, my program calls glewInit()… which immediately calls glewContextInit().

The glewContextInit() function calls glGetString(GL_VERSION), which returns a value of zero… which indicates an error. This prevents glewInit() from initializing much of anything, including function addresses like glXChooseFGConfig(). A subsequent call of glewGetErrorString(error) on the error value returned by glewInit() indicates “Missing GL version”.

So, my question is this. Why is this happening?

Note that I comile and build glew.c into my program, not link in the library (on both win32 and linux). This is how I did things with the GLEE package previously too.

Does anyone understand this? Why would something as fundamental as glGetString() not return a value? Note that even though glewInit() failed, the glX functions that return the version and extensions and other GLX information work just fine (return correct values). The version of GLX is v1.40.

I’ll very much appreciate any help.

Oh, one minor additional question. Why does “glew.h” include “glu.h”? My program doesn’t need GLU or SDL or any other packages beyond xlib and glx and opengl. I suspect I can simply #ifdef out the section in “glew.h” that includes this, which works fine on win32.

system

ubuntu v10.04 - 64-bit edition
AMD phenom II x4 CPU w/16GB
nvidia driver 195.36.24
GLX version 1.40
CodeBlocks IDE

Note that the “glxinfo” utility app reports:
OpenGL version string: 3.2.0 NVIDIA 195.36.24
OpenGL renderer string: GeForce 8600 GT/PCI/SSE2
OpenGL shading language version string: 1.50 NVIDIA via Cg compiler

You need to create a rendering context BEFORE calling glewInit().

I’m not sure if glew requires glu.h but #ifdef’ing it away may only be working because it is included elsewhere as well.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.