Files
fn_registry/cpp/functions/gfx/gl_framebuffer.md
T
egutierrez 37ca9562c3 chore(registry): añadir uses_functions a consumidores reales (gfx)
Auditoria del issue 0044: 14 archivos .md de cpp/functions/gfx/ con
uses_functions actualizado. Resuelve dependencias detectadas via
#include: gl_loader (consumido por casi todo el dominio gfx),
dag_catalog (consumido por la familia dag_*), fullscreen_quad,
gl_framebuffer, gl_shader, mesh_obj_load, uniform_parser y
dag_node_previews.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 23:40:31 +02:00

1.8 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path, framework, params, output
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path framework params output
gl_framebuffer function cpp gfx 1.0.0 impure void fb_init(Framebuffer& f); void fb_resize(Framebuffer& f, int w, int h); void fb_destroy(Framebuffer& f) CRUD de un framebuffer OpenGL (FBO + textura RGBA8). fb_resize es no-op si las dimensiones no cambian. Listo para uso con ImGui::Image.
opengl
framebuffer
fbo
texture
gfx
offscreen
gl_loader_cpp_gfx
false error_go_core
GL/gl.h
GL/glext.h
false
cpp/functions/gfx/gl_framebuffer.cpp opengl
name desc
f Struct Framebuffer con campos fbo, tex (GL ids), width, height. Inicializar a {0} antes de fb_init.
name desc
w Ancho deseado en pixels (fb_resize)
name desc
h Alto deseado en pixels (fb_resize)
Modifica f in-place. Después de fb_init, f.fbo y f.tex son IDs GL válidos. fb_destroy pone todos los campos a 0.

gl_framebuffer

FBO con textura color RGBA8 (GL_CLAMP_TO_EDGE, GL_LINEAR). Diseñado para renderizado offscreen y posterior display via ImGui::Image.

Ciclo de vida

fn::gfx::Framebuffer fb{};
fn::gfx::fb_init(fb);          // fbo + tex 1x1

// En el render loop:
fn::gfx::fb_resize(fb, w, h);  // no-op si mismas dimensiones

// Al destruir:
fn::gfx::fb_destroy(fb);

Uso con ImGui::Image

// Flip Y porque OpenGL tiene origen bottom-left
ImGui::Image(
    reinterpret_cast<ImTextureID>(static_cast<uintptr_t>(fb.tex)),
    size,
    ImVec2(0, 1), ImVec2(1, 0)
);

Notas

fb_resize recrea solo la textura (no el FBO) cuando las dimensiones cambian, reattachando la nueva textura al FBO existente. Esto minimiza el overhead de resize.