void Uniform4uiv( const GLint Location, const GLsizei Count, const GLuint* const Value) { glUniform4uiv(Location, Count, Value); }
inline void VL_glUniform4uiv(GLint location, GLsizei count, const GLuint *value) { if (glUniform4uiv) glUniform4uiv(location, count, value); else if (glUniform4uivEXT) glUniform4uivEXT(location, count, value); else VL_UNSUPPORTED_FUNC(); }
void Shader::setUniform<glm::uvec4>(const std::string& name, const glm::uvec4& data) { int prev_bound_program; glGetIntegerv(GL_CURRENT_PROGRAM, &prev_bound_program); if(name_to_location.count(name) == 0) { throw Exceptions::InvalidUniformNameException(name); } if(prev_bound_program != program_object) useProgram(); glUniform4uiv(name_to_location[name], 1, glm::value_ptr(data)); if(prev_bound_program != program_object) glUseProgram(prev_bound_program); }
int teatime_run_program(teatime_t *obj, const uint32_t ikey[4], uint32_t rounds) { if (obj && obj->program > 0) { int rc = 0; do { glUseProgram(obj->program); TEATIME_BREAKONERROR(glUseProgram, rc); glActiveTexture(GL_TEXTURE0); TEATIME_BREAKONERROR(glActiveTexture, rc); glBindTexture(GL_TEXTURE_2D, obj->itexid); TEATIME_BREAKONERROR(glBindTexture, rc); glUniform1i(obj->locn_input, 0); TEATIME_BREAKONERROR(glUniform1i, rc); glActiveTexture(GL_TEXTURE1); TEATIME_BREAKONERROR(glActiveTexture, rc); glBindTexture(GL_TEXTURE_2D, obj->otexid); TEATIME_BREAKONERROR(glBindTexture, rc); glUniform1i(obj->locn_output, 1); TEATIME_BREAKONERROR(glUniform1i, rc); glUniform4uiv(obj->locn_key, 1, ikey); TEATIME_BREAKONERROR(glUniform1uiv, rc); glUniform1ui(obj->locn_rounds, rounds); TEATIME_BREAKONERROR(glUniform1ui, rc); glFinish(); glPolygonMode(GL_FRONT, GL_FILL); /* render */ glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex2i(0, 0); //glTexCoord2i(obj->tex_size, 0); glTexCoord2i(1, 0); glVertex2i(obj->tex_size, 0); //glTexCoord2i(obj->tex_size, obj->tex_size); glTexCoord2i(1, 1); glVertex2i(obj->tex_size, obj->tex_size); glTexCoord2i(0, 1); //glTexCoord2i(0, obj->tex_size); glVertex2i(0, obj->tex_size); glEnd(); glFinish(); TEATIME_BREAKONERROR_FB(Rendering, rc); TEATIME_BREAKONERROR(Rendering, rc); rc = 0; } while (0); return rc; } return -EINVAL; }
bool Shader::setShaderUniform(const std::string &name, GLsizei uniSize, GLsizei len, const GLuint *value) { GLint loc; if(!this->getUniformLoc(name, loc)) return false; switch(uniSize) { case 1: glUniform1uiv(loc, len, value); break; case 2: glUniform2uiv(loc, len, value);break; case 3: glUniform3uiv(loc, len, value);break; case 4: glUniform4uiv(loc, len, value);break; default: return false; } return true; }
void Shader::BindUInt(const std::string &name, int size, int count, const unsigned int *value) { int id = GetUniformLocation(name); if (id == -1) return; switch (size) { case 1: glUniform1uiv(id, count, value); break; case 2: glUniform2uiv(id, count, value); break; case 3: glUniform3uiv(id, count, value); break; case 4: glUniform4uiv(id, count, value); break; default: FURYW << "Incorrect unfirom size!"; break; } }
void UniformImplementation_Legacy::set(const Program * program, const GLint location, const std::vector<glm::uvec4> & value) const { program->use(); glUniform4uiv(location, static_cast<GLint>(value.size()), reinterpret_cast<const unsigned*>(value.data())); }
enum piglit_result test_format(int format_index) { const struct format *format = &formats[format_index]; GLuint tex, bo; bool is_rg = (format->channels == R || format->channels == RG); bool is_arb = (format->channels == I || format->channels == L || format->channels == LA || format->channels == A); bool is_rgb32 = (format->channels == RGB); bool pass = true; int data_components, num_samples; int i; bool returns_float = (format->norm || format->type == GL_FLOAT || format->type == GL_HALF_FLOAT); bool returns_int = (!format->norm && (format->type == GL_BYTE || format->type == GL_SHORT || format->type == GL_INT)); bool returns_uint = (!format->norm && (format->type == GL_UNSIGNED_BYTE || format->type == GL_UNSIGNED_SHORT || format->type == GL_UNSIGNED_INT)); struct program *prog; if (returns_float) prog = &prog_f; else if (returns_int) prog = &prog_i; else prog = &prog_u; glUseProgram(prog->prog); if (test_arb != is_arb) return PIGLIT_SKIP; if (is_rgb32 && !test_rgb32) return PIGLIT_SKIP; /* These didn't exist in the extension before being promoted to * GL 3.1. */ if (is_rg && piglit_get_gl_version() < 31) return PIGLIT_SKIP; printf("Testing %s\n", piglit_get_gl_enum_name(format->format)); glGenBuffers(1, &bo); glBindBuffer(GL_TEXTURE_BUFFER, bo); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_BUFFER, tex); glTexBuffer(GL_TEXTURE_BUFFER, format->format, bo); switch (format->type) { case GL_BYTE: case GL_UNSIGNED_BYTE: glBufferData(GL_TEXTURE_BUFFER, sizeof(uint8_data), uint8_data, GL_STATIC_READ); data_components = ARRAY_SIZE(uint8_data); break; case GL_SHORT: case GL_UNSIGNED_SHORT: glBufferData(GL_TEXTURE_BUFFER, sizeof(uint16_data), uint16_data, GL_STATIC_READ); data_components = ARRAY_SIZE(uint16_data); break; case GL_INT: case GL_UNSIGNED_INT: glBufferData(GL_TEXTURE_BUFFER, sizeof(uint32_data), uint32_data, GL_STATIC_READ); data_components = ARRAY_SIZE(uint32_data); break; case GL_FLOAT: glBufferData(GL_TEXTURE_BUFFER, sizeof(float_data), float_data, GL_STATIC_READ); data_components = ARRAY_SIZE(float_data); break; case GL_HALF_FLOAT: { unsigned short hf_data[ARRAY_SIZE(float_data)]; for (i = 0; i < ARRAY_SIZE(float_data); i++) { hf_data[i] = piglit_half_from_float(float_data[i]); } glBufferData(GL_TEXTURE_BUFFER, sizeof(hf_data), hf_data, GL_STATIC_READ); data_components = ARRAY_SIZE(float_data); break; } default: printf("line %d, bad type: %s\n", __LINE__, piglit_get_gl_enum_name(format->type)); return PIGLIT_SKIP; } num_samples = data_components / format->components; for (i = 0; i < num_samples; i++) { float x1 = 5 + i * 10; float x2 = 10 + i * 10; float y1 = piglit_height - (5 + y_index * 10); float y2 = piglit_height - (10 + y_index * 10); GLfloat verts[8] = { transform_x(x1), transform_y(y1), transform_x(x2), transform_y(y1), transform_x(x2), transform_y(y2), transform_x(x1), transform_y(y2), }; float expected_f[4]; uint32_t expected_i[4]; const float green[4] = {0, 1, 0, 0}; if (returns_float) { if (!get_expected_f(format, i, expected_f)) return PIGLIT_SKIP; glUniform4fv(prog->expected_location, 1, expected_f); } else { if (!get_expected_i(format, i, expected_i)) return PIGLIT_SKIP; if (returns_uint) { glUniform4uiv(prog->expected_location, 1, expected_i); } else { glUniform4iv(prog->expected_location, 1, (int *)expected_i); } } glUniform1i(prog->pos_location, i); glBufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, GL_STREAM_DRAW); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); if (pass && !piglit_probe_rect_rgba(x1, y2, x2 - x1, y1 - y2, green)) { if (returns_int) { printf(" Texel: %d %d %d %d\n", expected_i[0], expected_i[1], expected_i[2], expected_i[3]); } else if (returns_uint) { printf(" Texel: %u %u %u %u\n", expected_i[0], expected_i[1], expected_i[2], expected_i[3]); } else { printf(" Texel: %f %f %f %f\n", expected_f[0], expected_f[1], expected_f[2], expected_f[3]); } pass = false; } } glDeleteBuffers(1, &bo); glDeleteTextures(1, &tex); glUseProgram(0); y_index++; piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, "%s", piglit_get_gl_enum_name(format->format)); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
/* * Sets the given uniform variable to the given value. */ void sstSetUniformData( sstProgram *program, char *name, GLvoid *data ) { uniform *un; int i; /* Find our data */ for( i = 0; i < program->un_count; i++ ) { un = &program->uniforms[i]; if( strcmp(un->name, name) == 0 ) { break; } } /* Lookup failure */ if( i >= program->un_count ) { printf("WARN: Uniform variable [%s] does not exist!\n", name); return; } switch( un->first ) { case 1: switch( un->type ) { case GL_FLOAT: glUniform1fv(un->location, un->count, (const GLfloat*)data); return; case GL_INT: glUniform1iv(un->location, un->count, (const GLint*)data); return; case GL_UNSIGNED_INT: glUniform1uiv(un->location, un->count, (const GLuint*)data); return; default: printf("WARN: Invalid type for uniform value [%s]!\n", name); return; } case 2: switch( un->second ) { case 0: case 1: switch( un->type ) { case GL_FLOAT: glUniform2fv(un->location, un->count, (const GLfloat*)data); return; case GL_INT: glUniform2iv(un->location, un->count, (const GLint*)data); return; case GL_UNSIGNED_INT: glUniform2uiv(un->location, un->count, (const GLuint*)data); return; default: printf("WARN: Invalid type for uniform value [%s]!\n", name); return; } case 2: glUniformMatrix2fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; case 3: glUniformMatrix2x3fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; case 4: glUniformMatrix2x4fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; default: printf("WARN: Invalid second matrix component: %d!\n", un->second); return; } case 3: switch( un->second ) { case 0: case 1: switch( un->type ) { case GL_FLOAT: glUniform3fv(un->location, un->count, (const GLfloat*)data); return; case GL_INT: glUniform3iv(un->location, un->count, (const GLint*)data); return; case GL_UNSIGNED_INT: glUniform3uiv(un->location, un->count, (const GLuint*)data); return; default: printf("WARN: Invalid type for uniform value [%s]!\n", name); return; } case 2: glUniformMatrix3x2fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; case 3: glUniformMatrix3fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; case 4: glUniformMatrix3x4fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; default: printf("WARN: Invalid second matrix component: %d!\n", un->second); return; } case 4: switch( un->second ) { case 0: case 1: switch( un->type ) { case GL_FLOAT: glUniform4fv(un->location, un->count, (const GLfloat*)data); return; case GL_INT: glUniform4iv(un->location, un->count, (const GLint*)data); return; case GL_UNSIGNED_INT: glUniform4uiv(un->location, un->count, (const GLuint*)data); return; default: printf("WARN: Invalid type for uniform value [%s]!\n", name); return; } case 2: glUniformMatrix4x2fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; case 3: glUniformMatrix4x3fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; case 4: glUniformMatrix4fv(un->location, un->count, un->transpose, (const GLfloat*)data); return; default: printf("WARN: Invalid second matrix component: %d!\n", un->second); return; } default: printf("WARN: Invalid first matrix component: %d!\n", un->first); return; } }
/* * Test glVertexAttribIArray(type, size, normalized) */ static bool test_array(GLenum type, GLuint size) { static const GLfloat verts[4][2] = { { -1.0, -1.0 }, { 1.0, -1.0 }, { 1.0, 1.0 }, { -1.0, 1.0 } }; static const GLfloat green[4] = { 0.0, 1.0, 0.0, 0.0 }; GLubyte attr_buffer[4 * 4 * sizeof(GLuint)]; int typeSize; const void *data; GLint expected[4]; int i, p; switch (type) { case GL_BYTE: typeSize = sizeof(GLbyte); data = byte4_data; for (i = 0; i < 4; i++) expected[i] = byte4_data[i]; break; case GL_UNSIGNED_BYTE: typeSize = sizeof(GLubyte); data = ubyte4_data; for (i = 0; i < 4; i++) expected[i] = ubyte4_data[i]; break; case GL_SHORT: typeSize = sizeof(GLshort); data = short4_data; for (i = 0; i < 4; i++) expected[i] = short4_data[i]; break; case GL_UNSIGNED_SHORT: typeSize = sizeof(GLushort); data = ushort4_data; for (i = 0; i < 4; i++) expected[i] = ushort4_data[i]; break; case GL_INT: typeSize = sizeof(GLint); data = int4_data; for (i = 0; i < 4; i++) expected[i] = int4_data[i]; break; case GL_UNSIGNED_INT: typeSize = sizeof(GLuint); data = uint4_data; for (i = 0; i < 4; i++) expected[i] = uint4_data[i]; break; default: assert(0); typeSize = sizeof(GLint); } /* set unused components to defaults */ switch (size) { case 1: expected[1] = 0; case 2: expected[2] = 0; case 3: expected[3] = 1; } /* Setup the attribute buffer by making four copies of the * test's array data (for the four vertices). */ { int i, sz = typeSize * size; for (i = 0; i < 4; i++) { memcpy(attr_buffer + i * sz, data, sz); } } /* We set up both the signed and unsigned int attribute arrays to * point to the same vertex data. */ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, verts); glEnableVertexAttribArray(0); glVertexAttribIPointer(Attr_i, size, type, 0, attr_buffer); glEnableVertexAttribArray(Attr_i); glVertexAttribIPointer(Attr_u, size, type, 0, attr_buffer); glEnableVertexAttribArray(Attr_u); glViewport(0, 0, piglit_width, piglit_height); glClearColor(1,0,0,0); glClear(GL_COLOR_BUFFER_BIT); /* The same value is expected for the signed and unsigned attributes */ glUniform4iv(ExpectedUniform_i, 1, expected); glUniform4uiv(ExpectedUniform_u, 1, (const GLuint *) expected); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableVertexAttribArray(0); glDisableVertexAttribArray(Attr_i); glDisableVertexAttribArray(Attr_u); p = piglit_probe_pixel_rgba(piglit_width / 2, piglit_height / 2, green); if (!p) { printf("Test %s[%d] failed\n", piglit_get_gl_enum_name(type), size); fflush(stdout); } piglit_present_results(); return p; }
bool Shader :: setUniformVec<glm::uvec4>(const char *name, const glm::uvec4 &value) { int loc = glGetUniformLocation(program, name); if(loc < 0) return false; glUniform4uiv(loc, 1, glm::value_ptr(value)); return true; }
void Shader::SetUniform(Int32 loc, const glm::uvec4 &xyzw) { glUniform4uiv(loc, 1, glm::value_ptr(xyzw)); }
void kore::BindUniform::doExecute(void) const { if(!_componentUniform) { Log::getInstance()->write("[ERROR] Uniform binding undefined"); return; } GLerror::gl_ErrorCheckStart(); _renderManager-> useShaderProgram(_shaderUniform->shader->getProgramLocation()); switch (_componentUniform->type) { case GL_FLOAT: glUniform1fv(_shaderUniform->location, _componentUniform->size, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_VEC2: glUniform2fv(_shaderUniform->location, _componentUniform->size, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_VEC3: glUniform3fv(_shaderUniform->location, _componentUniform->size, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_VEC4: glUniform4fv(_shaderUniform->location, _componentUniform->size, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_DOUBLE: glUniform1d(_shaderUniform->location, *static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_VEC2: glUniform2dv(_shaderUniform->location, _componentUniform->size, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_VEC3: glUniform3dv(_shaderUniform->location, _componentUniform->size, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_VEC4: glUniform4dv(_shaderUniform->location, _componentUniform->size, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_BOOL: case GL_INT: glUniform1i(_shaderUniform->location, *static_cast<GLint*>(_componentUniform->data)); break; case GL_BOOL_VEC2: case GL_INT_VEC2: glUniform2iv(_shaderUniform->location, _componentUniform->size, static_cast<GLint*>(_componentUniform->data)); break; case GL_BOOL_VEC3: case GL_INT_VEC3: glUniform3iv(_shaderUniform->location, _componentUniform->size, static_cast<GLint*>(_componentUniform->data)); break; case GL_BOOL_VEC4: case GL_INT_VEC4: glUniform4iv(_shaderUniform->location, _componentUniform->size, static_cast<GLint*>(_componentUniform->data)); break; case GL_UNSIGNED_INT: glUniform1ui(_shaderUniform->location, *static_cast<GLuint*>(_componentUniform->data)); break; case GL_UNSIGNED_INT_VEC2: glUniform2uiv(_shaderUniform->location, _componentUniform->size, static_cast<GLuint*>(_componentUniform->data)); break; case GL_UNSIGNED_INT_VEC3: glUniform3uiv(_shaderUniform->location, _componentUniform->size, static_cast<GLuint*>(_componentUniform->data)); break; case GL_UNSIGNED_INT_VEC4: glUniform4uiv(_shaderUniform->location, _componentUniform->size, static_cast<GLuint*>(_componentUniform->data)); break; case GL_FLOAT_MAT2: glUniformMatrix2fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT3: glUniformMatrix3fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT4: glUniformMatrix4fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT2x3: glUniformMatrix2x3fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT2x4: glUniformMatrix2x4fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT3x2: glUniformMatrix3x2fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT3x4: glUniformMatrix3x4fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT4x2: glUniformMatrix4x2fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT4x3: glUniformMatrix3x4fv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_DOUBLE_MAT2: glUniformMatrix2dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT3: glUniformMatrix3dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT4: glUniformMatrix4dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT2x3: glUniformMatrix2x3dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT2x4: glUniformMatrix2x4dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT3x2: glUniformMatrix3x2dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT3x4: glUniformMatrix3x4dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT4x2: glUniformMatrix4x2dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT4x3: glUniformMatrix4x3dv(_shaderUniform->location, _componentUniform->size, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; // Note(dlazarek): Currently, we handle texture-bindings outside of // Uniform-bindigs for sorting and performance-reasons. case GL_SAMPLER_1D: case GL_SAMPLER_2D: case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_1D_SHADOW: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_1D_ARRAY: case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_1D_ARRAY_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: case GL_SAMPLER_2D_MULTISAMPLE: case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_BUFFER: case GL_SAMPLER_2D_RECT: case GL_SAMPLER_2D_RECT_SHADOW: case GL_INT_SAMPLER_1D: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_1D_ARRAY: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_INT_SAMPLER_BUFFER: case GL_INT_SAMPLER_2D_RECT: case GL_UNSIGNED_INT_SAMPLER_1D: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_UNSIGNED_INT_SAMPLER_BUFFER: case GL_UNSIGNED_INT_SAMPLER_2D_RECT: //glActiveTexture(GL_TEXTURE0 + _componentUniform->texUnit); //glProgramUniform1i(_shaderID, _shaderUniform->location, _componentUniform->texUnit); kore::Log::getInstance()->write("[ERROR] sampler type was adressed" "as uniform"); break; /* break; case GL_IMAGE_1D: break; case GL_IMAGE_2D: break; case GL_IMAGE_3D: break; case GL_IMAGE_2D_RECT: break; case GL_IMAGE_CUBE: break; case GL_IMAGE_BUFFER: break; case GL_IMAGE_1D_ARRAY: break; case GL_IMAGE_2D_ARRAY: break; case GL_IMAGE_2D_MULTISAMPLE: break; case GL_IMAGE_2D_MULTISAMPLE_ARRAY: break; case GL_INT_IMAGE_1D: break; case GL_INT_IMAGE_2D: break; case GL_INT_IMAGE_3D: break; case GL_INT_IMAGE_2D_RECT: break; case GL_INT_IMAGE_CUBE: break; case GL_INT_IMAGE_BUFFER: break; case GL_INT_IMAGE_1D_ARRAY: break; case GL_INT_IMAGE_2D_ARRAY: break; case GL_INT_IMAGE_2D_MULTISAMPLE: break; case GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY: break; case GL_UNSIGNED_INT_IMAGE_1D: break; case GL_UNSIGNED_INT_IMAGE_2D: break; case GL_UNSIGNED_INT_IMAGE_3D: break; case GL_UNSIGNED_INT_IMAGE_2D_RECT: break; case GL_UNSIGNED_INT_IMAGE_CUBE: break; case GL_UNSIGNED_INT_IMAGE_BUFFER: break; case GL_UNSIGNED_INT_IMAGE_1D_ARRAY: break; case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: break; case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE: break; case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY: break; */ default: kore::Log::getInstance()->write("[ERROR] Unknown uniform binding\n"); break; } GLerror::gl_ErrorCheckFinish("BindUniformOperation: " + _shaderUniform->name); }
void GLState::UniformFuncs::glsUniform4uiv(const GLint location, const GLsizei count, const GLuint* value) { glUniform4uiv(location, count, value); ERROR_CHECK; }
void shader_gl3::uniform(const char* name, const uint4* arg1, const size_t& count) const { A2E_CHECK_UNIFORM_EXISTENCE(name); A2E_CHECK_UNIFORM_TYPE(name, GL_UNSIGNED_INT_VEC4); glUniform4uiv(A2E_SHADER_GET_UNIFORM_POSITION(name), (GLsizei)count, (GLuint*)arg1); }
void Z3DShaderProgram::setUniformValueArray(GLint loc, const glm::uvec4 *values, int count) { if (loc != -1) { glUniform4uiv(loc, count, &(values[0][0])); } }
void Z3DShaderProgram::setUniformValue(GLint loc, const glm::uvec4 &value) { if (loc != -1) { glUniform4uiv(loc, 1, &value[0]); } }
void shader_set_parameter(shader_t *s, char *nm, void *value, size_t sz) { char buf[64]; GLint current_program; glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program); glUseProgram(s->program); int location = glGetUniformLocation(s->program, nm); GLuint index; //Why is there a distinction between location/index? glGetUniformIndices(s->program, 1, (const GLchar * const*)&nm, &index); if(location < 0 || location == GL_INVALID_INDEX) // ERROR uniform does not exist { shader_set_block(s, nm, value, sz); // try with uniform block goto CLEANUP; } GLenum type; glGetActiveUniform(s->program, index, 0, NULL, NULL, &type, NULL); //void (*uniform_func)(GLint loc, GLsizei count, const GLuint *val) = 0; switch(type) { case GL_FLOAT_VEC4: glUniform4fv(location, sz/(sizeof(float) * 4), value); break; case GL_FLOAT_VEC3: glUniform3fv(location, sz/(sizeof(float) * 3), value); break; case GL_FLOAT_VEC2: glUniform2fv(location, sz/(sizeof(float) * 2), value); break; case GL_FLOAT: glUniform1fv(location, sz/sizeof(float), value); break; case GL_INT_VEC4: glUniform4iv(location, (sz/sizeof(int) * 4), value); break; case GL_INT_VEC3: glUniform3iv(location, (sz/sizeof(int) * 3), value); break; case GL_INT_VEC2: glUniform2iv(location, (sz/sizeof(int) * 2), value); break; case GL_INT: case GL_BOOL: case GL_SAMPLER_2D: case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: glUniform1iv(location, sz/sizeof(int), value); break; case GL_UNSIGNED_INT_VEC4: glUniform4uiv(location, (sz/sizeof(unsigned int) * 4), value); break; case GL_UNSIGNED_INT_VEC3: glUniform3uiv(location, (sz/sizeof(unsigned int) * 3), value); break; case GL_UNSIGNED_INT_VEC2: glUniform2uiv(location, (sz/sizeof(unsigned int) * 2), value); break; case GL_UNSIGNED_INT: glUniform1uiv(location, sz/sizeof(unsigned int), value); break; case GL_FLOAT_MAT4: glUniformMatrix4fv(location, sz/(sizeof(float) * 16), true, value); break; case GL_FLOAT_MAT3: glUniformMatrix3fv(location, sz/(sizeof(float) * 9), true, value); break; default: assert(0 && "invalid parameter type"); } CLEANUP: glUseProgram(current_program); }
void UniformImplementation_Legacy::set(const Program * program, const GLint location, const glm::uvec4 & value) const { program->use(); glUniform4uiv(location, 1, glm::value_ptr(value)); }
void operator()(GLint location, GLsizei count, const GLuint *value_ptr) { glUniform4uiv(location, count, value_ptr); }
bool Shader :: setUniformVec<glm::uvec4>(int loc, const glm::uvec4 &value) { if(loc < 0) return false; glUniform4uiv(loc, 1, glm::value_ptr(value)); return true; }
void piglit_init(int argc, char **argv) { GLuint fbo; static const char *vs_source = "#version 130\n" "void main()\n" "{\n" " gl_Position = gl_Vertex;\n" "}\n"; static const char *fs_source = "#version 130\n" "uniform uvec4 color;\n" "out uvec4 result;\n" "void main()\n" "{\n" " result = color;\n" "}\n"; GLuint fs, vs, prog; int f, i; enum piglit_result result = PIGLIT_SKIP; const struct format_info *test_formats = formats; int num_test_formats = ARRAY_SIZE(formats); for (i = 1; i < argc; i++) { if (strcmp(argv[i], "GL_ARB_texture_rg") == 0) { piglit_require_extension(argv[i]); test_formats = rg_formats; num_test_formats = ARRAY_SIZE(rg_formats); } else if (strcmp(argv[i], "GL_ARB_texture_rgb10_a2ui") == 0) { piglit_require_extension(argv[i]); test_formats = rgb10_formats; num_test_formats = ARRAY_SIZE(rgb10_formats); } else { usage(); exit(1); } } piglit_require_extension("GL_EXT_texture_integer"); piglit_require_GLSL_version(130); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source); prog = piglit_link_simple_program(vs, fs); if (!prog || !fs || !vs) piglit_report_result(PIGLIT_FAIL); glUseProgram(prog); color_loc = glGetUniformLocation(prog, "color"); glUniform4uiv(color_loc, 1, color); glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); /* Turn on all the knobs (except multisample alpha, which * we'll leave to an EXT_framebuffer_multisample test) that * are supposed to be ignored. */ glEnable(GL_BLEND); glBlendFunc(GL_ZERO, GL_ZERO); glEnable(GL_DITHER); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_NEVER, 1); for (f = 0; f < num_test_formats; f++) piglit_merge_result(&result, test_format(&test_formats[f])); glBindFramebuffer(GL_FRAMEBUFFER, 0); glDeleteFramebuffers(1, &fbo); piglit_report_result(result); }
void Shader::SetUniform(Int32 loc, const glm::uvec4 *xyzw, UInt32 size) { glUniform4uiv(loc, size, (GLuint*)xyzw); }