2013-12-21 22:48:54 +00:00
|
|
|
#include "OpenGLPart.h"
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <cmath>
|
|
|
|
#include "OpenGLRenderer.h"
|
|
|
|
#include "OpenGLShaderProgram.h"
|
|
|
|
#include "CameraDefinition.h"
|
|
|
|
#include "AtmosphereDefinition.h"
|
|
|
|
#include "AtmosphereRenderer.h"
|
|
|
|
#include "Scenery.h"
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
OpenGLPart::OpenGLPart(OpenGLRenderer *renderer) : renderer(renderer) {
|
2013-12-21 22:48:54 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
OpenGLPart::~OpenGLPart() {
|
|
|
|
QMapIterator<QString, OpenGLShaderProgram *> i(shaders);
|
|
|
|
while (i.hasNext()) {
|
2013-12-21 22:48:54 +00:00
|
|
|
i.next();
|
|
|
|
delete i.value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void OpenGLPart::interrupt() {
|
2013-12-30 15:02:33 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
OpenGLShaderProgram *OpenGLPart::createShader(QString name) {
|
|
|
|
OpenGLShaderProgram *program = new OpenGLShaderProgram(name.toStdString(), renderer);
|
2013-12-21 22:48:54 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
if (!shaders.contains(name)) {
|
2013-12-21 22:48:54 +00:00
|
|
|
shaders[name] = program;
|
|
|
|
return program;
|
2015-11-09 21:30:46 +00:00
|
|
|
} else {
|
2013-12-21 22:48:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void OpenGLPart::updateScenery(bool onlyCommon) {
|
2013-12-21 22:48:54 +00:00
|
|
|
// Let subclass do its own collecting
|
2015-11-09 21:30:46 +00:00
|
|
|
if (not onlyCommon) {
|
2013-12-21 22:48:54 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|