From ce51f1634af7ec5a7710d59b82716fda72607ca8 Mon Sep 17 00:00:00 2001 From: onelin Date: Wed, 26 Nov 2025 21:22:27 +0100 Subject: Add render pipeline customization --- src/daw.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/daw.c') diff --git a/src/daw.c b/src/daw.c index 163f484..fa607f0 100644 --- a/src/daw.c +++ b/src/daw.c @@ -171,9 +171,24 @@ i32 engine_run(Instance* p, StateType initial_state, void* state_arg) { StateType state = initial_state; + Window* w = p->window; + { u64 state_init_time = get_time(); State_init(state, mem, state_arg); + if (!w->render_targets) { + // 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. + FramebufferParameters p[] = { + {.num_attached_buffers = 1, {200,200}}, + }; + u32 t[] = { + BUFFERPARAMETER_SET_PARAMETER(BUFFERPARAMETER_SET_TYPE(0, BufferType_texture), BUFFERPARAMETER_TEXTURE_2D) + }; + window_init_renderstack(w, 1, 1, p, t); + w->render_targets->cam[0] = default_camera; + } INFO("Initializing state \"%s\" took %.1fns", StateTypeStr[state], (get_time() - state_init_time)); } @@ -222,12 +237,26 @@ i32 engine_run(Instance* p, StateType initial_state, void* state_arg) { // Reset camera to default camera p->cam = &default_camera; + free(w->render_targets); state = next_state; update_func = State_updateFunc(state); { u64 state_init_time = get_time(); State_init(state, mem, retval); + if (!w->render_targets) { + // 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. + FramebufferParameters p[] = { + {.num_attached_buffers = 1, {200,200}}, + }; + u32 t[] = { + BUFFERPARAMETER_SET_PARAMETER(BUFFERPARAMETER_SET_TYPE(0, BufferType_texture), BUFFERPARAMETER_TEXTURE_2D) + }; + window_init_renderstack(w, 1, 1, p, t); + w->render_targets->cam[0] = default_camera; + } INFO("Initializing state \"%s\" took %.1fns", StateTypeStr[state], (get_time() - state_init_time)); } -- cgit v1.3