reorganize file content
This commit is contained in:
parent
878de1098b
commit
47a6b6df35
34 changed files with 358 additions and 288 deletions
|
|
@ -1,18 +1,18 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* color.c :+: :+: :+: */
|
||||
/* global.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 17:04:56 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/15 16:26:52 by mcolonna ### ########.fr */
|
||||
/* Created: 2024/10/01 16:24:58 by grobledo #+# #+# */
|
||||
/* Updated: 2024/10/31 17:20:56 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "map.h"
|
||||
#include "global.h"
|
||||
|
||||
t_color color_from_rgb(int red, int green, int blue)
|
||||
{
|
||||
return (red << 16 | green << 8 | blue);
|
||||
}
|
||||
void *g_mlx = NULL;
|
||||
void *g_win = NULL;
|
||||
t_map g_map;
|
||||
t_player g_player;
|
||||
|
|
@ -3,16 +3,14 @@
|
|||
/* ::: :::::::: */
|
||||
/* input.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/17 14:43:36 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/17 16:05:50 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:21:00 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "input.h"
|
||||
#include <X11/keysym.h>
|
||||
#include "algo.h"
|
||||
|
||||
t_input_actions g_input_actions;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,22 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* algo.c :+: :+: :+: */
|
||||
/* main.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 16:24:58 by grobledo #+# #+# */
|
||||
/* Updated: 2024/10/31 15:26:48 by mc ### ########.fr */
|
||||
/* Created: 2024/10/31 16:57:40 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:55:18 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "algo.h"
|
||||
#include "input.h"
|
||||
#include <stdio.h>
|
||||
#include "main.h"
|
||||
|
||||
void *g_mlx = NULL;
|
||||
void *g_win = NULL;
|
||||
t_map g_map;
|
||||
t_player g_player;
|
||||
// t_tex g_tex;
|
||||
# include "render.h"
|
||||
# include "move.h"
|
||||
# include "input.h"
|
||||
# include "const.h"
|
||||
# include "global.h"
|
||||
|
||||
static void load_textures(t_tex *tex)
|
||||
{
|
||||
|
|
@ -34,7 +32,7 @@ static void load_textures(t_tex *tex)
|
|||
&tex->tex_width, &tex->tex_height);
|
||||
}
|
||||
|
||||
void draw_screen(void)
|
||||
static void draw_screen(void)
|
||||
{
|
||||
void *img_ptr;
|
||||
u_int32_t *img_data;
|
||||
|
|
@ -68,8 +66,6 @@ static int loop_hook(void *param)
|
|||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
g_mlx = mlx_init();
|
||||
23
src/map1.c
23
src/map1.c
|
|
@ -3,23 +3,28 @@
|
|||
/* ::: :::::::: */
|
||||
/* map1.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 17:12:58 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/15 17:22:53 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:56:25 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "map.h"
|
||||
#include "map_utils.h"
|
||||
|
||||
#include "stream.h"
|
||||
#include "read_all_text.h"
|
||||
#include "libft.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "player.h"
|
||||
|
||||
const t_map_mapping_element g_map_mapping[] = {
|
||||
{' ', {false, EMPTY, {NULL, NULL, NULL, NULL}}},
|
||||
{'0', {true, EMPTY, {NULL, NULL, NULL, NULL}}},
|
||||
{'1', {true, WALL, {NULL, NULL, NULL, NULL}}},
|
||||
{'N', {true, EMPTY, {init_player_n, NULL, NULL, NULL}}},
|
||||
{'S', {true, EMPTY, {init_player_s, NULL, NULL, NULL}}},
|
||||
{'E', {true, EMPTY, {init_player_e, NULL, NULL, NULL}}},
|
||||
{'W', {true, EMPTY, {init_player_w, NULL, NULL, NULL}}},
|
||||
{'\0', {true, EMPTY, {NULL, NULL, NULL, NULL}}}};
|
||||
|
||||
static bool map_from_file2(t_map *dest, t_stream *stream, int fd)
|
||||
{
|
||||
|
|
|
|||
12
src/map2.c
12
src/map2.c
|
|
@ -3,23 +3,15 @@
|
|||
/* ::: :::::::: */
|
||||
/* map2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 17:12:58 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/15 16:44:40 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:51:49 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "map.h"
|
||||
#include "map_utils.h"
|
||||
#include "stream.h"
|
||||
#include "read_all_text.h"
|
||||
#include "libft.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const t_map_case *map_get_case(const t_map *map, int x, int y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* map_mapping.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/04 12:05:21 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/15 17:19:26 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "map_mapping.h"
|
||||
#include "player.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
const t_map_mapping_element g_map_mapping[] = {
|
||||
{' ', {false, EMPTY, {NULL, NULL, NULL, NULL}}},
|
||||
{'0', {true, EMPTY, {NULL, NULL, NULL, NULL}}},
|
||||
{'1', {true, WALL, {NULL, NULL, NULL, NULL}}},
|
||||
{'N', {true, EMPTY, {init_player_n, NULL, NULL, NULL}}},
|
||||
{'S', {true, EMPTY, {init_player_s, NULL, NULL, NULL}}},
|
||||
{'E', {true, EMPTY, {init_player_e, NULL, NULL, NULL}}},
|
||||
{'W', {true, EMPTY, {init_player_w, NULL, NULL, NULL}}},
|
||||
{'\0', {true, EMPTY, {NULL, NULL, NULL, NULL}}}};
|
||||
77
src/map_utils.h
Normal file
77
src/map_utils.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* map_utils.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/03 15:05:13 by mc #+# #+# */
|
||||
/* Updated: 2024/10/31 17:56:54 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAP_UTILS_H
|
||||
# define MAP_UTILS_H
|
||||
|
||||
# include "map.h"
|
||||
|
||||
# include "stream.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
|
||||
|
|
@ -3,17 +3,14 @@
|
|||
/* ::: :::::::: */
|
||||
/* map_utils1.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/03 15:02:09 by mc #+# #+# */
|
||||
/* Updated: 2024/10/17 17:59:05 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:21:36 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "map_utils.h"
|
||||
#include "map.h"
|
||||
#include "map_mapping.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
bool read_color_parameter(const char *name, t_color *dest,
|
||||
t_stream *stream, bool *redefined)
|
||||
|
|
|
|||
|
|
@ -3,17 +3,14 @@
|
|||
/* ::: :::::::: */
|
||||
/* map_utils2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/04 15:12:08 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/15 16:27:41 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:21:44 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "map_utils.h"
|
||||
#include "map_mapping.h"
|
||||
#include "map.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/// @brief Read the map description to get the dimensions.
|
||||
/// The map must be at least 1x1.
|
||||
|
|
|
|||
11
src/move.c
11
src/move.c
|
|
@ -3,14 +3,19 @@
|
|||
/* ::: :::::::: */
|
||||
/* move.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 12:47:34 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/17 15:06:43 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:58:27 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "algo.h"
|
||||
#include "move.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "map.h"
|
||||
#include "global.h"
|
||||
#include "const.h"
|
||||
#include "input.h"
|
||||
|
||||
static void push_from_wall(t_point_int c)
|
||||
|
|
|
|||
|
|
@ -3,16 +3,17 @@
|
|||
/* ::: :::::::: */
|
||||
/* player.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 17:33:11 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/15 17:38:27 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:59:13 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "player.h"
|
||||
#include "utils.h"
|
||||
#include "algo.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "const.h"
|
||||
|
||||
static void init_player(t_point_int pos, double rot)
|
||||
{
|
||||
|
|
|
|||
11
src/render.c
11
src/render.c
|
|
@ -3,15 +3,18 @@
|
|||
/* ::: :::::::: */
|
||||
/* render.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: grobledo <grobledo@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/14 14:55:05 by greg #+# #+# */
|
||||
/* Updated: 2024/10/24 14:27:52 by grobledo ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:02:59 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "algo.h"
|
||||
#include <stdio.h>
|
||||
#include "render.h"
|
||||
#include "render_utils.h"
|
||||
|
||||
#include "const.h"
|
||||
#include "global.h"
|
||||
|
||||
static void calculate_perpwalldist3(int x,
|
||||
t_point_double *deltadist,
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* render2.c :+: :+: :+: */
|
||||
/* render_utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: grobledo <grobledo@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/24 14:26:22 by grobledo #+# #+# */
|
||||
/* Updated: 2024/10/24 14:27:37 by grobledo ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:02:20 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "algo.h"
|
||||
#include "render_utils.h"
|
||||
|
||||
#include "const.h"
|
||||
#include "global.h"
|
||||
|
||||
void ft_init_texture(const double perpwalldist, t_ray *ray, t_tex *tex)
|
||||
{
|
||||
|
|
@ -48,4 +51,4 @@ void draw_wall(t_tex *tex, t_ray *ray, const int line_height, int x,
|
|||
&tex->bpp, &tex->size_line, &tex->endian);
|
||||
color = texture_data[tex->tex_x * tex->tex_width + tex->tex_y];
|
||||
img_data[y * SCREEN_WIDTH + x] = color;
|
||||
}
|
||||
}
|
||||
23
src/render_utils.h
Normal file
23
src/render_utils.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* render_utils.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/24 14:26:22 by grobledo #+# #+# */
|
||||
/* Updated: 2024/10/31 18:01:59 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RENDER_UTILS_H
|
||||
# define RENDER_UTILS_H
|
||||
|
||||
# include "render.h"
|
||||
|
||||
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
|
||||
|
|
@ -3,15 +3,14 @@
|
|||
/* ::: :::::::: */
|
||||
/* stream.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/02 14:08:10 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/17 16:02:33 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:25:23 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "stream.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void read_expected_string(const char *str, t_stream *stream, bool *err)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,15 +3,14 @@
|
|||
/* ::: :::::::: */
|
||||
/* utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/15 12:38:40 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/17 16:36:14 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:25:30 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "algo.h"
|
||||
#include <stdarg.h>
|
||||
#include "utils.h"
|
||||
|
||||
void vector_from_rotation(t_point_double *vec, double angle, double norm)
|
||||
{
|
||||
|
|
|
|||
10
src/utils2.c
10
src/utils2.c
|
|
@ -3,15 +3,14 @@
|
|||
/* ::: :::::::: */
|
||||
/* utils2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/29 14:02:37 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/29 14:12:14 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:25:34 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "utils.h"
|
||||
#include "mlx.h"
|
||||
|
||||
u_int32_t *get_data_addr(void *img_ptr)
|
||||
{
|
||||
|
|
@ -29,3 +28,8 @@ u_int32_t *get_data_addr(void *img_ptr)
|
|||
}
|
||||
return (r);
|
||||
}
|
||||
|
||||
t_color color_from_rgb(int red, int green, int blue)
|
||||
{
|
||||
return (red << 16 | green << 8 | blue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,16 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* read_all_text.c :+: :+: :+: */
|
||||
/* utils3.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: mc <mc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/02 16:18:35 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/10/15 16:28:22 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:25:53 by mc ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "read_all_text.h"
|
||||
#include "map.h"
|
||||
#include "libft.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include "utils.h"
|
||||
|
||||
/// @brief Concatenate *dest and src and put the result in *dest.
|
||||
///
|
||||
|
|
@ -73,7 +68,7 @@ static char *add_endline_if_necessary(char *str)
|
|||
|
||||
char *read_all_text(int fd)
|
||||
{
|
||||
char buf[BUFFER_SIZE];
|
||||
char buf[READ_ALL_TEXT_BUFFER_SIZE];
|
||||
int n;
|
||||
char *r;
|
||||
|
||||
|
|
@ -84,7 +79,7 @@ char *read_all_text(int fd)
|
|||
n = 1;
|
||||
while (n)
|
||||
{
|
||||
n = read(fd, buf, BUFFER_SIZE);
|
||||
n = read(fd, buf, READ_ALL_TEXT_BUFFER_SIZE);
|
||||
if (n < 0 || (n && !strconcat(&r, buf, n)))
|
||||
{
|
||||
free(r);
|
||||
Loading…
Add table
Add a link
Reference in a new issue