开发者

Setting the GLSL version on Mac

开发者 https://www.devze.com 2023-03-31 03:48 出处:网络
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 开发者_如何学Cproduc

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号