Cub3D
 
Loading...
Searching...
No Matches
cub3d_render.h File Reference
#include "data_structure.h"
#include <stddef.h>
Include dependency graph for cub3d_render.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

t_datacub_init (t_data *data)
 Initialize map and backbuffer for rendering.
 
int cub_translate_map (t_data *data)
 Convert 2d map string to int vector.
 
int cub3d_init_render (t_data *data)
 Init cub for rendering.
 
void cub_render (t_data *data)
 Main rendering function.
 
void cub_loop (t_data *data)
 Main loop function. Handles player update logic and rendering.
 
void cub_player_update (t_data *data)
 Updates player based on input.
 
void cub_render_minimap (t_data *data)
 Render the minimap.
 
void draw_column (t_data *data, int x, const t_raydata *rdata)
 Draw a column of pixels from a raycast result.
 
void hitwall_loop (const t_data *data, t_raydata *rdata)
 Check which wall will be hit.
 
t_imghitside_texture (t_textures *tex, int hitside, const t_pos2 *step)
 Function to select the texture based on the hit side and step direction.
 
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.
 
void cubmlx_clear (t_mlx *mlx, unsigned int color)
 Clear the backbuffer with a specific color.
 
void cubmlx_putpixel (t_data *data, int x, int y, unsigned int color)
 Puts a pixel onto the backbuffer.
 
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.
 
void cubmlx_putrect (t_data *data, t_pos2 pos, t_pos2 size, unsigned int color)
 Puts a rectangle onto the backbuffer.
 
void cubmlx_putline (t_data *data, t_pos2 p1, t_pos2 p2, unsigned int color)
 Puts a line onto the backbuffer.
 
void solve_collision_x (t_data *data, float x_vel)
 Solver of collision on x axis.
 
void solve_collision_y (t_data *data, float y_vel)
 Solver of collision on y axis.
 
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 unit, when MOVEMENT_SPEED_FWD_BWD >= 1.0f or MOVEMENT_SPEED_LEFT_RIGHT >= 1.0f.
 
float absf (float n)
 Returns the absolute value of a float.
 
int abs (int n)
 Returns the absolute value of an int.
 
int max (int a, int b)
 Returns the highest value between a and b.
 
double mind (double a, double b)
 Returns the lowest value between doubles a and b.
 
t_vec2 vec2rotate (t_vec2 vec, float angle)
 Returns a new vector rotated according to the angle.
 

Function Documentation

◆ cub3d_init_render()

int cub3d_init_render ( t_data * data)

Init cub for rendering.

Parameters
[in,out]datadata structure
Returns
int 0 OK, error otherwise
Here is the call graph for this function:

◆ cub_init()

t_data * cub_init ( t_data * data)

Initialize map and backbuffer for rendering.

Parameters
[in,out]datadata structure
Returns
t_data* data if successful, NULL otherwise
Here is the call graph for this function:

◆ cub_loop()

void cub_loop ( t_data * data)

Main loop function. Handles player update logic and rendering.

Parameters
[in,out]datadata structure
Here is the call graph for this function:

◆ cub_player_update()

void cub_player_update ( t_data * data)

Updates player based on input.

Parameters
[in,out]datadata structure

◆ cub_render()

void cub_render ( t_data * data)

Main rendering function.

Parameters
[in,out]datadata structure
Here is the call graph for this function:

◆ cub_render_minimap()

void cub_render_minimap ( t_data * data)

Render the minimap.

Parameters
[in,out]datadata structure
Here is the call graph for this function:

◆ cub_translate_map()

int cub_translate_map ( t_data * data)

Convert 2d map string to int vector.

Parameters
[in,out]datadata structure
Returns
int 1 OK, 0 otherwise

◆ draw_column()

void draw_column ( t_data * data,
int x,
const t_raydata * rdata )

Draw a column of pixels from a raycast result.

Parameters
[in,out]datadata structure
[in]xx axis column
[in,out]rdatastructure to handle important values for rendering
Here is the call graph for this function:

◆ hitside_texture()

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.

Parameters
[in]texpointer to texture structure
[in]hitsidehitside
[in]stepstep direction

◆ hitwall_loop()

void hitwall_loop ( const t_data * data,
t_raydata * rdata )

Check which wall will be hit.

Parameters
[in,out]datadata structure
[in,out]rdatastructure to handle important values for rendering

◆ raycalc()

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.

Parameters
[in]win_sizewindow size
[in]xx axis column
[in]cam_anglecamera angle
[in,out]rdatastructure to handle important values for rendering
Here is the call graph for this function: