al_set_shader_int_vector(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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_components is 1 β€” an array of num_elems integer 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