如果使用不支持的扩展,驱动程序将返回编译错误。但是您能否直接从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_
前缀... - derhass