From eb06c9d49fddd6ffd5725bf8a33c2eab8cfd94c7 Mon Sep 17 00:00:00 2001 From: onelin Date: Wed, 3 Dec 2025 22:21:54 +0100 Subject: Add support for depth & stencil buffers --- src/daw.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/daw.c') diff --git a/src/daw.c b/src/daw.c index 2687f11..4a99d33 100644 --- a/src/daw.c +++ b/src/daw.c @@ -245,13 +245,21 @@ i32 engine_run(Instance* p, StateType initial_state, void* state_arg) { // Create only 1 additional framebuffer, in addition to the default // one. This is used to render a texture that is represented as a quad // on the default framebuffer. + ivec2 wsz; + window_get_size(&wsz); FramebufferParameters p[] = { - {.num_attached_buffers = 1, {1600,1600}}, + {.num_attached_buffers = 2, .dimensions = {wsz[0], wsz[1], 0}}, }; u32 t[] = { - BUFFERPARAMETER_SET_PARAMETER(BUFFERPARAMETER_SET_TYPE(0, BufferType_texture), BUFFERPARAMETER_TEXTURE_2D | BUFFERPARAMETER_TEXTURE_FMT_RGBA8) + BUFFERPARAMETER_SET_PARAMETER(BUFFERPARAMETER_SET_TYPE(0, BufferType_texture), BUFFERPARAMETER_TEXTURE_2D | BUFFERPARAMETER_FMT_RGBA8), + // The depth buffer could also be a texture like so: + // BUFFERPARAMETER_SET_PARAMETER( + // BUFFERPARAMETER_SET_TYPE(0, BufferType_texture), + // BUFFERPARAMETER_TEXTURE_2D | BUFFERPARAMETER_FMT_DEPTH + // ), + BUFFERPARAMETER_SET_PARAMETER(BUFFERPARAMETER_SET_TYPE(0, BufferType_render), BUFFERPARAMETER_RENDERBUFFER_DEPTH | BUFFERPARAMETER_FMT_DEPTH), }; - window_init_renderstack(w, 1, 1, p, t); + window_init_renderstack(w, 1, 2, p, t); //w->render_targets->cam[0] = &default_renderbuffer_camera; } -- cgit v1.3