Ejemplo n.º 1
0
void uniform_set(Uniform* uniform, float f) {
	check_uniform(uniform);
	glUniform1f(uniform->location, f);
}
Ejemplo n.º 2
0
void uniform_set(Uniform* uniform, int i) {
	check_uniform(uniform);
	glUniform1i(uniform->location, i);
}
Ejemplo n.º 3
0
void uniform_set(Uniform* uniform, const vec2 &v) {
	check_uniform(uniform);
	glUniform2f(uniform->location, v.x, v.y);
}
Ejemplo n.º 4
0
void uniform_set(Uniform* uniform, const vec3 &v) {
	check_uniform(uniform);
	glUniform3f(uniform->location, v.x, v.y, v.z);
}
Ejemplo n.º 5
0
void uniform_set(Uniform* uniform, const vec4& v) {
	check_uniform(uniform);
	glUniform4f(uniform->location, v.x, v.y, v.z, v.w);
}
Ejemplo n.º 6
0
void uniform_set(Uniform* uniform, const mat3 &m) {
	check_uniform(uniform);
	glUniformMatrix3fv(uniform->location, 1, 0, value_ptr(m));
}
Ejemplo n.º 7
0
static GLboolean
test_uniform_funcs(void)
{
   static const char *signedFragText =
      "uniform int value1; \n"
      "uniform ivec2 value2; \n"
      "uniform ivec3 value3; \n"
      "uniform ivec4 value4; \n"
      "void main() \n"
      "{ \n"
      "   vec4 t = vec4(value4); \n"
      "   t += vec4(value3, 0.0); \n"
      "   t += vec4(value2, 0.0, 0.0); \n"
      "   t += vec4(value1, 0.0, 0.0, 0.0); \n"
      " gl_FragColor = 0.01 * t; \n"
      "} \n";

   static const char *unsignedFragText =
      "#extension GL_EXT_gpu_shader4: enable \n"
      "uniform unsigned int value1; \n"
      "uniform uvec2 value2; \n"
      "uniform uvec3 value3; \n"
      "uniform uvec4 value4; \n"
      "void main() \n"
      "{ \n"
      "   vec4 t = vec4(value4); \n"
      "   t += vec4(value3, 0.0); \n"
      "   t += vec4(value2, 0.0, 0.0); \n"
      "   t += vec4(value1, 0.0, 0.0, 0.0); \n"
      " gl_FragColor = 0.01 * t; \n"
      "} \n";


   GLint vals[4], loc1, loc2, loc3, loc4;
   GLuint shader;

   /*
    * Signed integer tests.
    */
   shader = piglit_compile_shader_text(GL_FRAGMENT_SHADER, signedFragText);
   assert(shader);

   Program = piglit_link_simple_program(0, shader);
   assert(Program);

   glUseProgram(Program);
   check_error(__FILE__, __LINE__);

   loc1 = glGetUniformLocation(Program, "value1");
   assert(loc1 >= 0);

   loc2 = glGetUniformLocation(Program, "value2");
   assert(loc2 >= 0);

   loc3 = glGetUniformLocation(Program, "value3");
   assert(loc3 >= 0);

   loc4 = glGetUniformLocation(Program, "value4");
   assert(loc4 >= 0);

   check_error(__FILE__, __LINE__);

   gen_values(vals, 1, SIGNED);
   glUniform1iARB(loc1, vals[0]);
   if (!check_uniform(vals, 1, SIGNED, loc1, "glUniform1iARB"))
      return GL_FALSE;

   gen_values(vals, 2, SIGNED);
   glUniform2iARB(loc2, vals[0], vals[1]);
   if (!check_uniform(vals, 2, SIGNED, loc2, "glUniform2iARB"))
      return GL_FALSE;

   gen_values(vals, 3, SIGNED);
   glUniform3iARB(loc3, vals[0], vals[1], vals[2]);
   if (!check_uniform(vals, 3, SIGNED, loc3, "glUniform3iARB"))
      return GL_FALSE;

   gen_values(vals, 4, SIGNED);
   glUniform4iARB(loc4, vals[0], vals[1], vals[2], vals[3]);
   if (!check_uniform(vals, 4, SIGNED, loc4, "glUniform4iARB"))
      return GL_FALSE;


   /*
    * Unsigned integer tests.
    */
   shader = piglit_compile_shader_text(GL_FRAGMENT_SHADER, unsignedFragText);
   assert(shader);

   Program = piglit_link_simple_program(0, shader);
   assert(Program);

   glUseProgram(Program);
   check_error(__FILE__, __LINE__);

   loc1 = glGetUniformLocation(Program, "value1");
   assert(loc1 >= 0);

   loc2 = glGetUniformLocation(Program, "value2");
   assert(loc2 >= 0);

   loc3 = glGetUniformLocation(Program, "value3");
   assert(loc3 >= 0);

   loc4 = glGetUniformLocation(Program, "value4");
   assert(loc4 >= 0);

   check_error(__FILE__, __LINE__);

   gen_values(vals, 1, UNSIGNED);
   glUniform1uiEXT(loc1, vals[0]);
   if (!check_uniform(vals, 1, UNSIGNED, loc1, "glUniform1uiEXT"))
      return GL_FALSE;

   gen_values(vals, 2, UNSIGNED);
   glUniform2uiEXT(loc2, vals[0], vals[1]);
   if (!check_uniform(vals, 2, UNSIGNED, loc2, "glUniform2uiEXT"))
      return GL_FALSE;

   gen_values(vals, 3, UNSIGNED);
   glUniform3uiEXT(loc3, vals[0], vals[1], vals[2]);
   if (!check_uniform(vals, 3, UNSIGNED, loc3, "glUniform3uiEXT"))
      return GL_FALSE;

   gen_values(vals, 4, UNSIGNED);
   glUniform4uiEXT(loc4, vals[0], vals[1], vals[2], vals[3]);
   if (!check_uniform(vals, 4, UNSIGNED, loc4, "glUniform4uiEXT"))
      return GL_FALSE;

   return GL_TRUE;
}