improve gexit with init function and add basic mlx image gestion

This commit is contained in:
Hugo LAMY
2022-03-25 18:49:06 +01:00
parent 3a1036ccdc
commit 02b5d88ea5
45 changed files with 139 additions and 7042 deletions

View File

@@ -1,18 +1,36 @@
#include "cube3d.h"
void destroy_mlx(void *param)
{
t_game *game;
game = param;
mlx_destroy_image(game->mlx_ptr, game->img_ptr);
mlx_destroy_window(game->mlx_ptr, game->win_ptr);
mlx_destroy_display(game->mlx_ptr);
free(game->mlx_ptr);
}
int shut_down()
{
gexit(B_RED"close windows"RESET"\n");
return (0);
}
int main(int ac, char **av)
{
t_game *game;
game = init_game();
init_parsing(ac, av, game);
gexit_init(destroy_mlx, game);
// receive a keypress event
mlx_hook(game->win_ptr, 2, 1L << 0, keypress, game);
// receive a keyprelease event
mlx_hook(game->win_ptr, 3, 1L << 1, keyrelease, game);
// receive event when clicking the red button to close the window
mlx_hook(game->win_ptr, 17, 1L << 17, shut_down, game);
mlx_hook(game->win_ptr, 17, 1L << 17, shut_down, NULL);
// infinite loop that waits for events to occurs
mlx_loop(game->mlx_ptr);
return (0);