Reputation: 51
I'm trying to check if vec3 values have the same components.
int same = 0;
vec3 v1 = vec3(1.0f, 0.0f, 0.0f);
vec3 v2 = vec3(0.0f, 0.0f, 0.0f);
if (v1 == v2) // <- this part
{
same = 1;
}
Is == the correct relational operator for vec3 type?
If not, what can I use (operators and functions are also welcome) to compare vec3 values?
Upvotes: 1
Views: 685
Reputation: 22165
The GLSL 4.5 Specification, Section 5.9 states:
The equality operators equal (==), and not equal (!=) operate on all types [...]. They result in a scalar Boolean. [...] For vectors, matrices, structures, and arrays, all components, members, or elements of one operand must equal the corresponding components, members, or elements in the other operand for the operands to be considered equal.
To answer your question: Yes, the ==
operator compares weather two vectors have the same value in all components.
Upvotes: 1