-
Notifications
You must be signed in to change notification settings - Fork 0
/
other_1.c
66 lines (59 loc) · 2.23 KB
/
other_1.c
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
61
62
63
64
65
66
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* other_1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mhedeon <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/12/08 18:22:21 by mhedeon #+# #+# */
/* Updated: 2019/01/31 17:26:44 by mhedeon ### ########.fr */
/* */
/* ************************************************************************** */
#include "wolf3d.h"
void get_color(t_texture *tex, SDL_Color *color, int x, int y)
{
color->a = (Uint8)(tex->pixels[y * tex->sur->w + x] >> 24);
color->r = (Uint8)(tex->pixels[y * tex->sur->w + x] >> 16 & 0xFF);
color->g = (Uint8)(tex->pixels[y * tex->sur->w + x] >> 8 & 0xFF);
color->b = (Uint8)(tex->pixels[y * tex->sur->w + x] & 0xFF);
}
void set_pixel(t_wolf *wolf, SDL_Color *color, int x, int y)
{
if ((wolf->buff[y * SCREEN_WIDTH + x] >> 16 & 0xFF) == 152 &&
(wolf->buff[y * SCREEN_WIDTH + x] >> 8 & 0xFF) == 0 &&
(wolf->buff[y * SCREEN_WIDTH + x] & 0xFF) == 136)
wolf->buff[y * SCREEN_WIDTH + x] = (color->a << 24) |
color->r << 16 |
color->g << 8 |
color->b;
}
void set_pixel_s(t_wolf *wolf, SDL_Color *color, int x, int y)
{
wolf->buff[y * SCREEN_WIDTH + x] = (color->a << 24) |
color->r << 16 |
color->g << 8 |
color->b;
}
void clear_buffer(t_wolf *wolf)
{
int x;
int y;
y = -1;
while (++y < SCREEN_HEIGHT)
{
x = -1;
while (++x < SCREEN_WIDTH)
wolf->buff[y * SCREEN_WIDTH + x] = (255 << 24) |
152 << 16 |
0 << 8 |
136;
}
}
void screen_upd(t_wolf *wolf)
{
SDL_UpdateTexture(wolf->tex, NULL, wolf->buff,
SCREEN_WIDTH * sizeof(Uint32));
SDL_RenderClear(wolf->ren);
SDL_RenderCopy(wolf->ren, wolf->tex, NULL, NULL);
SDL_RenderPresent(wolf->ren);
}