Drawable Renderer (#1570), Better validity check for VAO wrappers.

Don't draw if VAO state isn't valid.
Reset VAO state to default after draw.
This commit is contained in:
Tim Sylvester
2023-06-06 13:08:05 -07:00
committed by Bart Louwers
parent 7f33ddfef4
commit 9966dcdb05
2 changed files with 5 additions and 4 deletions

View File

@@ -56,18 +56,17 @@ void DrawableGL::draw(const PaintParameters& parameters) const {
bindTextures();
auto& glContext = static_cast<gl::Context&>(parameters.context);
const auto saveVertexArray = glContext.bindVertexArray.getCurrentValue();
for (const auto& seg : impl->segments) {
const auto& glSeg = static_cast<DrawSegmentGL&>(*seg);
const auto& mlSeg = glSeg.getSegment();
if (glSeg.getVertexArray().isValid()) {
glContext.bindVertexArray = glSeg.getVertexArray().getID();
glContext.draw(glSeg.getMode(), mlSeg.indexOffset, mlSeg.indexLength);
}
glContext.draw(glSeg.getMode(), mlSeg.indexOffset, mlSeg.indexLength);
}
glContext.bindVertexArray = saveVertexArray;
glContext.bindVertexArray = value::BindVertexArray::Default;
unbindTextures();
unbindUniformBuffers();

View File

@@ -70,7 +70,9 @@ public:
return *this;
}
bool isValid() const { return state.operator bool(); }
bool isValid() const {
return state && state->vertexArray && state->vertexArray.get();
}
VertexArrayID getID() const { return state->vertexArray; }