You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Raylib defines some SHADER_LOC_... constants which it automatically uses to set the available locations in LoadShader().
If I want to add some of my own locations, like in the example "basic_lighting", where it uses a bunch, it would be nice to be able to look them up once, and store/cache them in the Shader::locs array. The tricky part is that it's not obvious which of those slots are not used, nor how many are possible to store there.
Looking in the source, config.h and rlgl.c, it becomes clear that the last predefined location is id = 25 (at the moment) and the locs array is allocated with size 32.
So, I propose adding a SHADER_LOC_USER constant, which would be defined as <last predefined location> + 1 (in practice, just last in the ShaderLocationIndex enum). This enables the developer to know that anything above SHADER_LOC_USER is available.
So, defining constants for custom locations becomes simpler, e.g.: SHADER_LOC_FOG_DAMPNESS = SHADER_LOC_USER + 3 (completely fictitious 😄).
Also, the RL_MAX_SHADER_LOCATIONS could be bumped to like 128 (or 256 even). Alternatively, the max could be settable at run-time, before the first shader is created (i.e. if the Shader struct becomes too large in some context).
Note that the locs array doesn't affect how many locations actually exist in a shader, it's just client-side storage for remembering (some of) them 😉.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently, Raylib defines some
SHADER_LOC_...
constants which it automatically uses to set the available locations inLoadShader()
.If I want to add some of my own locations, like in the example "basic_lighting", where it uses a bunch, it would be nice to be able to look them up once, and store/cache them in the
Shader::locs
array. The tricky part is that it's not obvious which of those slots are not used, nor how many are possible to store there.Looking in the source,
config.h
andrlgl.c
, it becomes clear that the last predefined location is id = 25 (at the moment) and thelocs
array is allocated with size 32.So, I propose adding a
SHADER_LOC_USER
constant, which would be defined as<last predefined location> + 1
(in practice, just last in theShaderLocationIndex
enum). This enables the developer to know that anything aboveSHADER_LOC_USER
is available.So, defining constants for custom locations becomes simpler, e.g.:
SHADER_LOC_FOG_DAMPNESS = SHADER_LOC_USER + 3
(completely fictitious 😄).Also, the
RL_MAX_SHADER_LOCATIONS
could be bumped to like 128 (or 256 even). Alternatively, the max could be settable at run-time, before the first shader is created (i.e. if theShader
struct becomes too large in some context).Note that the
locs
array doesn't affect how many locations actually exist in a shader, it's just client-side storage for remembering (some of) them 😉.edit: rephrased a bit
Beta Was this translation helpful? Give feedback.
All reactions