How does one go about setting the GLSL version on Mac? Is this even possible? I'm running a fragment shader and would like to create an array of vec3s, but the shader compiler is 开发者_如何学Cproducing an error indicating that I need to use a higher GLSL version. The specific error is
'array of 3-component vector of float' : array type not supported here in glsl < 120
Thanks for the help.
Although I have no Mac experience, you can specify the lowest required version of your shader (which is 1.10 by default, I think) by using something like
#version 120 //shader requires version 1.20
as first line in your shader. But of course the specified version also has to be supported by your hardware and driver, which you can check for with glGetString(GL_SHADING_LANGUAGE_VERSION)
.
EDIT: I confirmed this with a look into the GLSL spec, which also says that all shaders that are linked together should target the same version, although I'm quite sure I myself have once successfully violated this, but this may be due to my forgiving nVidia driver. So if it still complains when linking, add the same #version
tag to the vertex shader, too.
精彩评论