-
Notifications
You must be signed in to change notification settings - Fork 0
Variables
Gustav Sterbrant edited this page Oct 11, 2024
·
2 revisions
To declare a variable with GPULang you can take several routes. Examples:
Declare a variable with an explicit type, uninitialized:
color : f32x4;
Declare a variable with an inferred type:
color = f32x4(r,g,b,a);
Declare a variable with an explicit type, initialized through conversion
color : f32x4 = 1.0f;
GPULang doesn't offer lazy type inference. The type must be known on the same statement where the variable is declared.
GPULang offers a few conversion methods for ease of use. By default, implicit conversion is enabled but can be disabled with the disallowImplicitConversion
flag passed to the compiler. Explicit conversion is always allowed, obviously.