al_set_shader_int_vector(3alleg5)
π al_set_shader_int_vector β the Allegro 5 API glow-up π
okay bestie, welcome to the Allegro 5 API section 3, page al_set_shader_int_vector. this is the one that yeets whole arrays of ints straight into your shader's uniform and honestly? it's giving main character energy β¨
β¨ SYNOPSIS β¨
#include <allegro5/allegro.h>
bool al_set_shader_int_vector(const char *name,
int num_components, const int *i, int num_elems)
πΈ DESCRIPTION πΈ
so basically, this sets an integer vector array uniform on the shader that belongs to the current target bitmap. yes, the current target bitmap's shader, not some random one β vibe check your bitmap first, bestie π
the num_components param can only be 1, 2, 3 or 4. no cap. here's the tea:
- if
num_componentsis 1 β an array ofnum_elemsinteger elements gets added. simple. one int per element, periodt. - otherwise β every array element you add is assumed to be a vector with 2, 3 or 4 components inside it. so like, one element is a whole little squad of ints π«Ά
π¦ example time π¦
say you've got a GLSL uniform declared like uniform ivec3 flowers[4], or an HLSL uniform declared like uniform int3 flowers[4] (same energy, different syntax, iykyk). then from your code you'd do this:
int flowers[4][3] =
{
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{2, 5, 7}
};
al_set_shader_int_vector("flowers", 3, (int*)flowers, 4);
look at that. four elements, three components each, handed over like a lil bouquet π
π the return value π
returns true on success π
otherwise it returns false β for example if the uniform by that name does not exist in the shader. so like, if you typo'd the name or the shader just doesn't have it, you get a false and no flowers for you π
fr fr, check that return value. a silent false is how you end up staring at a blank screen at 2am wondering why your shader is unbothered and empty.
β SINCE β
5.1.0 β it's been iconic since 5.1.0, we been knew.
π SEE ALSO π
Allegro reference manual π Β· section 3alleg5 Β· brought to you by the al_set_shader_int_vector(3alleg5) page itself. that's the whole manual, no date drama, just vibes. slay π
β¨π
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms