diff options
| author | onelin <oscar@nelin.dk> | 2025-11-26 20:22:27 +0000 |
|---|---|---|
| committer | onelin <oscar@nelin.dk> | 2025-11-26 21:45:06 +0000 |
| commit | ce51f1634af7ec5a7710d59b82716fda72607ca8 (patch) | |
| tree | f36629accd5fc47980f81a0575ba3be8c6db7564 /src/daw.c | |
| parent | 51587ec974d532b68bb323a14d18f857ed357d74 (diff) | |
Add render pipeline customization
Diffstat (limited to 'src/daw.c')
| -rw-r--r-- | src/daw.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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)); } |
