How raylib wraps GLSL

· sepi's blog

#game #raylib #glsl #opengl #3d #programming

as you may know I've been working on a little 3d game using wonderful raylib. one of the nice things about raylib is that it puts a nice abstraction layer on top of opengl and comes with a lot of utility functions to do all sorts of 3d operations, however you still need to wirte shadres manually if you need custom effects.

if all you want is to put some 3d objects on the screen you can get away with raylib default functionalities. but for things like lighting and particle effect you need to write custom shader codes. raylib by default makes many necessary values available to you on the shaders.

for example the model view projection matrices are all defined for you when you add a camera to your scene, and you can access these values in glsl without explicitely binding them. however I find the documentation on this area really poor. It took me a couple of hours and I ended up consulting rlgl source code to understand which uniform is bounded by default and what names are assigned to them.

there are these following vertex attribues and uniform locations already defined in raylib:

you can also override these names if you prefer by using the following two functions:

1int GetShaderLocation(Shader shader, const char *uniformName);
2int GetShaderLocationAttrib(Shader shader, const char *attribName);