diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-02-24 10:45:32 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-02-24 10:45:32 +0100 |
| commit | ee4c9685acd70b9b12b22d967c2a45e9a63a714c (patch) | |
| tree | 9b4487a28c5519034d382f98d59d7eba17985a2c /src/state.c | |
| parent | 49f9d59d274324c83170c120cdfa7485328c2d17 (diff) | |
| download | fractol-ee4c9685acd70b9b12b22d967c2a45e9a63a714c.tar.gz fractol-ee4c9685acd70b9b12b22d967c2a45e9a63a714c.tar.bz2 fractol-ee4c9685acd70b9b12b22d967c2a45e9a63a714c.zip | |
Boilerplate minilibx
Diffstat (limited to 'src/state.c')
| -rw-r--r-- | src/state.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/state.c b/src/state.c new file mode 100644 index 0000000..4f33041 --- /dev/null +++ b/src/state.c @@ -0,0 +1,48 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* state.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/24 09:58:01 by cacharle #+# #+# */ +/* Updated: 2020/02/24 10:43:08 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "fractol.h" + +static void st_state_init_palette(t_state *state) +{ + + +} + +int state_init(t_state *state, char *fractal_name) +{ + (void)fractal_name; + + if ((state->mlx_ptr = mlx_init()) == NULL) + return (-1); + if ((state->window_ptr = mlx_new_window(state->mlx_ptr, 640, 480, WINDOW_TITLE)) == NULL) + return (state_destroy(state)); + state->window.width = WINDOW_WIDTH; + state->window.height = WINDOW_HEIGHT; + if ((state->window.id = mlx_new_image(state->mlx_ptr, state->window.width, state->window.height)) == NULL) + return (state_destroy(state)); + state->window.data = mlx_get_data_addr(state->window.id, &state->window.depth, + &state->window.size_line, &state->window.endian); + state->running = true; + return (0); +} + +int state_destroy(t_state *state) +{ + if (state == NULL) + return (-1); + if (state->mlx_ptr != NULL && state->window.id != NULL) + mlx_destroy_image(state->mlx_ptr, state->window.id); + if (state->mlx_ptr != NULL && state->window_ptr != NULL) + mlx_destroy_window(state->mlx_ptr, state->window_ptr); + return (-1); +} |
