Make RenderablePlanet not crash if the nighttextures are not present

This commit is contained in:
Alexander Bock
2017-04-13 11:52:29 -04:00
parent 8a617ee254
commit 665c9035a5
2 changed files with 5 additions and 13 deletions

View File

@@ -292,16 +292,7 @@ bool RenderablePlanet::initialize() {
LERROR(ss.str());
}
loadTexture();
while ((err = glGetError()) != GL_NO_ERROR) {
const GLubyte * errString = gluErrorString(err);
std::stringstream ss;
ss << "Error loading textures. OpenGL error: " << errString << std::endl;
LERROR(ss.str());
}
_geometry->initialize(this);
_geometry->initialize(this);
_programObject->deactivate();
@@ -309,6 +300,8 @@ bool RenderablePlanet::initialize() {
const GLubyte * errString = gluErrorString(err);
LERROR("Shader Programs Creation. OpenGL error: " << errString);
}
loadTexture();
return isReady();
}
@@ -394,13 +387,13 @@ void RenderablePlanet::render(const RenderData& data) {
_programObject->setUniform("texture1", dayUnit);
// Bind possible night texture
if (_hasNightTexture) {
if (_hasNightTexture && _nightTexture) {
nightUnit.activate();
_nightTexture->bind();
_programObject->setUniform("nightTex", nightUnit);
}
if (_hasHeightTexture) {
if (_hasHeightTexture && _heightMapTexture) {
heightUnit.activate();
_heightMapTexture->bind();
_programObject->setUniform("heightTex", heightUnit);

View File

@@ -46,7 +46,6 @@ public:
bool initialize(Renderable* parent) override;
void deinitialize() override;
void render() override;
PowerScaledSphere* _planet;
private:
void createSphere();