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

我只是一个虾纸丫 提交于 2020-01-16 04:04:14

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/22619406/why-does-glew-say-that-i-dont-have-extensions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!