2013-12-22 14:04:33 +00:00
|
|
|
#include "OpenGLSharedState.h"
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
OpenGLSharedState::OpenGLSharedState() {
|
2013-12-22 14:04:33 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 18:18:36 +00:00
|
|
|
OpenGLSharedState::~OpenGLSharedState() {
|
2015-11-23 23:58:09 +00:00
|
|
|
for (const auto &pair : variables) {
|
|
|
|
delete pair.second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-23 22:40:19 +00:00
|
|
|
void OpenGLSharedState::apply(OpenGLShaderProgram *program, unsigned int &texture_unit) {
|
2015-11-09 21:30:46 +00:00
|
|
|
for (const auto &pair : variables) {
|
2013-12-22 17:05:11 +00:00
|
|
|
pair.second->apply(program, texture_unit);
|
2013-12-22 14:04:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-10 22:41:42 +00:00
|
|
|
void OpenGLSharedState::destroy(OpenGLFunctions *functions) {
|
|
|
|
for (const auto &pair : variables) {
|
|
|
|
pair.second->destroy(functions);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-10 23:36:50 +00:00
|
|
|
OpenGLVariable *OpenGLSharedState::get(const string &name) {
|
2015-11-09 21:30:46 +00:00
|
|
|
OpenGLVariable *&var = variables[name];
|
2015-11-23 23:58:09 +00:00
|
|
|
if (var == NULL) {
|
2013-12-22 14:04:33 +00:00
|
|
|
var = new OpenGLVariable(name);
|
|
|
|
}
|
|
|
|
return var;
|
|
|
|
}
|