Skip to content

Commit 890e301

Browse files
committed
fixing cross compilation issue
1 parent 218a97e commit 890e301

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

includes/mlx.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
9-
/* Updated: 2023/12/08 14:09:31 by kbz_8 ### ########.fr */
9+
/* Updated: 2023/12/08 18:07:40 by kbz_8 ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -72,7 +72,7 @@ MLX_API void* mlx_new_window(void* mlx, int w, int h, const char* title);
7272
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
7373
*/
7474

75-
MLX_API int mlx_loop_hook(void* mlx, int (*f)(), void* param);
75+
MLX_API int mlx_loop_hook(void* mlx, int (*f)(void*), void* param);
7676

7777
/**
7878
* @brief Starts the internal main loop
@@ -141,7 +141,7 @@ MLX_API int mlx_mouse_get_pos(void* mlx, int* x, int* y);
141141
*
142142
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
143143
*/
144-
MLX_API int mlx_on_event(void* mlx, void* win, mlx_event_type event, int (*f)(), void* param);
144+
MLX_API int mlx_on_event(void* mlx, void* win, mlx_event_type event, int (*f)(int, void*), void* param);
145145

146146

147147
/**

test/main.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
9-
/* Updated: 2023/12/08 12:23:07 by kbz_8 ### ########.fr */
9+
/* Updated: 2023/12/08 18:08:13 by kbz_8 ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -22,12 +22,14 @@ typedef struct s_mlx
2222
void *img;
2323
} t_mlx;
2424

25-
int update(t_mlx *mlx)
25+
int update(void *param)
2626
{
2727
static int i = 0;
2828
int j;
2929
int k;
30+
t_mlx *mlx;
3031

32+
mlx = (t_mlx *)param;
3133
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->logo, 100, 100);
3234
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->img, 150, 60);
3335
mlx_string_put(mlx->mlx, mlx->win, 20, 50, 0xFFFFFFFF, "that's a text");
@@ -41,8 +43,7 @@ int update(t_mlx *mlx)
4143
k++;
4244
j++;
4345
}
44-
i++;
45-
if (i == 5000)
46+
if (++i == 5000)
4647
{
4748
mlx_clear_window(mlx->mlx, mlx->win);
4849
mlx_set_font_scale(mlx->mlx, mlx->win, "font.ttf", 16.f);
@@ -79,17 +80,17 @@ void *create_image(t_mlx *mlx)
7980
return (img);
8081
}
8182

82-
int key_hook(int key, t_mlx *param)
83+
int key_hook(int key, void *param)
8384
{
8485
if (key == 41)
85-
mlx_loop_end(param->mlx);
86+
mlx_loop_end(((t_mlx *)param)->mlx);
8687
return (0);
8788
}
8889

89-
int window_hook(int event, t_mlx *param)
90+
int window_hook(int event, void *param)
9091
{
9192
if (event == 0)
92-
mlx_loop_end(param->mlx);
93+
mlx_loop_end(((t_mlx *)param)->mlx);
9394
return (0);
9495
}
9596

0 commit comments

Comments
 (0)