MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Program

Class Program

Source/Graphics/shaders.h:168–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166};
167
168class Program {
169 public:
170 GLuint gl_program;
171 std::string name;
172 int shader_ids[kMaxShaderTypes];
173 std::vector<GLint> tex_uniform;
174 typedef ska::flat_hash_map<std::string, GLint> UniformAddressCacheMap;
175 UniformAddressCacheMap uniform_address_cache;
176 typedef ska::flat_hash_map<GLint, GLint> UniformOffsetCacheMap;
177 UniformOffsetCacheMap uniform_offset_cache;
178 typedef ska::flat_hash_map<std::string, GLint> AttribAddressCacheMap;
179 AttribAddressCacheMap attrib_address_cache;
180 typedef ska::flat_hash_map<GLint, std::vector<GLfloat> > UniformValueCacheMap;
181 UniformValueCacheMap uniform_value_cache;
182 std::vector<GLint> commonShaderUniforms;
183
184 public:
185 template <typename T>
186 void SetUniform(CommonShaderUniformIDs uniformID, const T& value) {
187 SetUniform(commonShaderUniforms[uniformID], value);
188 }
189 void SetUniform(GLint uniformID, const mat4& value) {
190 // note that this avoids all of the caching that would otherwise happen
191 glUniformMatrix4fv(uniformID, 1, GL_FALSE, value);
192 }
193 void SetUniform(GLint uniformID, const mat3& value) {
194 // note that this avoids all of the caching that would otherwise happen
195 glUniformMatrix3fv(uniformID, 1, GL_FALSE, value);
196 }
197};
198
199class Shaders {
200 private:

Callers 1

returnProgramMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected