feat(shaders_lab): uniform annotations → auto-generated ImGui controls
- cpp/functions/gfx/uniform_parser: regex-based parser of @slider/@color/@toggle/@xy annotations (+ inline tests) - cpp/functions/gfx/uniform_panel: ImGui widgets + value store + glUniform* apply - shader_canvas: optional uniforms callback invoked per-frame - gl_loader: +glUniform1i/3f/4f - seed plasma: demo uniforms u_speed + u_color - rebuild Windows .exe Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "gfx/gl_loader.h"
|
||||
#include "gfx/shader_canvas.h"
|
||||
#include "imgui.h"
|
||||
#include <functional>
|
||||
|
||||
namespace fn::gfx {
|
||||
|
||||
@@ -17,7 +18,8 @@ void canvas_set_program(ShaderCanvas& c, unsigned int program) {
|
||||
c.program = program;
|
||||
}
|
||||
|
||||
void canvas_render(ShaderCanvas& c, float time_seconds) {
|
||||
void canvas_render(ShaderCanvas& c, float time_seconds,
|
||||
const std::function<void(unsigned int program)>& uniforms_fn) {
|
||||
ImVec2 avail = ImGui::GetContentRegionAvail();
|
||||
int w = static_cast<int>(avail.x);
|
||||
int h = static_cast<int>(avail.y);
|
||||
@@ -56,6 +58,8 @@ void canvas_render(ShaderCanvas& c, float time_seconds) {
|
||||
glUniform2f(loc_mouse, mx, my);
|
||||
}
|
||||
|
||||
if (uniforms_fn) uniforms_fn(c.program);
|
||||
|
||||
quad_draw(c.quad);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user