reorganize file content
This commit is contained in:
parent
878de1098b
commit
47a6b6df35
34 changed files with 358 additions and 288 deletions
|
|
@ -1,90 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* algo.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/30 15:45:59 by grobledo #+# #+# */
|
||||
/* Updated: 2024/10/31 16:03:42 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ALGO_H
|
||||
# define ALGO_H
|
||||
|
||||
# include <unistd.h>
|
||||
# include <math.h>
|
||||
# include <linux/types.h>
|
||||
# include <stdbool.h>
|
||||
# include <stdlib.h>
|
||||
# include <X11/X.h>
|
||||
# include "mlx.h"
|
||||
# include "libft.h"
|
||||
|
||||
# include "stream.h"
|
||||
# include "read_all_text.h"
|
||||
# include "map.h"
|
||||
# include "map_mapping.h"
|
||||
|
||||
# define MAP_WIDTH 24 // cases (TODO test)
|
||||
# define MAP_HEIGHT 24 // cases (TODO test)
|
||||
# define TEX_WIDTH 64
|
||||
# define TEX_HEIGHT 64
|
||||
# define MOVE_SPEED 0.05 // cases
|
||||
# define PI 3.1415926535
|
||||
# define ROT_SPEED_DIVIDE_PI 64 // pi/n rad
|
||||
# define COLOR_WALL 0xFF0000 // 0xRRGGBB
|
||||
# define COLOR_CEILING 0x29f8ff // 0xRRGGBB
|
||||
# define COLOR_FLOOR 0xFF985C // 0xRRGGBB
|
||||
# define SCREEN_WIDTH 640 // px
|
||||
# define SCREEN_HEIGHT 480 // px
|
||||
# define FOV 0.66 // ? TODO unit
|
||||
# define HITBOX 0.25 // cases. should be more than MOVE_SPEED
|
||||
|
||||
typedef struct s_tex
|
||||
{
|
||||
void *textures[4];
|
||||
void *current_tex;
|
||||
int tex_height;
|
||||
int tex_width;
|
||||
int tex_dir;
|
||||
int tex_x;
|
||||
int tex_y;
|
||||
int bpp;
|
||||
int size_line;
|
||||
int endian;
|
||||
} t_tex;
|
||||
|
||||
typedef struct s_ray
|
||||
{
|
||||
// pos player on map (cases)
|
||||
t_point_double dir;
|
||||
bool side;
|
||||
double wallx;
|
||||
} t_ray;
|
||||
|
||||
extern void *g_mlx;
|
||||
extern void *g_win;
|
||||
extern t_player g_player;
|
||||
extern t_map g_map;
|
||||
// extern t_tex g_tex;
|
||||
|
||||
/// @brief Write an error message on stderr.
|
||||
///
|
||||
/// @param str... All the strings to write. The last parameter MUST BE NULL.
|
||||
void write_err(const char *str, ...);
|
||||
|
||||
void vector_from_rotation(t_point_double *vec, double angle, double norm);
|
||||
|
||||
int render(u_int32_t *img_data, t_tex *tex);
|
||||
|
||||
void draw_screen(void);
|
||||
|
||||
void move(void);
|
||||
|
||||
void ft_init_texture(const double perpwalldist, t_ray *ray, t_tex *tex);
|
||||
|
||||
void draw_wall(t_tex *tex, t_ray *ray, const int line_height, int x,
|
||||
int y, u_int32_t *img_data);
|
||||
#endif
|
||||
31
include/const.h
Normal file
31
include/const.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* const.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 17:00:59 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:06:00 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CONST_H
|
||||
# define CONST_H
|
||||
|
||||
# include "include.h"
|
||||
|
||||
# define MAP_WIDTH 24 // cases (TODO test)
|
||||
# define MAP_HEIGHT 24 // cases (TODO test)
|
||||
# define MOVE_SPEED 0.05 // cases
|
||||
# define PI 3.1415926535
|
||||
# define ROT_SPEED_DIVIDE_PI 64 // pi/n rad
|
||||
# define COLOR_WALL 0xFF0000 // 0xRRGGBB
|
||||
# define COLOR_CEILING 0x29f8ff // 0xRRGGBB
|
||||
# define COLOR_FLOOR 0xFF985C // 0xRRGGBB
|
||||
# define SCREEN_WIDTH 640 // px
|
||||
# define SCREEN_HEIGHT 480 // px
|
||||
# define FOV 0.66 // ? TODO unit
|
||||
# define HITBOX 0.25 // cases. should be more than MOVE_SPEED
|
||||
|
||||
#endif
|
||||
25
include/global.h
Normal file
25
include/global.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* global.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 17:06:31 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:29:00 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef GLOBAL_H
|
||||
# define GLOBAL_H
|
||||
|
||||
# include "include.h"
|
||||
|
||||
# include "map.h"
|
||||
|
||||
extern void *g_mlx;
|
||||
extern void *g_win;
|
||||
extern t_player g_player;
|
||||
extern t_map g_map;
|
||||
|
||||
#endif
|
||||
33
include/include.h
Normal file
33
include/include.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* include.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 16:22:09 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 18:03:26 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef INCLUDE_H
|
||||
# define INCLUDE_H
|
||||
|
||||
# include <errno.h>
|
||||
# include <fcntl.h>
|
||||
# include <linux/types.h>
|
||||
# include <math.h>
|
||||
# include <stdarg.h>
|
||||
# include <stdbool.h>
|
||||
# include <stdint.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <unistd.h>
|
||||
# include <X11/keysym.h>
|
||||
# include <X11/X.h>
|
||||
|
||||
# include "libft.h"
|
||||
# include "mlx.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -3,17 +3,17 @@
|
|||
/* ::: :::::::: */
|
||||
/* input.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/17 14:43:09 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/17 14:59:41 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 16:24:16 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef INPUT_H
|
||||
# define INPUT_H
|
||||
|
||||
# include <stdbool.h>
|
||||
# include "include.h"
|
||||
|
||||
/// @brief Modified by the input of the user. A value becomes true
|
||||
/// when the user presses the corresponding key.
|
||||
|
|
|
|||
18
include/main.h
Normal file
18
include/main.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 17:19:59 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:55:11 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAIN_H
|
||||
# define MAIN_H
|
||||
|
||||
# include "include.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -6,14 +6,15 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 13:59:04 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/31 15:57:58 by mc ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:55:39 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAP_H
|
||||
# define MAP_H
|
||||
|
||||
# include <stdbool.h>
|
||||
# include "include.h"
|
||||
|
||||
# include "utils.h"
|
||||
|
||||
/// @brief The type of a case.
|
||||
|
|
@ -61,6 +62,19 @@ typedef struct s_map_case
|
|||
t_object object;
|
||||
} t_map_case;
|
||||
|
||||
/// @brief Each element of g_map_mapping. A case and its associated char.
|
||||
typedef struct s_map_mapping_element
|
||||
{
|
||||
/// @brief char representing the case.
|
||||
char name;
|
||||
/// @brief associated case.
|
||||
t_map_case value;
|
||||
} t_map_mapping_element;
|
||||
|
||||
/// @brief List of each char and its according case.
|
||||
/// Ended by an element with the name '\0'.
|
||||
extern const t_map_mapping_element g_map_mapping[];
|
||||
|
||||
typedef struct s_player
|
||||
{
|
||||
// pos player on map (cases)
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* map_mapping.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/04 12:00:07 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/04 15:24:14 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAP_MAPPING_H
|
||||
# define MAP_MAPPING_H
|
||||
|
||||
# include "map.h"
|
||||
|
||||
/// @brief Each element of g_map_mapping. A case and its associated char.
|
||||
typedef struct s_map_mapping_element
|
||||
{
|
||||
/// @brief char representing the case.
|
||||
char name;
|
||||
/// @brief associated case.
|
||||
t_map_case value;
|
||||
} t_map_mapping_element;
|
||||
|
||||
/// @brief List of each char and its according case.
|
||||
/// Ended by an element with the name '\0'.
|
||||
extern const t_map_mapping_element g_map_mapping[];
|
||||
|
||||
#endif
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* map_utils.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/03 15:05:13 by mc #+# #+# */
|
||||
/* Updated: 2024/10/17 17:58:23 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAP_UTILS_H
|
||||
# define MAP_UTILS_H
|
||||
|
||||
# include "stream.h"
|
||||
# include "map.h"
|
||||
# include <stdbool.h>
|
||||
# include <stddef.h>
|
||||
|
||||
/// @brief Read a parameter of the map which has a color as an argument.
|
||||
/// Color format: [0-255],[0-255],[0-255]
|
||||
/// @param name Name of the parameter.
|
||||
/// @param dest Will be set to the value of the parameter.
|
||||
/// Unchanged if error.
|
||||
/// If success but *dest is not 0xFF000000, throws an error.
|
||||
/// @param stream Stream to use.
|
||||
/// Unchanged if error.
|
||||
/// @param redefined Set to true if the parameter was already defined.
|
||||
/// @return true if success or redefined, false if non-fatal error.
|
||||
bool read_color_parameter(const char *name, t_color *dest,
|
||||
t_stream *stream, bool *redefined);
|
||||
|
||||
/// @brief Read a parameter of the map which has a string as an argument.
|
||||
/// @param name Name of the parameter.
|
||||
/// @param dest Will be set to an alloc'd pointer to the value of the parameter.
|
||||
/// Unchanged if error.
|
||||
/// If success but *dest is not null, throws an error.
|
||||
/// @param stream Stream to use.
|
||||
/// Unchanged if error.
|
||||
/// @param redefined Set to true if the parameter was already defined.
|
||||
/// @return true if success or redefined, false if non-fatal error.
|
||||
bool read_string_parameter(const char *name, const char **dest,
|
||||
t_stream *stream, bool *redefined);
|
||||
|
||||
/// @brief Read a map-formatted string.
|
||||
/// If an error occurs, write an error message on stderr.
|
||||
/// @param dest Will be set to the map.
|
||||
/// @param stream Stream to use.
|
||||
/// @return true if success, false if error.
|
||||
bool read_map(t_map *dest, t_stream *stream);
|
||||
|
||||
/// @brief Get the case associated with the char.
|
||||
///
|
||||
/// @param dest Will be set to the char.
|
||||
/// @param name Name of the case.
|
||||
/// @return true if success, false if error.
|
||||
bool get_case(t_map_case *dest, char name);
|
||||
|
||||
/// @brief Fill the pointer with 'size' null bytes.
|
||||
///
|
||||
/// @param dest The pointer to set.
|
||||
/// @param size The number of bytes.
|
||||
void fill_zeros(void *dest, size_t size);
|
||||
|
||||
/// @brief Read the map description part of the map.
|
||||
/// Read until the end of the file.
|
||||
///
|
||||
/// @param map The .width, .height and .cases members will be set.
|
||||
/// @param stream Stream to use.
|
||||
/// @return true if success, false if error.
|
||||
bool read_map_description(t_map *map, t_stream *stream);
|
||||
|
||||
/// @brief Initialize all objects of the map.
|
||||
/// @param map Map to use.
|
||||
void map_init_objects(t_map *map);
|
||||
|
||||
#endif
|
||||
20
include/move.h
Normal file
20
include/move.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* move.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 16:59:27 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 16:59:48 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MOVE_H
|
||||
# define MOVE_H
|
||||
|
||||
# include "include.h"
|
||||
|
||||
void move(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -3,16 +3,18 @@
|
|||
/* ::: :::::::: */
|
||||
/* player.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 17:31:35 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/15 17:43:52 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:30:01 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PLAYER_H
|
||||
# define PLAYER_H
|
||||
|
||||
# include "include.h"
|
||||
|
||||
# include "utils.h"
|
||||
|
||||
void init_player_n(void **data, t_point_int pos);
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* read_all_text.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/02 15:39:02 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/02 17:04:33 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef READ_ALL_TEXT_H
|
||||
# define READ_ALL_TEXT_H
|
||||
|
||||
/// @brief Size of buffer used in read_all_text().
|
||||
# define BUFFER_SIZE 1000
|
||||
|
||||
/// @brief Read all the text of the given file.
|
||||
///
|
||||
/// If the last line isn't ended by a '\\n', add one.
|
||||
///
|
||||
/// If error, returns NULL and set errno accordingly.
|
||||
///
|
||||
/// @param fd File descriptor of the file.
|
||||
/// @return Alloc'd string of the file content. NULL if error.
|
||||
char *read_all_text(int fd);
|
||||
|
||||
#endif
|
||||
23
include/render.h
Normal file
23
include/render.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* render.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 17:13:20 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:27:33 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RENDER_H
|
||||
# define RENDER_H
|
||||
|
||||
# include "include.h"
|
||||
|
||||
# include "utils.h"
|
||||
# include "temp.h"
|
||||
|
||||
int render(u_int32_t *img_data, t_tex *tex);
|
||||
|
||||
#endif
|
||||
|
|
@ -3,17 +3,17 @@
|
|||
/* ::: :::::::: */
|
||||
/* stream.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/02 12:33:25 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/17 15:57:59 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 16:25:10 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef STREAM_H
|
||||
# define STREAM_H
|
||||
|
||||
# include <stdbool.h>
|
||||
# include "include.h"
|
||||
|
||||
/// @brief Represents a string and an associated cursor.
|
||||
typedef struct s_stream
|
||||
|
|
|
|||
47
include/temp.h
Normal file
47
include/temp.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* temp.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 17:04:08 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:28:09 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
// DEBUG remove temp.h
|
||||
|
||||
#ifndef TEMP_H
|
||||
# define TEMP_H
|
||||
|
||||
# include "include.h"
|
||||
|
||||
# include "utils.h"
|
||||
|
||||
# define TEX_WIDTH 64
|
||||
# define TEX_HEIGHT 64
|
||||
|
||||
typedef struct s_tex
|
||||
{
|
||||
void *textures[4];
|
||||
void *current_tex;
|
||||
int tex_height;
|
||||
int tex_width;
|
||||
int tex_dir;
|
||||
int tex_x;
|
||||
int tex_y;
|
||||
int bpp;
|
||||
int size_line;
|
||||
int endian;
|
||||
} t_tex;
|
||||
|
||||
typedef struct s_ray
|
||||
{
|
||||
// pos player on map (cases)
|
||||
t_point_double dir;
|
||||
bool side;
|
||||
double wallx;
|
||||
} t_ray;
|
||||
|
||||
#endif
|
||||
|
|
@ -6,16 +6,14 @@
|
|||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 16:56:47 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/31 15:31:21 by mc ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:15:31 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef UTILS_H
|
||||
# define UTILS_H
|
||||
|
||||
# include <linux/types.h>
|
||||
# include <stdint.h>
|
||||
# include <stddef.h>
|
||||
# include "include.h"
|
||||
|
||||
typedef uint32_t u_int32_t;
|
||||
|
||||
|
|
@ -43,6 +41,9 @@ typedef __u32 t_color;
|
|||
/// @return The result.
|
||||
t_color color_from_rgb(int red, int green, int blue);
|
||||
|
||||
/// @brief Write an error message on stderr.
|
||||
///
|
||||
/// @param str... All the strings to write. The last parameter MUST BE NULL.
|
||||
void write_err(const char *str, ...);
|
||||
|
||||
/// @brief Call the function in loop.
|
||||
|
|
@ -59,4 +60,19 @@ void timedloop(void (*f)(void));
|
|||
/// @return Address to the data, or NULL if error.
|
||||
u_int32_t *get_data_addr(void *img_ptr);
|
||||
|
||||
void vector_from_rotation(t_point_double *vec, double angle, double norm);
|
||||
|
||||
/// @brief Size of buffer used in read_all_text().
|
||||
# define READ_ALL_TEXT_BUFFER_SIZE 1000
|
||||
|
||||
/// @brief Read all the text of the given file.
|
||||
///
|
||||
/// If the last line isn't ended by a '\\n', add one.
|
||||
///
|
||||
/// If error, returns NULL and set errno accordingly.
|
||||
///
|
||||
/// @param fd File descriptor of the file.
|
||||
/// @return Alloc'd string of the file content. NULL if error.
|
||||
char *read_all_text(int fd);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue