void Uniform1uiv( const GLint Location, const GLsizei Count, const GLuint* const Value) { glUniform1uiv(Location, Count, Value); }
int gl_Uniformui(State& state){ int argc = state.stack->getTop(); switch (argc){ case 5: glUniform4ui((GLint)state.stack->to<int>(1), (GLuint)state.stack->to<int>(2), (GLuint)state.stack->to<int>(3), (GLuint)state.stack->to<int>(4), (GLuint)state.stack->to<int>(5)); break; case 4: glUniform3ui((GLint)state.stack->to<int>(1), (GLuint)state.stack->to<int>(2), (GLuint)state.stack->to<int>(3), (GLuint)state.stack->to<int>(4)); break; case 3: glUniform2ui((GLint)state.stack->to<int>(1), (GLuint)state.stack->to<int>(2), (GLuint)state.stack->to<int>(3)); break; case 2: if (state.stack->is<LUA_TTABLE>(2)){ size_t size = 0; GLuint * data; vector<unsigned int> _data; size = getArray<unsigned int>(state, 2, _data); data = _data.data(); glUniform1uiv((GLint)state.stack->to<int>(1), (GLsizei)size, (GLuint *)data); } else if (state.stack->is<LUA_TNUMBER>(2)){ glUniform1ui((GLint)state.stack->to<int>(1), (GLuint)state.stack->to<int>(2)); } break; default: break; } return 0; }
inline void VL_glUniform1uiv(GLint location, GLsizei count, const GLuint *value) { if (glUniform1uiv) glUniform1uiv(location, count, value); else if (glUniform1uivEXT) glUniform1uivEXT(location, count, value); else VL_UNSUPPORTED_FUNC(); }
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<unsigned int> & value) const { program->use(); glUniform1uiv(location, static_cast<GLint>(value.size()), value.data()); }
/* * 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; } }
void program::uniform(const std::string& name, size_t count, const std::vector<uint32_t>& values) noexcept { glUniform1uiv(resolve_uniform_location(name), count, reinterpret_cast<const uint32_t*>(values.data())); }
void operator()(GLint location, GLsizei count, const GLuint *value_ptr) { glUniform1uiv(location, count, value_ptr); }
void GLState::UniformFuncs::glsUniform1uiv(const GLint location, const GLsizei count, const GLuint* value) { glUniform1uiv(location, count, value); ERROR_CHECK; }
void shader_gl3::uniform(const char* name, const unsigned int* arg1, const size_t& count) const { A2E_CHECK_UNIFORM_EXISTENCE(name); A2E_CHECK_UNIFORM_TYPE(name, GL_UNSIGNED_INT); glUniform1uiv(A2E_SHADER_GET_UNIFORM_POSITION(name), (GLsizei)count, arg1); }
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 Shader::SetUniform(Int32 loc, const UInt32 &x) { glUniform1uiv(loc, 1, &x); }
void Shader::SetUniform(Int32 loc, const UInt32 *x, UInt32 size) { glUniform1uiv(loc, size, x); }