Cub3D
 
Loading...
Searching...
No Matches
cub3d_render.h
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* cub3d_render.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: ppontet <ppontet@student.42lyon.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/06/17 20:50:27 by rdesprez #+# #+# */
9/* Updated: 2025/09/29 15:22:07 by rdesprez ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#ifndef CUB3D_RENDER_H
14# define CUB3D_RENDER_H
15
16# include "data_structure.h"
17# include <stddef.h>
18
25t_data *cub_init(t_data *data);
32int cub_translate_map(t_data *data);
39int cub3d_init_render(t_data *data);
45void cub_render(t_data *data);
51void cub_loop(t_data *data);
57void cub_player_update(t_data *data);
63void cub_render_minimap(t_data *data);
71void draw_column(t_data *data, int x, const t_raydata *rdata);
78void hitwall_loop(const t_data *data, t_raydata *rdata);
87t_img *hitside_texture(t_textures *tex, int hitside, const t_pos2 *step);
96void raycalc(const t_pos2 win_size, int x, float cam_angle,
97 t_raydata *rdata);
98
105
112void cubmlx_clear(t_mlx *mlx, unsigned int color);
113
122void cubmlx_putpixel(t_data *data, int x, int y, unsigned int color);
123
132void cubmlx_putvertline(t_data *data, t_pos2 pos, int len,
133 unsigned int color);
134
143void cubmlx_putrect(t_data *data, t_pos2 pos, t_pos2 size,
144 unsigned int color);
145
154void cubmlx_putline(t_data *data, t_pos2 p1, t_pos2 p2, unsigned int color);
156
162
169void solve_collision_x(t_data *data, float x_vel);
170
177void solve_collision_y(t_data *data, float y_vel);
178
188void resolve_collision_steps(t_data *data, float vel_x, float vel_y);
190
196
203float absf(float n);
204
211int abs(int n);
212
220int max(int a, int b);
221
229double mind(double a, double b);
230
238t_vec2 vec2rotate(t_vec2 vec, float angle);
240
241#endif
void hitwall_loop(const t_data *data, t_raydata *rdata)
Check which wall will be hit.
Definition hitwall.c:15
t_data * cub_init(t_data *data)
Initialize map and backbuffer for rendering.
Definition init.c:36
void cub_player_update(t_data *data)
Updates player based on input.
Definition player.c:89
t_img * hitside_texture(t_textures *tex, int hitside, const t_pos2 *step)
Function to select the texture based on the hit side and step direction.
Definition hitside.c:15
void draw_column(t_data *data, int x, const t_raydata *rdata)
Draw a column of pixels from a raycast result.
Definition draw_column.c:109
void cub_loop(t_data *data)
Main loop function. Handles player update logic and rendering.
Definition loop.c:41
int cub_translate_map(t_data *data)
Convert 2d map string to int vector.
Definition map_translate.c:78
void cub_render(t_data *data)
Main rendering function.
Definition render.c:20
void raycalc(const t_pos2 win_size, int x, float cam_angle, t_raydata *rdata)
Function to calculate rays using window size and camera angle.
Definition render_more.c:19
int cub3d_init_render(t_data *data)
Init cub for rendering.
Definition cub3d_raoul.c:20
void cub_render_minimap(t_data *data)
Render the minimap.
Definition minimap.c:81
Header file for all the types and structures of the project.
struct s_data t_data
Definition data_structure.h:32
struct s_vec2 t_vec2
Definition data_structure.h:37
struct s_pos2 t_pos2
Definition data_structure.h:36
struct s_raydata t_raydata
Definition data_structure.h:41
struct s_img t_img
Definition data_structure.h:26
struct s_mlx t_mlx
Definition data_structure.h:29
struct s_textures t_textures
Definition data_structure.h:27
void cubmlx_clear(t_mlx *mlx, unsigned int color)
Clear the backbuffer with a specific color.
Definition ft_mlx_render.c:15
void cubmlx_putvertline(t_data *data, t_pos2 pos, int len, unsigned int color)
Puts a vertical line on the backbuffer. Optimized for vertical lines.
Definition ft_mlx_render.c:42
void cubmlx_putrect(t_data *data, t_pos2 pos, t_pos2 size, unsigned int color)
Puts a rectangle onto the backbuffer.
Definition ft_mlx_render.c:65
void cubmlx_putpixel(t_data *data, int x, int y, unsigned int color)
Puts a pixel onto the backbuffer.
Definition ft_mlx_render.c:30
void cubmlx_putline(t_data *data, t_pos2 p1, t_pos2 p2, unsigned int color)
Puts a line onto the backbuffer.
Definition ft_mlx_render.c:84
void resolve_collision_steps(t_data *data, float vel_x, float vel_y)
Solver of collision on x and y using steps smaller than 1 unit, To use only when moving faster than 1...
Definition player_utils.c:62
void solve_collision_x(t_data *data, float x_vel)
Solver of collision on x axis.
Definition player_utils.c:16
void solve_collision_y(t_data *data, float y_vel)
Solver of collision on y axis.
Definition player_utils.c:39
float absf(float n)
Returns the absolute value of a float.
Definition utils.c:13
double mind(double a, double b)
Returns the lowest value between doubles a and b.
Definition utils.c:34
t_vec2 vec2rotate(t_vec2 vec, float angle)
Returns a new vector rotated according to the angle.
Definition vec2.c:16
int max(int a, int b)
Returns the highest value between a and b.
Definition utils.c:27
int abs(int n)
Returns the absolute value of an int.
Definition utils.c:20