【发布时间】:2021-03-23 20:21:22
【问题描述】:
您不能使用不受支持的扩展,驱动程序将返回编译错误。但是你能直接从 GLSL 代码检查某些扩展的可用性吗?有这样的事情吗?
#version XXX core
#if supported(EXT_some_extension)
#extension EXT_some_extension: enable
#endif
...
更新:根据 Nicol 的 Bolas 回答。是的,这也出现在我的脑海中,但由于某种原因,它不起作用
#version 150 core
#extension ARB_explicit_attrib_location : enable
#ifdef ARB_explicit_attrib_location
#define useLayout layout(location = 2)
#else
#define useLayout //thats an empty space
#endif
in vec2 in_Position;
useLayout in vec2 in_TextureCoord;
...
宏“useLayout”总是设置为空白空间,但如果我只留下#enable 指令而没有条件它将使用它(我的驱动程序支持它)。看起来扩展没有被定义,它是别的东西(可能?)(#if defined(ARB_explicit_attrib_location) 也不起作用)
【问题讨论】:
-
尼可波拉斯是正确的。您只是忘记了扩展定义的
GL_前缀... -
刚刚意识到这一点。谢谢你的帮助。