diff --git a/gb.opengl/src/glsl/GL.c b/gb.opengl/src/glsl/GL.c index b4c77f277..821ead2a1 100644 --- a/gb.opengl/src/glsl/GL.c +++ b/gb.opengl/src/glsl/GL.c @@ -54,6 +54,7 @@ GB_DESC Cgl[] = GB_STATIC_METHOD("UseProgram", NULL, GLUSEPROGRAM, "(Program)i"), GB_STATIC_METHOD("ValidateProgram", NULL, GLVALIDATEPROGRAM, "(Program)i"), /* GLuniform.c */ + GB_STATIC_METHOD("GetUniformLocation", NULL, GLGETUNIFORMLOCATION, "(Program)i(Name)s"), GB_STATIC_METHOD("Uniform1f", NULL, GLUNIFORM1F, "(Location)i(V0)f"), GB_STATIC_METHOD("Uniform2f", NULL, GLUNIFORM2F, "(Location)i(V0)f(V1)f"), GB_STATIC_METHOD("Uniform3f", NULL, GLUNIFORM3F, "(Location)i(V0)f(V1)f(V2)f"), @@ -70,6 +71,15 @@ GB_DESC Cgl[] = GB_STATIC_METHOD("Uniform2iv", NULL, GLUNIFORM2IV, "(Location)i(Values)Integer[]"), GB_STATIC_METHOD("Uniform3iv", NULL, GLUNIFORM3IV, "(Location)i(Values)Integer[]"), GB_STATIC_METHOD("Uniform4iv", NULL, GLUNIFORM4IV, "(Location)i(Values)Integer[]"), + GB_STATIC_METHOD("UniformMatrix2fv", NULL, GLUNIFORMMATRIX2FV, "(Location)i(Transpose)b(Values)Float[]"), + GB_STATIC_METHOD("UniformMatrix3fv", NULL, GLUNIFORMMATRIX3FV, "(Location)i(Transpose)b(Values)Float[]"), + GB_STATIC_METHOD("UniformMatrix4fv", NULL, GLUNIFORMMATRIX4FV, "(Location)i(Transpose)b(Values)Float[]"), + GB_STATIC_METHOD("UniformMatrix2x3fv", NULL, GLUNIFORMMATRIX2X3FV, "(Location)i(Transpose)b(Values)Float[]"), + GB_STATIC_METHOD("UniformMatrix3x2fv", NULL, GLUNIFORMMATRIX3X2FV, "(Location)i(Transpose)b(Values)Float[]"), + GB_STATIC_METHOD("UniformMatrix2x4fv", NULL, GLUNIFORMMATRIX2X4FV, "(Location)i(Transpose)b(Values)Float[]"), + GB_STATIC_METHOD("UniformMatrix4x2fv", NULL, GLUNIFORMMATRIX4X2FV, "(Location)i(Transpose)b(Values)Float[]"), + GB_STATIC_METHOD("UniformMatrix3x4fv", NULL, GLUNIFORMMATRIX3X4FV, "(Location)i(Transpose)b(Values)Float[]"), + GB_STATIC_METHOD("UniformMatrix4x3fv", NULL, GLUNIFORMMATRIX4X3FV, "(Location)i(Transpose)b(Values)Float[]"), /* Contants */ GB_CONSTANT("GL_ACTIVE_ATTRIBUTES", "i", GL_ACTIVE_ATTRIBUTES), diff --git a/gb.opengl/src/glsl/GLuniform.c b/gb.opengl/src/glsl/GLuniform.c index 131c4fbf1..563ee3cc4 100644 --- a/gb.opengl/src/glsl/GLuniform.c +++ b/gb.opengl/src/glsl/GLuniform.c @@ -24,6 +24,18 @@ #include "GL.h" +BEGIN_METHOD(GLGETUNIFORMLOCATION, GB_INTEGER program; GB_STRING name) + + if (!LENGTH(name)) + { + GB.ReturnInteger(0); + return; + } + + GB.ReturnInteger(glGetUniformLocation(VARG(program), GB.ToZeroString(ARG(name)))); + +END_METHOD + BEGIN_METHOD(GLUNIFORM1F, GB_INTEGER location; GB_FLOAT v0) glUniform1f(VARG(location), VARG(v0)); @@ -261,3 +273,246 @@ BEGIN_METHOD(GLUNIFORM4IV, GB_INTEGER location; GB_OBJECT array) glUniform4iv(VARG(location), count, values); END_METHOD + +BEGIN_METHOD(GLUNIFORMMATRIX2FV, GB_INTEGER location; GB_BOOLEAN transpose; GB_OBJECT array) + + GB_ARRAY fArray = VARG(array); + int count = GB.Array.Count(fArray); + int fill = count%4 ? (4-(count%4)) : 0; + + if (!count) + return; + + GLfloat values[count+fill]; + int i; + + for (i=0; i