Last development push
This commit is contained in:
67
src/execution/render2.c
Normal file
67
src/execution/render2.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* render2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/09 18:44:12 by aortigos #+# #+# */
|
||||
/* Updated: 2025/12/09 18:44:40 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/cub3d.h"
|
||||
|
||||
int get_rgba(int r, int g, int b, int a)
|
||||
{
|
||||
return (r << 24 | g << 16 | b << 8 | a << 0);
|
||||
}
|
||||
|
||||
int reverse_bytes(int c)
|
||||
{
|
||||
unsigned int b;
|
||||
|
||||
b = 0;
|
||||
b |= (c & 0xFF) << 24;
|
||||
b |= (c & 0xFF00) << 8;
|
||||
b |= (c & 0xFF0000) >> 8;
|
||||
b |= (c & 0xFF000000) >> 24;
|
||||
return (b);
|
||||
}
|
||||
|
||||
void my_mlx_pixel_put(t_mlx *mlx, int x, int y, int color)
|
||||
{
|
||||
if (x < 0)
|
||||
return ;
|
||||
else if (x >= S_W)
|
||||
return ;
|
||||
if (y < 0)
|
||||
return ;
|
||||
else if (y >= S_H)
|
||||
return ;
|
||||
mlx_put_pixel(mlx->img, x, y, color);
|
||||
}
|
||||
|
||||
float nor_angle(float angle)
|
||||
{
|
||||
if (angle < 0)
|
||||
angle += (2 * M_PI);
|
||||
if (angle > (2 * M_PI))
|
||||
angle -= (2 * M_PI);
|
||||
return (angle);
|
||||
}
|
||||
|
||||
int unit_circle(float angle, char c)
|
||||
{
|
||||
if (c == 'x')
|
||||
{
|
||||
if (angle > 0 && angle < M_PI)
|
||||
return (1);
|
||||
}
|
||||
else if (c == 'y')
|
||||
{
|
||||
if (angle > (M_PI / 2) && angle < (3 * M_PI) / 2)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user