I am reading a tutorial about openGL 3.3 (where naturally GLSL 330 is in use). Unfortunately my hardware is limited to openGL 3.0 (where GLSL 130 is the newest format). In GLSL 130 the syntax
layout (location = 1) in vec4 position;
produces an error. Most importantly a code where several instances of "layout" are applied to different variables does not work. I even tried
#extension ARB_explicit_attrib_location : require
which is also not supported. Is there a way to rewrite these statements from 330 in 130 equivalently?
layout(location = output index) out vec4 outColor; As with vertex shader inputs, this allows the user to forgo the use of glBindFragDataLocation. Similarly, the values in the shader override the values provided by this function.
Yes, gl_FragColor is deprecated. You should use the following syntax: layout(location = 0) out vec4 diffuseColor; It is included in the GLSL 4.60 spec under the section 7.1.
A uniform is a global Shader variable declared with the "uniform" storage qualifier. These act as parameters that the user of a shader program can pass to that program. Their values are stored in a program object.
Std140 is a standardized memory layout for GLSL shader interface blocks (e.g. uniform blocks). An interface block is a group op typed GLSL variables. For details on the layout rules for std140, please refer to the section 2.12. 6.4 “Standard Uniform Block Layout” of the OpenGL ES 3.0 Specification.
If your implementation does not support ARB_explicit_attrib_location (either as an extension or as version 330
or later), then you cannot use explicit attribute locations. You must specify them before the linking phase with glBindAttribLocation
.
And technically, your "hardware" could do this just fine. NVIDIA and ATI support this extension in all hardware that they still support in drivers. This is an API convenience. I'm guessing you're on some from of Intel hardware. If so, you have my sympathy.
BTW, is that my code, by chance?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With