@@ -256,6 +256,9 @@ SCGfxFrameStats sc_gfx_frame_stats (const SCGfxContext *ctx);
256256/* Enable or disable software framebuffer rasterization (default: on) */
257257void sc_gfx_set_rasterize (SCGfxContext * ctx , bool enable );
258258
259+ /* Resize the framebuffer / swapchain (handle window resize) */
260+ SCResult sc_gfx_resize (SCGfxContext * ctx , u32 width , u32 height );
261+
259262/* Built-in 2-D helpers (sprite / rect / text batch) */
260263void sc_gfx_draw_rect (SCGfxContext * ctx , SCRect2f rect , SCColor color );
261264void sc_gfx_draw_sprite (SCGfxContext * ctx , SCRect2f dest , SCGfxTexture tex , SCColor tint );
@@ -303,6 +306,7 @@ void sc_vulkan_end_frame (SCGfxContext *ctx);
303306SCGfxTexture sc_vulkan_make_texture (SCGfxContext * ctx ,
304307 const SCGfxTextureDesc * desc );
305308void sc_vulkan_destroy_texture (SCGfxContext * ctx , SCGfxTexture tex );
309+ SCResult sc_vulkan_resize (SCGfxContext * ctx , u32 width , u32 height );
306310#endif
307311
308312/* ---- Internal context ------------------------------------------------- */
@@ -686,6 +690,24 @@ void sc_gfx_set_rasterize(SCGfxContext *ctx, bool enable) {
686690 if (ctx ) ctx -> rasterize = enable ;
687691}
688692
693+ SCResult sc_gfx_resize (SCGfxContext * ctx , u32 width , u32 height ) {
694+ if (!ctx || width == 0 || height == 0 ) return SC_ERR_INVALID_ARG ;
695+ #ifdef SC_GFX_BACKEND_VULKAN
696+ if (ctx -> backend == SC_BACKEND_VULKAN ) {
697+ return sc_vulkan_resize (ctx , width , height );
698+ }
699+ #endif
700+ if (ctx -> backend == SC_BACKEND_SOFTWARE ) {
701+ u8 * fb = (u8 * )realloc (ctx -> framebuffer , (usize )width * height * 4 );
702+ if (!fb ) return SC_ERR_OOM ;
703+ ctx -> framebuffer = fb ;
704+ ctx -> width = width ;
705+ ctx -> height = height ;
706+ return SC_OK ;
707+ }
708+ return SC_ERR_NOT_SUPPORTED ;
709+ }
710+
689711/* ---- 2-D batch helpers ------------------------------------------------ */
690712static void _sc_gfx_push_quad (SCGfxContext * ctx , SCGfxTexture tex ,
691713 f32 x0 , f32 y0 , f32 x1 , f32 y1 ,
0 commit comments