This is not really shader thing bu't I'm facing this in shader related context
I need to load shader from file and be able to use it's uniforms without hardcoding (at least so much as possible).
to update the uniform I need to know it's type to use proper GL call from dglOpenGL.pas
for example updating mat4 needs glUniformMatrix4fv and updating a vec3 needs glUniform3fv.
Is it possible to keep and read this procedure name from file with shader definition?
for example:
Code:
<shader vert="default" frag="default" >
<layouts>
<layout location="0" type="vec4" name="position" />
</layouts>
<uniforms>
<uniform name="color" type="vec4" method="glUniform4fv" update="frame" editorVisible="true"/>
</uniforms>
</shader>
where 'method' property holds the 'update method' name. I know that I could use the 'type' with milion ifs to choose proper one but it's not something i'd like to do.
Another problem is calling this method later. Different methods have different 'footprint' so I can't really declare a single method type like this:
Code:
TUniformMehodFv = procedure(location: GLint; count: GLsizei; transpose: GLboolean; value: PGLfloat); {$IFDEF DGL_WIN}stdcall; {$ELSE}cdecl; {$ENDIF}
this would compile for few methods with same parameter count and type.
So how do you guys do it in your engines? We gonna need shader managment in PGDCE too at some point so maybe we can start talking about it?
Bookmarks