(#122) bugfix: border rendering no longer throws GL error 1281 (#155)

fixes: #122
This commit is contained in:
Matthew Kosarek 2024-06-14 20:26:29 -04:00 committed by GitHub
parent 34f0614c62
commit febe04b213
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -370,7 +370,10 @@ miracle::Renderer::DrawData Renderer::draw(
}
glEnableVertexAttribArray(prog->position_attr);
glEnableVertexAttribArray(prog->texcoord_attr);
bool has_texcoord_attr = prog->texcoord_attr >= 0;
if (has_texcoord_attr)
glEnableVertexAttribArray(prog->texcoord_attr);
primitives.clear();
tessellate(primitives, renderable);
@ -415,9 +418,13 @@ miracle::Renderer::DrawData Renderer::draw(
glVertexAttribPointer(prog->position_attr, 3, GL_FLOAT,
GL_FALSE, sizeof(mgl::Vertex),
&p.vertices[0].position);
glVertexAttribPointer(prog->texcoord_attr, 2, GL_FLOAT,
GL_FALSE, sizeof(mgl::Vertex),
&p.vertices[0].texcoord);
if (has_texcoord_attr)
{
glVertexAttribPointer(prog->texcoord_attr, 2, GL_FLOAT,
GL_FALSE, sizeof(mgl::Vertex),
&p.vertices[0].texcoord);
}
if (blend.dst_rgb == GL_ZERO)
{
@ -440,7 +447,9 @@ miracle::Renderer::DrawData Renderer::draw(
{
}
glDisableVertexAttribArray(prog->texcoord_attr);
if (has_texcoord_attr)
glDisableVertexAttribArray(prog->texcoord_attr);
glDisableVertexAttribArray(prog->position_attr);
if (renderable.clip_area())
{