adding graphics support class, refactoring the code

This commit is contained in:
2023-04-02 17:37:38 +02:00
parent 7eea6ea1d5
commit aaf7e861d5
14 changed files with 318 additions and 148 deletions

View File

@@ -6,14 +6,14 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
/* Updated: 2023/04/01 17:50:46 by maldavid ### ########.fr */
/* Updated: 2023/04/02 15:50:40 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../includes/mlx.h"
typedef struct
typedef struct s_mlx
{
void *mlx;
void *win;
@@ -25,7 +25,6 @@ int update(t_mlx *mlx)
static int i = 0;
int j;
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->logo, 100, 100);
j = 0;
while (j < 400)
{
@@ -46,11 +45,13 @@ int main(void)
t_mlx mlx;
int w;
int h;
mlx.mlx = mlx_init();
mlx.win = mlx_new_window(mlx.mlx, 400, 400, "My window");
mlx.logo = mlx_png_file_to_image(mlx.mlx, "42_logo.png", &w, &h);
mlx_pixel_put(mlx.mlx, mlx.win, 200, 10, 0xFFFF00FF);
mlx_put_image_to_window(mlx.mlx, mlx.win, mlx.logo, 100, 100);
mlx_put_image_to_window(mlx.mlx, mlx.win, mlx.logo, 200, 200);
mlx_loop_hook(mlx.mlx, update, &mlx);
mlx_loop(mlx.mlx);
mlx_destroy_image(mlx.mlx, mlx.logo);