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:
committed by
Bart Louwers
parent
7f33ddfef4
commit
9966dcdb05
@@ -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();
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user