Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// send Uniform
- void sendUniform(T)(int position, T t) {
- assert(this.isAttached, "cannot send uniform, shader not attached");
- static if(isFloatingPoint!T) {
- glUniform1f(position, t);
- }
- else static if(isIntegral!T) {
- glUniform1i(position, t);
- }
- else static if(isVector!T && isFloatingPoint!(T.vt)) {
- mixin("glUniform"~to!string(T.dimension)~"fv(position, 1, t.value_ptr);");
- }
- else static if(isVector!T && isIntegral!(T.vt)) {
- mixin("glUniform"~to!string(T.dimension)~"iv(position, 1, t.value_ptr);");
- }
- else static if(isMatrix!T && isNumeric!(T.mt) && T.cols >= 2 && T.cols <= 4 && T.rows >= 2 && T.rows <= 4) {
- static if(isFloatingPoint!(T.mt)) {
- static if(T.cols != T.rows)
- mixin("glUniformMatrix"~to!string(T.cols)~"x"~to!string(T.rows)~"fv(position, 1, false, t.value_ptr);");
- else
- mixin("glUniformMatrix"~to!string(T.cols)~"fv(position, 1, false, t.value_ptr);");
- }
- else static if(isIntegral!(T.mt)) {
- static if(T.cols != T.rows)
- mixin("glUniformMatrix"~to!string(T.cols)~"x"~to!string(T.rows)~"fi(position, 1, false, t.value_ptr);");
- else
- mixin("glUniformMatrix"~to!string(T.cols)~"fi(position, 1, false, t.value_ptr);");
- }
- }
- else
- {
- static assert(false, "Type "~T.stringof~" can not be sent via sendUniform");
- }
- glCheck();
- }
Advertisement
Add Comment
Please, Sign In to add comment