a la norme et sans leaks, manque le parsing
This commit is contained in:
37
srcs/draw.c
37
srcs/draw.c
@@ -2,14 +2,14 @@
|
||||
|
||||
void draw_image(t_fdf *fdf)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
fdf->rad_x = fdf->rot_x * M_PI / 180;
|
||||
fdf->rad_y = fdf->rot_y * M_PI / 180;
|
||||
i =-1;
|
||||
i = -1;
|
||||
while (++i < fdf->img_size_y * fdf->img_sizel)
|
||||
*(unsigned int*)(fdf->img_addr + i) = 0;
|
||||
*(unsigned int *)(fdf->img_addr + i) = 0;
|
||||
j = -1;
|
||||
while (++j < fdf->map_height)
|
||||
{
|
||||
@@ -23,8 +23,8 @@ void draw_image(t_fdf *fdf)
|
||||
|
||||
void draw_grid(t_fdf *fdf, int i, int j)
|
||||
{
|
||||
int *point_start;
|
||||
int *point_end;
|
||||
int *point_start;
|
||||
int *point_end;
|
||||
|
||||
point_start = new_coordinates(fdf, i, j);
|
||||
point_end = NULL;
|
||||
@@ -32,17 +32,22 @@ void draw_grid(t_fdf *fdf, int i, int j)
|
||||
point_end = new_coordinates(fdf, i + 1, j);
|
||||
draw_lines(fdf, point_start, point_end);
|
||||
if (j + 1 < fdf->map_height)
|
||||
{
|
||||
free(point_end);
|
||||
point_end = new_coordinates(fdf, i, j + 1);
|
||||
}
|
||||
draw_lines(fdf, point_start, point_end);
|
||||
free(point_start);
|
||||
free(point_end);
|
||||
}
|
||||
|
||||
void draw_lines(t_fdf *fdf, int *start, int *end)
|
||||
{
|
||||
int dx;
|
||||
int dy;
|
||||
int z;
|
||||
int i;
|
||||
int j;
|
||||
int dx;
|
||||
int dy;
|
||||
int z;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if (end)
|
||||
{
|
||||
@@ -66,7 +71,7 @@ void draw_lines(t_fdf *fdf, int *start, int *end)
|
||||
|
||||
void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z)
|
||||
{
|
||||
int color;
|
||||
int color;
|
||||
|
||||
color = 0xffffff;
|
||||
z -= (z * fdf->zoom) / fdf->offset;
|
||||
@@ -81,14 +86,14 @@ void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z)
|
||||
|
||||
void draw_pixel(t_fdf *fdf, int x, int y, int color)
|
||||
{
|
||||
int position;
|
||||
int xmax;
|
||||
int ymax;
|
||||
int position;
|
||||
int xmax;
|
||||
int ymax;
|
||||
|
||||
xmax = fdf->img_sizel / (fdf->img_bpp / 8);
|
||||
ymax = fdf->img_size_y;
|
||||
if (x < 0 || y < 0 || x > xmax || y > ymax)
|
||||
return ;
|
||||
position = y * fdf->img_sizel + x * fdf->img_bpp / 8;
|
||||
*(unsigned int*)(fdf->img_addr + position) = color;
|
||||
*(unsigned int *)(fdf->img_addr + position) = color;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user