summaryrefslogtreecommitdiff
path: root/src/daw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daw.c')
-rw-r--r--src/daw.c29
1 files changed, 29 insertions, 0 deletions
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));
}