From 4a6f427eb1ebd47a171fc3a93fae9794f723fb6b Mon Sep 17 00:00:00 2001 From: hgn Date: Thu, 20 Mar 2025 03:31:22 +0000 Subject: [PATCH] framebuffer delete --- vg_framebuffer.c | 23 +++++++++++++++++++++++ vg_framebuffer.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/vg_framebuffer.c b/vg_framebuffer.c index d227c7c..2f4a68f 100644 --- a/vg_framebuffer.c +++ b/vg_framebuffer.c @@ -334,6 +334,29 @@ void vg_framebuffer_create( vg_framebuffer *fb ) vg_async_call( async_framebuffer_create, fb, 0 ); } +void vg_framebuffer_free( vg_framebuffer *fb ) +{ + glDeleteFramebuffers( 1, &fb->id ); + + for( u32 j=0; jattachment_count; j++ ) + { + vg_framebuffer_attachment *attachment = &fb->attachments[j]; + + if( attachment->purpose == k_framebuffer_attachment_type_none ) + continue; + + if( attachment->purpose == k_framebuffer_attachment_type_renderbuffer ) + { + glDeleteRenderbuffers( 1, &attachment->id ); + } + else if( attachment->purpose == k_framebuffer_attachment_type_texture || + attachment->purpose == k_framebuffer_attachment_type_texture_depth ) + { + glDeleteTextures( 1, &attachment->id ); + } + } +} + void vg_framebuffer_ui( ui_context *ctx ) { ui_px w = vg.window_x/3, diff --git a/vg_framebuffer.h b/vg_framebuffer.h index 8bf177d..788c011 100644 --- a/vg_framebuffer.h +++ b/vg_framebuffer.h @@ -92,7 +92,8 @@ vg_framebuffer *vg_framebuffer_allocate( void *alloc, u32 attachment_count, bool /* * Allocate graphics memory and initialize */ -void vg_framebuffer_create( vg_framebuffer *fb ); +void vg_framebuffer_create( vg_framebuffer *fb ); /* LOADER THREAD */ +void vg_framebuffer_free( vg_framebuffer *fb ); /* * Draw framebuffer debugging stuff -- 2.25.1