Haydn V. Harach
Haydn V. Harach

Reputation: 1275

Why does GLEW say that I don't have extensions?

I'm at the initialization phase of my OpenGL application, and I'm adding some code to check for various extensions. Immediately I hit a stumbling point:

/* Check for EXT_texture_compression_s3tc */
if (GLEW_EXT_texture_compression_s3tc)
    infomore("GL_EXT_texture_compression_s3tc supported.\n");
else
    errormore("GL_EXT_texture_compression_s3tc unsupported.\n");

/* Check for anisotropic filtering */
if (GLEW_EXT_texture_filter_anisotropic)
    infomore("GL_EXT_texture_filter_anisotropic supported.\n");
else
    warnmore("GL_EXT_texture_filter_anisotropic unsupported.\n");

According to this, both S3TC and anisotropic filtering are unsupported by my video card, even though I know for a fact that I do have it. I have used both myself with OpenGL on this very same project with no issue. GLEW initializes fine (with glewExperimental = true), my context is set properly, and everything else works fine, but for some reason glew thinks I don't have these extensions.

What's going on here?

Upvotes: 1

Views: 627

Answers (1)

derhass
derhass

Reputation: 45362

Please allow my sume (moderately) wild guesses: Do you, by any chance, use a core profile context? And do you use glewExperimental = true because of this?

The problem is that GLEW is just broken with respect to core profiles. It tries to use glGetString(GL_EXTENSIONS), which is invalid in core profiles (the modern way is to use glGetIntegerv(GL_NUM_EXTENSIONS, &ext_cnt); for (i=0; i<ext_cnt; i++) glGetStringi(GL_EXTENSION,i) ), and will just generate an error. GLEW fails to query which extensions are available. Now what glewExperimental = true does is: ignore the fact that the extensions seem to be missing, and query the function pointers anyway. This is just a big hack, and the fact that the function pointer might be present does not guarantee that the repective GL extension is really present and useable. The other side effect of this mess is what you are experiencing: for GLEW, these extensions are just not present.

UPDATE

I don't know why GLEW hasn't fixed this isse since years (and there are even proposed patches to make it compatible to modern core profiles), but it looks like this behavior will stay with us for a long time.

With GLEW 2.0, the issue has finally be resolved, It does support core profiles, and the glewExperimental hack os no longer needed. It will also not generate a GL error.

Upvotes: 3

Related Questions