Trace Engine
A Raycaster Engine in C
Loading...
Searching...
No Matches
render.c File Reference
#include "render.h"
#include <math.h>
#include "map.h"
#include "raycaster.h"
#include "trigonometry.h"
#include "window_manager.h"
#include "graphics.h"
#include "trc_camera.h"
#include "textures.h"

Macros

#define RENDER_CHUNK_SIZE   (4) /** How many blocks away can the camera see */
 
#define RENDER_DISTANCE   (MAP_CELL_SIZE * RENDER_CHUNK_SIZE) /** Distance between the camera and the further object visible */
 
#define MAX_WALL_HEIGHT   (VIEWPORT_HEIGHT) /** A rename for VIEWPORT_HEIGHT, for easier code reading */
 
#define LINES_WIDTH   ((int) (VIEWPORT_WIDTH / get_ammount_of_rays())) /** Ammount of pixels each ray will draw on screen */
 
#define X_CORRECTION   (LINES_WIDTH / 2.0) /** Correction for X axis to get the screen centered */
 
#define Y_CORRECTION   (VIEWPORT_HEIGHT / 2.0) /** Correction for Y axis to get the screen centered */
 
#define DISTANCE_CORRECTION   (((float) VIEWPORT_WIDTH) / ((float) VIEWPORT_HEIGHT)) /** To see the walls square */
 
#define FLOOR_CORRECTION   ((VIEWPORT_WIDTH / 2.0) - 4) /** The floor (and also the ceiling) stops sliding with this one */
 
#define CEILEING_CORRECTION   (8.0 / get_actual_resolution()) /** The ceiling stops covering the walls */
 

Functions

void render_line (const ray_t ray)
 

Macro Definition Documentation

◆ CEILEING_CORRECTION

#define CEILEING_CORRECTION   (8.0 / get_actual_resolution()) /** The ceiling stops covering the walls */

◆ DISTANCE_CORRECTION

#define DISTANCE_CORRECTION   (((float) VIEWPORT_WIDTH) / ((float) VIEWPORT_HEIGHT)) /** To see the walls square */

◆ FLOOR_CORRECTION

#define FLOOR_CORRECTION   ((VIEWPORT_WIDTH / 2.0) - 4) /** The floor (and also the ceiling) stops sliding with this one */

◆ LINES_WIDTH

#define LINES_WIDTH   ((int) (VIEWPORT_WIDTH / get_ammount_of_rays())) /** Ammount of pixels each ray will draw on screen */

◆ MAX_WALL_HEIGHT

#define MAX_WALL_HEIGHT   (VIEWPORT_HEIGHT) /** A rename for VIEWPORT_HEIGHT, for easier code reading */

◆ RENDER_CHUNK_SIZE

#define RENDER_CHUNK_SIZE   (4) /** How many blocks away can the camera see */

◆ RENDER_DISTANCE

#define RENDER_DISTANCE   (MAP_CELL_SIZE * RENDER_CHUNK_SIZE) /** Distance between the camera and the further object visible */

◆ X_CORRECTION

#define X_CORRECTION   (LINES_WIDTH / 2.0) /** Correction for X axis to get the screen centered */

◆ Y_CORRECTION

#define Y_CORRECTION   (VIEWPORT_HEIGHT / 2.0) /** Correction for Y axis to get the screen centered */

Function Documentation

◆ render_line()

void render_line ( const ray_t  ray)

Render a vertical line in the window, using the info from ray

Parameters
rayA ray_t type, with the info of the wall, floor and ceiling to render