1al_attach_shader_source(3)                          al_attach_shader_source(3)
2
3
4

NAME

6       al_attach_shader_source - Allegro 5 API
7

SYNOPSIS

9              #include <allegro5/allegro.h>
10
11              bool al_attach_shader_source(ALLEGRO_SHADER *shader, ALLEGRO_SHADER_TYPE type,
12                  const char *source)
13

DESCRIPTION

15       Attaches the shader's source code to the shader object and compiles it.
16       Passing NULL deletes the underlying (OpenGL or  DirectX)  shader.   See
17       also  al_attach_shader_source_file(3)  if  you  prefer  to  obtain your
18       shader source from an external file.
19
20       If you do  not  use  ALLEGRO_PROGRAMMABLE_PIPELINE  Allegro's  graphics
21       functions  will  not  use any shader specific functions themselves.  In
22       case of a system with no fixed function pipeline (like OpenGL ES  2  or
23       OpenGL 3 or 4) this means Allegro's drawing functions cannot be used.
24
25       TODO: Is ALLEGRO_PROGRAMMABLE_PIPELINE set automatically in this case?
26
27       When  ALLEGRO_PROGRAMMABLE_PIPELINE  is  used the following shader uni‐
28       forms are provided by Allegro and can be accessed in your shaders:
29
30       al_projview_matrix
31              matrix for Allegro's orthographic projection multiplied  by  the
32              al_use_transform(3)  matrix.   The  type  is  mat4  in GLSL, and
33              float4x4 in HLSL.
34
35       al_use_tex
36              whether or not to use the bound texture.  The type  is  bool  in
37              both GLSL and HLSL.
38
39       al_tex the  texture if one is bound.  The type is sampler2D in GLSL and
40              texture in HLSL.
41
42       al_use_tex_matrix
43              whether or not to use a texture matrix (used by  the  primitives
44              addon).  The type is bool in both GLSL and HLSL.
45
46       al_tex_matrix
47              the  texture matrix (used by the primitives addon).  Your shader
48              should multiply the texture coordinates  by  this  matrix.   The
49              type is mat4 in GLSL, and float4x4 in HLSL.
50
51       For  GLSL  shaders the vertex attributes are passed using the following
52       variables:
53
54       al_pos vertex position attribute.  Type is vec4.
55
56       al_texcoord
57              vertex texture coordinate attribute.  Type is vec2.
58
59       al_color
60              vertex color attribute.  Type is vec4.
61
62       For HLSL shaders the vertex attributes are passed using  the  following
63       semantics:
64
65       POSITION0
66              vertex position attribute.  Type is float4.
67
68       TEXCOORD0
69              vertex texture coordinate attribute.  Type is float2.
70
71       TEXCOORD1
72              vertex color attribute.  Type is float4.
73
74       Also,  each  shader variable has a corresponding macro name that can be
75       used when defining the shaders using string literals.  Don't use  these
76       macros  with  the other shader functions as that will lead to undefined
77       behavior.
78
79       · ALLEGRO_SHADER_VAR_PROJVIEW_MATRIX for "al_projview_matrix"
80
81       · ALLEGRO_SHADER_VAR_POS for "al_pos"
82
83       · ALLEGRO_SHADER_VAR_COLOR for "al_color"
84
85       · ALLEGRO_SHADER_VAR_TEXCOORD for "al_texcoord"
86
87       · ALLEGRO_SHADER_VAR_USE_TEX for "al_use_tex"
88
89       · ALLEGRO_SHADER_VAR_TEX for "al_tex"
90
91       · ALLEGRO_SHADER_VAR_USE_TEX_MATRIX for "al_use_tex_matrix"
92
93       · ALLEGRO_SHADER_VAR_TEX_MATRIX for "al_tex_matrix"
94
95       Examine the output of al_get_default_shader_source(3) for an example of
96       how to use the above uniforms and attributes.
97
98       Returns true on success and false on error, in which case the error log
99       is updated.  The error log can be retrieved with al_get_shader_log(3).
100

SINCE

102       5.1.0
103

SEE ALSO

105       al_attach_shader_source_file(3),                    al_build_shader(3),
106       al_get_default_shader_source(3), al_get_shader_log(3)
107
108
109
110Allegro reference manual                            al_attach_shader_source(3)
Impressum