Files
egutierrez ab3115ce99 feat(shaders_lab): per-node preview thumbnails + double-rclick delete node
- DagStep: preview_open flag (default false).
- dag_compile: emit `uniform int u_preview_target` and a series of
  early-return branches at the start of fragColor selection. -1 (default)
  falls through to the real Output-driven fragColor.
- dag_node_previews (new fn): per-node FBO keyed by editor_uid, lazy
  created. Renders each node with preview_open=true to its FBO by
  setting u_preview_target = step index. Texture exposed via
  dag_preview_texture(uid) for ImGui::Image.
- dag_node_editor: small toggle button "[+] preview"/"[-] preview" in
  each non-Output node; when open, ImGui::Image(96x64, V-flipped).
- dag_node_editor: double right-click on hovered node deletes it
  (Output is protected).
- main.cpp: dag_previews_render after Canvas DAG; dag_previews_destroy
  on shutdown.

Single GL program drives both the canvas and all thumbnails — moving
sliders never recompiles, only the topology change does.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 02:06:50 +02:00

26 lines
961 B
C++

#pragma once
#include <vector>
#include "gfx/dag_types.h"
namespace fn::gfx {
// Renders a small thumbnail per node that has preview_open == true, by binding
// the node's FBO and drawing the DAG shader with u_preview_target = step index.
// Each node's FBO is created lazily and keyed by editor_uid. The active GL
// program must be the one returned by compile_dag_to_glsl(pipeline).
//
// Pass the pipeline used to compile `program` so target indices match.
void dag_previews_render(const std::vector<DagStep>& pipeline,
unsigned program,
int width = 96, int height = 64);
// Returns the OpenGL texture id for the preview of `editor_uid`, or 0 if
// none exists. Use with ImGui::Image(). Call AFTER dag_previews_render so
// the texture has fresh contents.
unsigned dag_preview_texture(unsigned editor_uid);
// Free all preview FBOs. Call on shutdown.
void dag_previews_destroy();
} // namespace fn::gfx