1 #include "SamplerBinding.hh"
2 #include <OpenGLFramework/Base/glfException.hh>
7 SamplerBinding::SamplerBinding() :
8 cached_(false), program_(NULL)
10 mappedTextures_.clear();
18 mappedTextures_.clear();
24 BIASASSERT(program_!=NULL);
25 map<std::string, textureCache>::iterator it = mappedTextures_.begin();
26 for(;it!=mappedTextures_.end(); it++) {
29 GLF_THROW_EXCEPTION(
"no active uniform named "<<it->first
30 <<
"! Check: 1. Is Program Linked?, 2. Typo?, 3. Correct shader?");
32 glGetUniformiv(program_->
GetProgramId(), loc, &it->second.tu);
44 map<std::string, textureCache>::iterator it = mappedTextures_.begin();
45 for(;it!=mappedTextures_.end(); it++) {
47 glActiveTexture(GL_TEXTURE0 + it->second.tu);
48 it->second.tex->Bind();
52 map<std::string, textureCache>::iterator it = mappedTextures_.begin();
53 for(;it!=mappedTextures_.end(); it++) {
56 GLF_THROW_EXCEPTION(
"no active uniform named "<<it->first
57 <<
"! Check: 1. Is Program Linked?, 2. Typo?, 3. Correct shader?");
61 glActiveTexture(GL_TEXTURE0 + tu);
62 it->second.tex->Bind();
78 mappedTextures_[UniformName].tex = texture;
void SetProgram(glfShaderProgram *program)
GLint GetUniformLocation(const std::string &varName)
A shader program composed of several shaders.
void Cache()
Call this to build a cache from the current object states.
void Bind()
Sets all mapped samplers to appropriate texture units.
void MapSampler(glfTexture *texture, const std::string &UniformName)