diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-05-10 14:08:07 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-05-10 14:08:07 +0200 |
| commit | 6d9c284a24555a7df0b37661ff3c5491d6d0449a (patch) | |
| tree | 58d7958e7e6f59181463343891b1a590016cf5ef /src/grahpics.c | |
| parent | aea23b389a5eba09b3865209a08843e66481dd54 (diff) | |
| download | cardioid-6d9c284a24555a7df0b37661ff3c5491d6d0449a.tar.gz cardioid-6d9c284a24555a7df0b37661ff3c5491d6d0449a.tar.bz2 cardioid-6d9c284a24555a7df0b37661ff3c5491d6d0449a.zip | |
First primitive cardioid drawing
Diffstat (limited to 'src/grahpics.c')
| -rw-r--r-- | src/grahpics.c | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/src/grahpics.c b/src/grahpics.c deleted file mode 100644 index ae9409d..0000000 --- a/src/grahpics.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "graphics.h" - -#define WINDOW_TITLE "Title" - -static const char *g_sdl_error_str; - -#define SDL_CALL(x) \ - SDL_ClearError(); \ - x; \ - g_sdl_error_str = SDL_GetError(); \ - if (*g_sdl_error_str != '\0') { \ - SDL_Log("ERROR SDL: %s", g_sdl_error_str); \ - exit(EXIT_FAILURE); \ - } - - -static void update(t_state *state); -static void event_handler(t_state *state); - -void graphics_init(t_state *state, int width, int height) -{ - SDL_CALL(SDL_Init(SDL_INIT_VIDEO)); - SDL_CALL(state->window = SDL_CreateWindow( - WINDOW_TITLE, - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - width, - height, - 0 - )); - SDL_CALL(state->renderer = SDL_CreateRenderer(state->window, -1, 0)); - state->running = true; -} - -void graphics_quit(t_state *state) -{ - SDL_DestroyRenderer(state->renderer); - SDL_DestroyWindow(state->window); - SDL_Quit(); -} - -void graphics_run(t_state *state) -{ - while (state->running) - { - event_handler(state); - update(state); - SDL_Delay(3); - } -} - -static -void update(t_state *state) -{ - // do stuff -} - -static -void event_handler(t_state *state) -{ - SDL_Event e; - while (SDL_PollEvent(&e)) - { - switch (e.type) - { - case SDL_QUIT: - state->running = false; - break; - } - } -} |
