aboutsummaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-05-19 13:22:59 +0200
committerCharles <sircharlesaze@gmail.com>2020-05-19 13:22:59 +0200
commit6a80b1b70ec069b051c0e31aafac6eb596e20261 (patch)
treeedf9856bcd2b4415796a2a49f0232ba830e69560 /src/state.c
parentc5008a4e62fb83eb71f5f94f622c01f2d8fe8b6b (diff)
downloadmandelbrot-6a80b1b70ec069b051c0e31aafac6eb596e20261.tar.gz
mandelbrot-6a80b1b70ec069b051c0e31aafac6eb596e20261.tar.bz2
mandelbrot-6a80b1b70ec069b051c0e31aafac6eb596e20261.zip
Back to basic SDL application boilerplate
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/state.c b/src/state.c
new file mode 100644
index 0000000..ee68b77
--- /dev/null
+++ b/src/state.c
@@ -0,0 +1,34 @@
+#include "config.h"
+#include "mandel.h"
+
+bool state_init(State *state)
+{
+ SDL_CALL(SDL_Init(SDL_INIT_VIDEO));
+ SDL_CALL(state->window = SDL_CreateWindow(
+ MANDEL_WINDOW_TITLE,
+ SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED,
+ MANDEL_WINDOW_WIDTH,
+ MANDEL_WINDOW_HEIGHT,
+ 0));
+ SDL_CALL(state->renderer = SDL_CreateRenderer(state->window, -1, 0));
+ state->running = true;
+ return state;
+}
+
+void state_run(State *state)
+{
+ while (state->running)
+ {
+ event_handle(state);
+ }
+}
+
+void state_quit(State *state)
+{
+ /* free(state->palette); */
+ /* SDL_FreeSurface(state->surface); */
+ SDL_DestroyRenderer(state->renderer);
+ SDL_DestroyWindow(state->window);
+ SDL_Quit();
+}