Why does this line:
float x = 1 - gl_Color.x;
give:
(26): error: Could not implicitly convert operands to arithmetic operator
GLM's vec2 is a utility class representing 2D vector, there are also vec3 , vec4 classes available for 3D and 4D respectively. GLM is also offering matrix classes following same naming conditions mat2 , mat3 , mat4 . You can multiply a matrix with a matrix or a matrix with a vector using overloaded * operator.
vec4 is a floating point vector with four components. It can be initialized by: Providing a scalar value for each component. Providing one scalar value. This value is used for all components.
Attributes are GLSL variables which are only available to the vertex shader (as variables) and the JavaScript code. Attributes are typically used to store color information, texture coordinates, and any other data calculated or retrieved that needs to be shared between the JavaScript code and the vertex shader.
gl_FragColor is the principal variable that your fragment shader is designed to change. If your code does not assign a value to it then it is left undefined for the rest of the pipeline. gl_FragData is an array of data that can be used by the rest of the pipeline.
GLSL (prior to #version 120) does not allow implicit conversions between integer and floating point. 1
is an integer and gl_Color.x
is a float, so you get an error. You need
float x = 1.0 - gl_Color.x;
instead
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