mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 11:12:01 +02:00
Add additional safety checks to gl::Uniform::load
This commit is contained in:
parent
881f7f0142
commit
a93aa68901
1 changed files with 11 additions and 8 deletions
|
@ -14,14 +14,17 @@ using namespace gl;
|
||||||
|
|
||||||
void Uniform::load(GLuint glprogram, int index) {
|
void Uniform::load(GLuint glprogram, int index) {
|
||||||
this->index = index;
|
this->index = index;
|
||||||
const GLint NAME_LENGTH = 256;
|
if (index > 0) {
|
||||||
GLchar glname[NAME_LENGTH];
|
static const GLint NAME_LENGTH = 1024;
|
||||||
GLint length = 0;
|
GLchar glname[NAME_LENGTH];
|
||||||
glGetActiveUniform(glprogram, index, NAME_LENGTH, &length, &size, &type, glname);
|
memset(glname, 0, NAME_LENGTH);
|
||||||
// Length does NOT include the null terminator
|
GLint length = 0;
|
||||||
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetActiveUniform.xhtml
|
glGetActiveUniform(glprogram, index, NAME_LENGTH, &length, &size, &type, glname);
|
||||||
name = std::string(glname, length);
|
// Length does NOT include the null terminator
|
||||||
binding = glGetUniformLocation(glprogram, glname);
|
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetActiveUniform.xhtml
|
||||||
|
name = std::string(glname, length);
|
||||||
|
binding = glGetUniformLocation(glprogram, name.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTextureType(GLenum type) {
|
bool isTextureType(GLenum type) {
|
||||||
|
|
Loading…
Reference in a new issue