Skip to content
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

Shader uniforms #11

Merged
merged 10 commits into from
Oct 1, 2014
Merged

Shader uniforms #11

merged 10 commits into from
Oct 1, 2014

Conversation

matteblair
Copy link
Member

Adds functionality for setting shader uniforms by name and fixes some previous flaws in ShaderProgram; Further possible work:

  • Add convenience methods for setting uniforms from GLM vector and matrix types (possible now, but slightly verbose)
  • Store uniform values in ShaderProgram and make glUniform calls only when value is changed (an optimization that seems premature at this point)
  • Uniform arrays? (They seem to be very rarely used)

@@ -182,3 +172,69 @@ GLuint ShaderProgram::makeCompiledShader(const std::string& _src, GLenum _type)
return shader;

}

void ShaderProgram::setUniformi(const std::string& _name, int _value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the dynamic JS methods are nice, with just one uniform method with variable types:
https://github.com/tangram-map/tangram/blob/master/src/gl/gl_program.js#L282

That then get dispatched to the appropriate GL uniform setter variant:
https://github.com/tangram-map/tangram/blob/master/src/gl/gl_program.js#L309

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that made me jealous haha. No such luck for poor old statically compiled languages (or at least nothing faster than typing these up)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants