Closed as not planned
Description
Describe the bug
There is an issue with depth, see the code below.
To Reproduce
void loop(void *param)
{
t_data *data;
static mlx_image_t *image = NULL;
int32_t instance_1_id;
int32_t instance_2_id;
data = param;
// WHEN THIS IS COMMENTED IN, THE SECOND SQUARE DOESN'T GET DRAWN
if (image != NULL)
{
mlx_delete_image(data->mlx, image);
image = NULL;
}
if (image == NULL)
{
image = mlx_new_image(data->mlx, 100, 100);
ft_memset(image->pixels, 255, image->width * image->height * sizeof(int));
instance_1_id = mlx_image_to_window(data->mlx, image, 0, 0);
instance_2_id = mlx_image_to_window(data->mlx, image, 100, 100);
}
}
t_i32 main(void)
{
t_data data;
ft_bzero(&data, sizeof(t_data));
data.mlx = mlx_init(200, 200, "", false);
mlx_loop_hook(data.mlx, loop, &data);
mlx_loop(data.mlx);
return (EXIT_SUCCESS);
}
Expected behavior
The second square to be drawn, see the comment in the code.
Additional context
If you replace the const float depth = mlxctx->zdepth;
with const float depth = 1000000;
inside of mlx_update_matrix()
you'll see that everything works as expected, though hardcoding it to such a low value is obviously problematic when you create more than a million instances during the lifetime of the program. Ideally you also wouldn't set it to a huge ass constant since it'd still be technically reachable if you ran the program long enough, though how you resolve this issue is up to you.