GLEW为什么说我没有扩展名? [英] Why does GLEW say that I don't have extensions?

查看:121
本文介绍了GLEW为什么说我没有扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在OpenGL应用程序的初始化阶段,我正在添加一些代码来检查各种扩展.我立刻遇到了一个绊脚石:

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");

因此,即使我知道确实有S3TC和各向异性过滤,我的视频卡也不支持.我在同一项目上都使用了OpenGL,这没有问题. GLEW可以很好地初始化(使用glewExperimental = true),我的上下文设置正确,其他所有东西都可以正常工作,但是出于某种原因,glew认为我没有这些扩展名.

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.

这是怎么回事?

推荐答案

请允许我(适度)疯狂地猜测:您是否有机会使用核心配置文件上下文?并且您是否因此使用glewExperimental = true?

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?

问题在于GLEW在核心配置文件方面只是损坏.它尝试使用glGetString(GL_EXTENSIONS),这在核心配置文件中是无效的(现代方法是使用glGetIntegerv(GL_NUM_EXTENSIONS, &ext_cnt); for (i=0; i<ext_cnt; i++) glGetStringi(GL_EXTENSION,i)),并且只会产生一个错误. GLEW无法查询可用的扩展.现在,glewExperimental = true的作用是:忽略扩展似乎丢失的事实,并且无论如何都要查询函数指针.这只是一个大技巧,并且可能存在函数指针的事实并不能保证相应的GL扩展确实存在并且可用.这种混乱的另一个副作用就是您正在经历的事情:对于GLEW,这些扩展名不存在.

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.

更新

我不知道为什么GLEW多年来没有解决这个问题(甚至还提出了使它与现代核心配置文件兼容的补丁程序),但是看起来这种行为将一直伴随着我们时间长了.

使用GLEW 2.0,该问题终于得到解决,它确实支持核心配置文件,并且不再需要glewExperimental hack os.它也不会产生GL错误.

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.

这篇关于GLEW为什么说我没有扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆