From 6a80b1b70ec069b051c0e31aafac6eb596e20261 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 19 May 2020 13:22:59 +0200 Subject: Back to basic SDL application boilerplate --- inc/config.h | 9 +++++++++ inc/mandel.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 inc/config.h create mode 100644 inc/mandel.h (limited to 'inc') 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 +# include +# include +# include + +#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 -- cgit