Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Shader.h"
- #include <GL/glew.h>
- #include <GLFW/glfw3.h>
- void Shader::bind() const {
- glUseProgram(handle);
- }
- void Shader::release() const {
- glUseProgram(0);
- }
- int Shader::uniform(const std::string &name) {
- // Is it already in the map?
- auto it = locationMap.find(name);
- if (it != locationMap.end()) {
- return it->second;
- }
- // It isn't, get the uniform location and store it
- GLint location = glGetUniformLocation(handle, name.c_str());
- locationMap.insert(std::make_pair<std::string, int>(name, location));
- return location;
- }
- int Shader::attribute(const std::string &name) {
- // Is it already in the map?
- auto it = locationMap.find(name);
- if (it != locationMap.end()) {
- return it->second;
- }
- // It isn't, get the attribute location and store it
- GLint location = glGetAttribLocation(handle, name.c_str());
- locationMap.insert(std::make_pair<std::string, int>(name, location));
- return location;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement