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"
|
|
|
|
|
|
|
|
OpenGLPart::OpenGLPart(OpenGLRenderer* renderer):
|
|
|
|
renderer(renderer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenGLPart::~OpenGLPart()
|
|
|
|
{
|
|
|
|
QMapIterator<QString, OpenGLShaderProgram*> i(shaders);
|
|
|
|
while (i.hasNext())
|
|
|
|
{
|
|
|
|
i.next();
|
|
|
|
delete i.value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenGLShaderProgram* OpenGLPart::createShader(QString name)
|
|
|
|
{
|
2013-12-22 14:04:33 +00:00
|
|
|
OpenGLShaderProgram* program = new OpenGLShaderProgram(name, renderer);
|
2013-12-21 22:48:54 +00:00
|
|
|
|
|
|
|
if (!shaders.contains(name))
|
|
|
|
{
|
|
|
|
shaders[name] = program;
|
|
|
|
return program;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLPart::updateScenery(bool onlyCommon)
|
|
|
|
{
|
|
|
|
// Let subclass do its own collecting
|
|
|
|
if (not onlyCommon)
|
|
|
|
{
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|