user11632619
user11632619

Reputation:

To what values are GLSL variables initialized by default?

I know that in c and c++, the variables are uninitialized by default. On the other hand in java they are initialized to 0 or null by default.

What is the corresponding default initialization in GLSL? Specifically, what are the default values when we create the following variables?

int val;

vec4 arr[20];

Upvotes: 3

Views: 1846

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473212

It depends on the storage qualifier of the variable in question. uniform variables are always initialized to 0/false. const-qualified variables cannot be uninitialized. All other uninitialized variables either get their contents from external resources (UBOs and the like) or have undefined values.

Upvotes: 7

Related Questions