[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 02/25/2013 08:27 AM, Elias Pschernig wrote:
I think in IRC we said that al_link_shader is superfluous as well.
al_attach_shader_* and al_use_shader should be enough.
The idea to remove al_link_shader would involve its functions being
automatically ran when both the vertex shader and a pixel shader sources
were attached... But I now think that that's is a bit too magical for my
liking. Firstly... it is still not clear to me whether or not you always
need both a vertex and a pixel shader for stuff to display. Secondly,
there is a third type of shader, the geometry shader, which we might
want to add one day... this one is definitely optional which complicates
the auto-detection of a complete shader program. I think it's just
clearer and simpler to keep al_link_shader as an explicit step.
We can even make the API a bit cleaner with it in place. Right now
al_attach_shader and al_link_shader both can fail and both yield a build
log. I think it'd be simpler for the user to have al_attach_shader
always succeed and only invoke the platform specifics inside
al_link_shader. The only caveat I can think of is that you lose some
fine grained error handling (I don't think it's an issue as I can't
think of these failures being recoverable in any meaningful sense) and
that you get both the vertex and the pixel shader error logs in one
string (we can annotate them in the OpenGL case in principle).
al_set_shader, however, probably can be subsumed into al_use_shader (as
the TODO comment in the documentation already suggests anyway).
To be clear... the entire API would be this:
al_create_shader - Creates the shader
al_destroy_shader - Destroys the shader
al_attach_shader_source - Sets an internal variable to point to the
source (maybe making a copy of it). Cannot fail.
al_attach_shader_source_file - Loads the source from a file. Can fail if
the file doesn't exist, but succeeds otherwise.
al_link_shader - (maybe renamed to al_build_shader) does the necessary
steps to compile and link the OpenGL program/D3D effect. Produces a
build log upon failure
al_get_shader_log - (maybe renamed to al_get_shader_build_log) does the
same thing as now
al_use_shader - does the same thing as now, but also grabs the locations
of the uniforms that Allegro core/primitives addon uses
al_set_shader_* - set the various uniforms. Do the same thing as now
-SL