aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shaders/rect.frag18
-rw-r--r--test/pugl_gl3_test.c18
2 files changed, 14 insertions, 22 deletions
diff --git a/shaders/rect.frag b/shaders/rect.frag
index d128f37..cb25bed 100644
--- a/shaders/rect.frag
+++ b/shaders/rect.frag
@@ -11,7 +11,6 @@
hardcoded, but could be made a uniform or vertex attribute easily enough. */
uniform vec2 u_size;
-uniform vec4 u_borderColor;
uniform vec4 u_fillColor;
noperspective in vec2 f_uv;
@@ -23,14 +22,15 @@ main()
{
const float border_width = 2.0;
- float t = step(border_width, f_uv[1]);
- float r = step(border_width, u_size.x - f_uv[0]);
- float b = step(border_width, u_size.y - f_uv[1]);
- float l = step(border_width, f_uv[0]);
- float fill_mix = t * r * b * l;
- float border_mix = 1.0 - fill_mix;
- vec4 fill = fill_mix * u_fillColor;
- vec4 border = border_mix * u_borderColor;
+ vec4 border_color = u_fillColor + vec4(0.0, 0.4, 0.4, 0.0);
+ float t = step(border_width, f_uv[1]);
+ float r = step(border_width, u_size.x - f_uv[0]);
+ float b = step(border_width, u_size.y - f_uv[1]);
+ float l = step(border_width, f_uv[0]);
+ float fill_mix = t * r * b * l;
+ float border_mix = 1.0 - fill_mix;
+ vec4 fill = fill_mix * u_fillColor;
+ vec4 border = border_mix * border_color;
FragColor = fill + border;
}
diff --git a/test/pugl_gl3_test.c b/test/pugl_gl3_test.c
index 9ddf7db..672dc65 100644
--- a/test/pugl_gl3_test.c
+++ b/test/pugl_gl3_test.c
@@ -59,7 +59,6 @@ typedef struct
float pos[2];
float size[2];
float fillColor[4];
- float borderColor[4];
} Rect;
// clang-format off
@@ -87,7 +86,6 @@ typedef struct
GLint u_MVP;
GLint u_size;
GLint u_fillColor;
- GLint u_borderColor;
unsigned framesDrawn;
int quit;
} PuglTestApp;
@@ -125,7 +123,6 @@ drawRect(const PuglTestApp* app, const Rect* rect, mat4 projection)
// Set uniforms for the various rectangle attributes
glUniform2fv(app->u_size, 1, rect->size);
glUniform4fv(app->u_fillColor, 1, rect->fillColor);
- glUniform4fv(app->u_borderColor, 1, rect->borderColor);
// Draw
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0);
@@ -207,14 +204,11 @@ makeRects(const size_t numRects)
const float s = (sinf(i) / 2.0f + 0.5f);
const float c = (cosf(i) / 2.0f + 0.5f);
- rects[i].size[0] = minSize + s * maxSize;
- rects[i].size[1] = minSize + c * maxSize;
- rects[i].fillColor[1] = s / 2.0f + 0.25f;
- rects[i].fillColor[2] = c / 2.0f + 0.25f;
- rects[i].fillColor[3] = boxAlpha;
- rects[i].borderColor[1] = rects[i].fillColor[1] + 0.4f;
- rects[i].borderColor[2] = rects[i].fillColor[1] + 0.4f;
- rects[i].borderColor[3] = boxAlpha;
+ rects[i].size[0] = minSize + s * maxSize;
+ rects[i].size[1] = minSize + c * maxSize;
+ rects[i].fillColor[1] = s / 2.0f + 0.25f;
+ rects[i].fillColor[2] = c / 2.0f + 0.25f;
+ rects[i].fillColor[3] = boxAlpha;
}
return rects;
@@ -330,8 +324,6 @@ main(int argc, char** argv)
app.u_MVP = glGetUniformLocation(app.drawRect.program, "MVP");
app.u_size = glGetUniformLocation(app.drawRect.program, "u_size");
app.u_fillColor = glGetUniformLocation(app.drawRect.program, "u_fillColor");
- app.u_borderColor =
- glGetUniformLocation(app.drawRect.program, "u_borderColor");
// Generate/bind a VAO to track state
glGenVertexArrays(1, &app.vao);