Skip to content

ofShader should show an error when using an invalid name #1052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kylemcdonald opened this issue Mar 10, 2012 · 1 comment
Open

ofShader should show an error when using an invalid name #1052

kylemcdonald opened this issue Mar 10, 2012 · 1 comment
Milestone

Comments

@kylemcdonald
Copy link
Contributor

if you have:

uniform float dog;
float cat;

and:

shader.setUniform1f("dog", ofGetElapsedTimef());
shader.setUniform1f("cat", ofGetElapsedTimef());

there is no currently no error printed to the console, and "cat" is mysteriously unchanging while "dog" is fine.

@bakercp
Copy link
Member

bakercp commented Aug 23, 2012

+1 on this. A pattern like this?

void ofShader::setUniform1i(const char* name, int v1) {
    if(bLoaded) {
                GLint location = getUniformLocation(name);
                if(location != -1) {
                    glUniform1i(location, v1);
                } else {
                    ofLogError("ofShader") << name << " is not a valid uniform.";
                }  
        }  
}

Alternatively, there might be a way to cache uniforms / attributes and check against the cache. PR #1507 might come in handy.

@kylemcdonald kylemcdonald added this to the 0.10.1 milestone Dec 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants