Skip to content
Permalink
Browse files

stylequad: always enable the tex_coord vertex attrib array when drawing

This fixes a rendering bug on Windows systems with AMD GPUs which caused
untextured (solid) stylequads to usually not be displayed. The stylequad
shader has a vertex attribute array for texture coordinates, and when
that array is disabled, the AMD driver (or GPU) is very unhappy.
  • Loading branch information
wrl committed Oct 30, 2018
1 parent 3afa6cf commit a202d8381af3950a23a76be9d7d219cf1ba41411
Showing with 13 additions and 4 deletions.
  1. +13 −4 src/stylequad.c
@@ -45,7 +45,6 @@ draw_solid(const struct rtb_stylequad *self, const struct rtb_shader *shader,
glBindBuffer(GL_ARRAY_BUFFER, self->vertices);
glEnableVertexAttribArray(shader->vertex);
glVertexAttribPointer(shader->vertex, 2, GL_FLOAT, GL_FALSE, 0, 0);

glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
@@ -71,6 +70,7 @@ draw_textured(struct rtb_render_context *ctx,
glEnableVertexAttribArray(shader->tex_coord);
glVertexAttribPointer(shader->tex_coord,
2, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

/* XXX: hardcoded `count` value here */
if (border)
@@ -95,23 +95,27 @@ draw(struct rtb_render_context *ctx, const struct rtb_stylequad *self,
rtb_render_set_position(ctx, center->x, center->y);
glUniform2f(shader->texture_size, 0.f, 0.f);

if (self->properties.bg_color && mode & RTB_STYLEQUAD_DRAW_BG_COLOR) {
if (self->properties.bg_color && (mode & RTB_STYLEQUAD_DRAW_BG_COLOR)) {
rtb_render_set_color(ctx,
self->properties.bg_color->r,
self->properties.bg_color->g,
self->properties.bg_color->b,
self->properties.bg_color->a);

glEnableVertexAttribArray(shader->tex_coord);

draw_solid(self, shader, GL_TRIANGLE_STRIP,
ctx->window->local_storage.ibo.stylequad.solid, 4);

glDisableVertexAttribArray(shader->tex_coord);
}

if (self->background_image.definition
&& mode & RTB_STYLEQUAD_DRAW_BG_IMAGE)
&& (mode & RTB_STYLEQUAD_DRAW_BG_IMAGE))
draw_textured(ctx, self, &self->background_image, 0);

if (self->border_image.definition
&& mode & RTB_STYLEQUAD_DRAW_BORDER_IMAGE)
&& (mode & RTB_STYLEQUAD_DRAW_BORDER_IMAGE))
draw_textured(ctx, self, &self->border_image, 1);

if (self->properties.border_color
@@ -144,9 +148,14 @@ rtb_stylequad_draw_solid(const struct rtb_stylequad *self,
const struct rtb_shader *shader = ctx->shader;

rtb_render_set_position(ctx, center->x, center->y);
glUniform2f(shader->texture_size, 0.f, 0.f);

glEnableVertexAttribArray(shader->tex_coord);

draw_solid(self, shader, GL_TRIANGLE_STRIP,
ctx->window->local_storage.ibo.stylequad.solid, 4);

glDisableVertexAttribArray(shader->tex_coord);
}

void

0 comments on commit a202d83

Please sign in to comment.