Re: [AD] shader variable names |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
There are two types of variables that are used by the shader addon. First there are ones that vary from vertex to vertex (al_pos, al_color, al_texcoord), which come from vertex data and there is no API to use those strings (instead there are al_set_shader_vertex_array, al_set_shader_color_array and al_set_shader_texcoord_array). As names, they are only used from GLSL shaders (HLSL shaders use a different mechanism altogether), so C macros for them are completely meaningless (with a tiniest exception of using them inside C string literals to specify shader definition, which I personally think makes for ugly code).
The second type are the uniforms (al_projview_matrix, al_use_tex, al_tex, al_use_tex_matrix, al_tex_matrix) which do not vary per vertex. There is an API to set them, but it won't do anything usually because the Allegro drawing code sets them. You can go al_set_shader_sampler(shader, ALLEGRO_SHADER_VAR_TEX, new_texture, 0), but since Allegro code resets it before drawing you'll have accomplished nothing. Again, you can safely use these macros inside the shader sources (this time it works for both HLSL and GLSL) that are specified as string literals.
So I think these macros should either be gone, or not be public because their usage outside the string literal shader definitions is always a mistake.
-SL
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |