-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstd_functions.c
More file actions
60 lines (53 loc) · 1.7 KB
/
std_functions.c
File metadata and controls
60 lines (53 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* :::::::: */
/* std_functions.c :+: :+: */
/* +:+ */
/* By: dkramer <dkramer@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2021/12/13 12:38:55 by dkramer #+# #+# */
/* Updated: 2021/12/13 12:38:56 by dkramer ######## odam.nl */
/* */
/* ************************************************************************** */
#include "mlx/mlx.h"
#include "so_long.h"
#include <stdlib.h>
#include "libft/ft_printf/libftprintf.h"
void my_pixel_put(t_mlx *mlx, int x, int y, unsigned int colour)
{
char *dst;
int offset;
offset = y * mlx->line_size + x * (mlx->bits_per_pixel / 8);
dst = mlx->address + offset;
*(unsigned int *)dst = colour;
}
int mymlx_destroy_window(t_mlx *mlx)
{
mlx_destroy_window(mlx->mlx, mlx->window);
exit(0);
return (0);
}
int create_trgb(int t, int r, int g, int b)
{
return (t << 24 | r << 16 | g << 8 | b);
}
void clearscreen(t_mlx *mlx)
{
int x;
int y;
unsigned int color;
color = create_trgb(0, 0, 0, 0);
x = 0;
y = 0;
while (y < mlx->height)
{
x = 0;
while (x < mlx->len * 64)
{
my_pixel_put(mlx, x, y, color);
x++;
}
y++;
}
mlx_put_image_to_window(mlx->mlx, mlx->window, mlx->image, 0, 0);
}