There is a bool
type for shader variables I'd like to use, but I couldn't find what size it have. This matters because when setting up vertex attribute pointer I specify the type of data which can be
GL_BYTE,
GL_UNSIGNED_BYTE,
GL_SHORT,
GL_UNSIGNED_SHORT,
GL_INT,
GL_UNSIGNED_INT,
GL_FLOAT, or
GL_DOUBLE
In c++ generally bool
should have the same size as 4 byte int
, but can I assume the same for GLSL or does it have only 1 byte?
Boolean variables are stored as 16-bit (2-byte) numbers, but they can only be True or False.
The actual size of a C# bool is one byte.
bool The bool type takes one byte and stores a value of true (1) or false(0).
So, the alignment of a mat4 is like that of a vec4, which is 16 bytes. And the size of a mat4 is 4*sizeof(vec4) = 4*16 bytes.
This matters because when setting up vertex attribute pointer I specify the type of data which can be
It's irrelevant, since vertex attributes cannot be booleans. From the GLSL 3.30 specification:
Vertex shader inputs can only be float, floating-point vectors, matrices, signed and unsigned integers and integer vectors. Vertex shader inputs can also form arrays of these types, but not structures.
Booleans are not on that list.
However, if you want to know what the size of a GLSL bool
is in terms of uniform blocks, it has the same size as uint
: 32-bits.
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