paysages3d/src/render/opengl/OpenGLPart.cpp

45 lines
992 B
C++
Raw Normal View History

2013-12-21 22:48:54 +00:00
#include "OpenGLPart.h"
#include "OpenGLShaderProgram.h"
2015-12-07 22:32:55 +00:00
#include "OpenGLVertexArray.h"
2013-12-21 22:48:54 +00:00
OpenGLPart::OpenGLPart(OpenGLRenderer *renderer) : renderer(renderer) {
2013-12-21 22:48:54 +00:00
}
OpenGLPart::~OpenGLPart() {
2015-12-07 22:32:55 +00:00
for (auto &pair: shaders) {
delete pair.second;
}
for (auto &array: arrays) {
delete array;
2013-12-21 22:48:54 +00:00
}
}
void OpenGLPart::interrupt() {
}
2015-12-07 22:32:55 +00:00
OpenGLShaderProgram *OpenGLPart::createShader(const std::string &name) {
OpenGLShaderProgram *program = new OpenGLShaderProgram(name, renderer);
2013-12-21 22:48:54 +00:00
2015-12-07 22:32:55 +00:00
if (shaders.find(name) == shaders.end()) {
2013-12-21 22:48:54 +00:00
shaders[name] = program;
return program;
} else {
2013-12-21 22:48:54 +00:00
return 0;
}
}
2015-12-07 22:32:55 +00:00
OpenGLVertexArray *OpenGLPart::createVertexArray(bool has_uv, bool strip)
{
OpenGLVertexArray *result = new OpenGLVertexArray(has_uv, strip);
arrays.push_back(result);
return result;
}
void OpenGLPart::updateScenery(bool onlyCommon) {
2013-12-21 22:48:54 +00:00
// Let subclass do its own collecting
if (not onlyCommon) {
2013-12-21 22:48:54 +00:00
update();
}
}