al_attach_shader_source(3alleg5) | al_attach_shader_source(3alleg5) |
al_attach_shader_source - Allegro 5 API
#include <allegro5/allegro.h> bool al_attach_shader_source(ALLEGRO_SHADER *shader, ALLEGRO_SHADER_TYPE type, const char *source)
Attaches the shader's source code to the shader object and compiles it. Passing NULL deletes the underlying (OpenGL or DirectX) shader. See also al_attach_shader_source_file(3alleg5) if you prefer to obtain your shader source from an external file.
If you do not use ALLEGRO_PROGRAMMABLE_PIPELINE Allegro's graphics functions will not use any shader specific functions themselves. In case of a system with no fixed function pipeline (like OpenGL ES 2 or OpenGL 3 or 4) this means Allegro's drawing functions cannot be used.
TODO: Is ALLEGRO_PROGRAMMABLE_PIPELINE set automatically in this case?
When ALLEGRO_PROGRAMMABLE_PIPELINE is used the following shader uniforms are provided by Allegro and can be accessed in your shaders:
For GLSL shaders the vertex attributes are passed using the following variables:
For HLSL shaders the vertex attributes are passed using the following semantics:
Also, each shader variable has a corresponding macro name that can be used when defining the shaders using string literals. Don't use these macros with the other shader functions as that will lead to undefined behavior.
Examine the output of al_get_default_shader_source(3alleg5) for an example of how to use the above uniforms and attributes.
Returns true on success and false on error, in which case the error log is updated. The error log can be retrieved with al_get_shader_log(3alleg5).
5.1.0
al_attach_shader_source_file(3alleg5), al_build_shader(3alleg5), al_get_default_shader_source(3alleg5), al_get_shader_log(3alleg5)
Allegro reference manual |