GLsizei *length, GLcharARB *sourceOut);
void (*GetUniformfv)(GLcontext *ctx, GLuint program, GLint location,
GLfloat *params);
+ void (*GetUniformiv)(GLcontext *ctx, GLuint program, GLint location,
+ GLint *params);
GLint (*GetUniformLocation)(GLcontext *ctx, GLuint program,
const GLcharARB *name);
GLboolean (*IsProgram)(GLcontext *ctx, GLuint name);
void GLAPIENTRY
_mesa_DeleteProgram(GLuint name)
{
+ printf("%s name=%u\n", __FUNCTION__, name);
if (name) {
GET_CURRENT_CONTEXT(ctx);
ctx->Driver.DeleteProgram2(ctx, name);
_mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint * params)
{
GET_CURRENT_CONTEXT(ctx);
- GLfloat fparams[16]; /* XXX is 16 enough? */
- GLuint i;
- ctx->Driver.GetUniformfv(ctx, program, location, fparams);
- for (i = 0; i < 16; i++)
- params[i] = (GLint) fparams[i]; /* XXX correct? */
+ ctx->Driver.GetUniformiv(ctx, program, location, params);
}
}
+#define MAX_UNIFORM_ELEMENTS 16
+
/**
- * Called via ctx->Driver.GetUniformfv().
+ * Helper for GetUniformfv(), GetUniformiv()
+ * Returns number of elements written to 'params' output.
*/
-static void
-_mesa_get_uniformfv(GLcontext *ctx, GLuint program, GLint location,
- GLfloat *params)
+static GLuint
+get_uniformfv(GLcontext *ctx, GLuint program, GLint location,
+ GLfloat *params)
{
struct gl_shader_program *shProg
= _mesa_lookup_shader_program(ctx, program);
ASSERT(prog);
if (prog) {
+ /* See uniformiv() below */
+ assert(prog->Parameters->Parameters[progPos].Size <= MAX_UNIFORM_ELEMENTS);
+
for (i = 0; i < prog->Parameters->Parameters[progPos].Size; i++) {
params[i] = prog->Parameters->ParameterValues[progPos][i];
}
+ return prog->Parameters->Parameters[progPos].Size;
}
}
else {
else {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(program)");
}
+ return 0;
+}
+
+
+/**
+ * Called via ctx->Driver.GetUniformfv().
+ */
+static void
+_mesa_get_uniformfv(GLcontext *ctx, GLuint program, GLint location,
+ GLfloat *params)
+{
+ (void) get_uniformfv(ctx, program, location, params);
+}
+
+
+/**
+ * Called via ctx->Driver.GetUniformiv().
+ */
+static void
+_mesa_get_uniformiv(GLcontext *ctx, GLuint program, GLint location,
+ GLint *params)
+{
+ GLfloat fparams[MAX_UNIFORM_ELEMENTS];
+ GLuint n = get_uniformfv(ctx, program, location, fparams);
+ GLuint i;
+ assert(n <= MAX_UNIFORM_ELEMENTS);
+ for (i = 0; i < n; i++) {
+ params[i] = (GLint) fparams[i];
+ }
}
driver->GetShaderInfoLog = _mesa_get_shader_info_log;
driver->GetShaderSource = _mesa_get_shader_source;
driver->GetUniformfv = _mesa_get_uniformfv;
+ driver->GetUniformiv = _mesa_get_uniformiv;
driver->GetUniformLocation = _mesa_get_uniform_location;
driver->IsProgram = _mesa_is_program;
driver->IsShader = _mesa_is_shader;