summaryrefslogtreecommitdiff
path: root/shaders/polygon.cc
diff options
context:
space:
mode:
authorHunter Kvalevog <hunter@kvog.sh>2026-02-03 22:05:09 -0600
committerHunter Kvalevog <hunter@kvog.sh>2026-02-03 22:05:09 -0600
commitbf18c18430c4cacb8c0fddbef0c2bf1962177dec (patch)
treea95f5576680ce7d43c0ddc94ccc4f40c1d42fc75 /shaders/polygon.cc
parent440612338695a73509c8bf3b72ef0e0786446cb7 (diff)
shaders: Refactor
Diffstat (limited to 'shaders/polygon.cc')
-rw-r--r--shaders/polygon.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/shaders/polygon.cc b/shaders/polygon.cc
new file mode 100644
index 0000000..c881475
--- /dev/null
+++ b/shaders/polygon.cc
@@ -0,0 +1,27 @@
+#include "shaders.hh"
+
+static int u_n = 3;
+static float u_bg[4] = { 0, 0, 0, 1 };
+static float u_fg[4] = { 1, 1, 1, 1 };
+
+static void ui()
+{
+ ImGui::SliderInt("N", &u_n, 3, 24);
+ ImGui::ColorPicker4("bg", u_bg);
+ ImGui::ColorPicker4("fg", u_fg);
+}
+
+static void uniforms(Shader* shader)
+{
+ GL(glUniform1i(shader->get_required_uniform("u_n"), u_n));
+ GL(glUniform4fv(shader->get_required_uniform("u_bg"), 1, u_bg));
+ GL(glUniform4fv(shader->get_required_uniform("u_fg"), 1, u_fg));
+}
+
+static Shader polygon = {
+ .path = "polygon.glsl",
+ .model = MODEL_QUAD,
+ .ui_fn = ui,
+ .uf_fn = uniforms,
+};
+ENABLE_SHADER(polygon);