aboutsummaryrefslogtreecommitdiff
path: root/inc
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 /inc
parentc5008a4e62fb83eb71f5f94f622c01f2d8fe8b6b (diff)
downloadmandelbrot-6a80b1b70ec069b051c0e31aafac6eb596e20261.tar.gz
mandelbrot-6a80b1b70ec069b051c0e31aafac6eb596e20261.tar.bz2
mandelbrot-6a80b1b70ec069b051c0e31aafac6eb596e20261.zip
Back to basic SDL application boilerplate
Diffstat (limited to 'inc')
-rw-r--r--inc/config.h9
-rw-r--r--inc/mandel.h55
2 files changed, 64 insertions, 0 deletions
diff --git a/inc/config.h b/inc/config.h
new file mode 100644
index 0000000..4085dba
--- /dev/null
+++ b/inc/config.h
@@ -0,0 +1,9 @@
+#ifndef CONFIG_H
+# define CONFIG_H
+
+# define MANDEL_WINDOW_WIDTH 640
+# define MANDEL_WINDOW_HEIGHT 480
+
+# define MANDEL_WINDOW_TITLE "Mandelbrot"
+
+#endif
diff --git a/inc/mandel.h b/inc/mandel.h
new file mode 100644
index 0000000..e6f3e10
--- /dev/null
+++ b/inc/mandel.h
@@ -0,0 +1,55 @@
+#ifndef MANDEL_H
+# define MANDEL_H
+
+# include <stdlib.h>
+# include <stdbool.h>
+# include <math.h>
+# include <SDL2/SDL.h>
+
+#define SDL_CALL(x) do { \
+ SDL_ClearError(); \
+ x; \
+ error_check_sdl(#x, __FILE__, __LINE__); \
+} while (0)
+
+typedef union
+{
+ uint32_t data;
+ struct
+ {
+ uint8_t b;
+ uint8_t g;
+ uint8_t r;
+ };
+} Color;
+
+typedef struct
+{
+ double x;
+ double y;
+} Point;
+
+typedef struct
+{
+ SDL_Window *window;
+ SDL_Renderer *renderer;
+ bool running;
+ SDL_Surface *surface;
+ Color *palette;
+} State;
+
+// mandelbrot.c
+int mandelbrot(double a, double b);
+
+// state.c
+bool state_init(State *state);
+void state_quit(State *state);
+void state_run(State *state);
+
+// event.c
+void event_handle(State *state);
+
+// error.c
+void error_check_sdl(const char *code, const char *filename, int line_num);
+
+#endif