您不能使用不受支持的扩展,驱动程序将返回编译错误。但是,你能直接从GLSL代码检查一些扩展的可用性吗?有没有这样的事情?GLSL:检查是否支持扩展
#version XXX core
#if supported(EXT_some_extension)
#extension EXT_some_extension: enable
#endif
...
UPDATE:根据尼科尔的流星锤答案。是的,出现在我的脑海里过,但由于某些原因,它不工作
#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)
不起作用)
Nicol Bolas是对的。您只是忘记了扩展名定义的GL_'前缀... – derhass
刚刚意识到这一点。谢谢你的帮助。 – TomatoMato