Only create RenderData if we actually want to render the Renderable

This commit is contained in:
Alexander Bock
2020-08-18 13:43:51 +02:00
parent 88b6fdd9fe
commit 4f2d612abe
3 changed files with 25 additions and 12 deletions

View File

@@ -34,6 +34,7 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/misc/defer.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
@@ -166,6 +167,8 @@ bool RenderablePlane::isReady() const {
}
void RenderablePlane::initializeGL() {
ZoneScoped
glGenVertexArrays(1, &_quad); // generate array
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
createPlane();
@@ -183,6 +186,8 @@ void RenderablePlane::initializeGL() {
}
void RenderablePlane::deinitializeGL() {
ZoneScoped
glDeleteVertexArrays(1, &_quad);
_quad = 0;
@@ -199,8 +204,9 @@ void RenderablePlane::deinitializeGL() {
}
void RenderablePlane::render(const RenderData& data, RendererTasks&) {
_shader->activate();
ZoneScoped
_shader->activate();
_shader->setUniform("opacity", _opacity);
glm::dvec3 objectPositionWorld = glm::dvec3(
@@ -277,6 +283,8 @@ void RenderablePlane::bindTexture() {}
void RenderablePlane::unbindTexture() {}
void RenderablePlane::update(const UpdateData&) {
ZoneScoped
if (_shader->isDirty()) {
_shader->rebuildFromFile();
}