Skip to content

Commit 52a5807

Browse files
authored
Merge pull request #3 from lareii/rewrite
rewrite.
2 parents 68b2e7a + 4b86c89 commit 52a5807

File tree

126 files changed

+1663
-8822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1663
-8822
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,7 @@ Mkfile.old
5252
dkms.conf
5353

5454
# Editor settings
55-
.vscode/
55+
.vscode/
56+
57+
# Directories
58+
build/

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/minilibx-linux"]
2+
path = lib/minilibx-linux
3+
url = https://github.com/42Paris/minilibx-linux.git

Makefile

+39-31
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,61 @@
1-
NAME = fdf
2-
3-
INC_DIR = inc
4-
LIB_DIR = lib
5-
LIBFT_DIR = $(LIB_DIR)/libft
6-
MLX_DIR = $(LIB_DIR)/minilibx
7-
LIBFT = $(LIBFT_DIR)/libft.a
8-
MLX = $(MLX_DIR)/libmlx.a
9-
BUILD_DIR = build
10-
11-
SRCS = fdf.c window_management.c read_map.c libft_extra.c point_utils.c
12-
OBJS = $(addprefix $(BUILD_DIR)/,$(SRCS:.c=.o))
13-
CFLAGS = -Wall -Wextra -Werror -I$(INC_DIR) -I$(LIBFT_DIR) -I$(MLX_DIR)
14-
LDFLAGS = -L$(LIBFT_DIR) -L$(MLX_DIR)
15-
LDLIBS = -lmlx -lft -lXext -lX11 -lm
16-
17-
RM = rm -rf
1+
NAME = fdf
2+
NAME_BONUS = fdf_bonus
3+
4+
INC_DIR = inc
5+
LIB_DIR = lib
6+
SRC_DIR = src
7+
BUILD_DIR = build
8+
9+
LIBFT_DIR = $(LIB_DIR)/libft
10+
MLX_DIR = $(LIB_DIR)/minilibx-linux
11+
LIBFT = $(LIBFT_DIR)/libft.a
12+
MLX = $(MLX_DIR)/libmlx.a
13+
14+
VPATH = src:src/map:src/render:src/window
15+
SRCS = fdf.c utils.c \
16+
init_map.c parse_map.c read_map.c \
17+
init_renderer.c render_map.c render_utils.c transformations.c \
18+
init_win.c win_hooks.c win_utils.c
19+
BONUS_SRCS = $(SRCS:.c=_bonus.c)
20+
OBJS = $(addprefix $(BUILD_DIR)/,$(SRCS:.c=.o))
21+
BONUS_OBJS = $(addprefix $(BUILD_DIR)/,$(BONUS_SRCS:.c=.o))
22+
23+
CFLAGS = -Wall -Wextra -Werror -I$(INC_DIR) -I$(LIBFT_DIR) -I$(MLX_DIR)
24+
LDFLAGS = -L$(LIBFT_DIR) -L$(MLX_DIR)
25+
LDLIBS = -lm -lmlx -lft -lX11 -lXext
26+
RM = rm -rf
1827

1928
all: $(NAME)
2029

21-
debug: $(OBJS) $(LIBFT) $(MLX)
22-
$(CC) -g $(CFLAGS) $(OBJS) -o $(NAME) $(LDFLAGS) $(LDLIBS)
23-
24-
$(NAME): $(OBJS) $(LIBFT) $(MLX)
25-
$(CC) $(CFLAGS) $(OBJS) -o $(NAME) $(LDFLAGS) $(LDLIBS)
30+
$(LIBFT):
31+
@make -C $(LIBFT_DIR)
2632

27-
%o: %c
28-
$(CC) -g $(CFLAGS) -c $< -o $@
33+
$(MLX):
34+
@make -C $(MLX_DIR)
2935

3036
$(BUILD_DIR):
3137
mkdir -p $@
3238

3339
$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR)
3440
$(CC) $(CFLAGS) -c $^ -o $@
3541

36-
$(LIBFT):
37-
@make -C $(LIBFT_DIR)
42+
$(NAME): $(OBJS) $(LIBFT) $(MLX)
43+
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $(NAME)
3844

39-
$(MLX):
40-
@make -C $(MLX_DIR)
45+
$(NAME_BONUS): $(BONUS_OBJS) $(LIBFT) $(MLX)
46+
$(CC) $(CFLAGS) $(BONUS_OBJS) $(LDFLAGS) $(LDLIBS) -o $(NAME_BONUS)
47+
48+
bonus: $(NAME_BONUS)
4149

4250
clean:
4351
$(RM) $(BUILD_DIR)
4452
@make -C $(LIBFT_DIR) clean
4553
@make -C $(MLX_DIR) clean
4654

4755
fclean: clean
48-
$(RM) $(NAME)
56+
$(RM) $(NAME) $(NAME_BONUS)
4957
@make -C $(LIBFT_DIR) fclean
5058

51-
re: fclean all
59+
re: fclean all
5260

53-
.PHONY: all clean fclean re
61+
.PHONY: all bonus clean fclean re

draw_line.c

Whitespace-only changes.

fdf.c

-117
This file was deleted.

inc/fdf.h

+53-29
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,79 @@
33
/* ::: :::::::: */
44
/* fdf.h :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: obastug <obastug@student.42.fr> +#+ +:+ +#+ */
6+
/* By: ebabaogl <ebabaogl@student.42kocaeli.co +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
8-
/* Created: 2025/01/02 11:39:37 by ebabaogl #+# #+# */
9-
/* Updated: 2025/01/07 12:47:31 by obastug ### ########.fr */
8+
/* Created: 2025/01/12 22:28:32 by ebabaogl #+# #+# */
9+
/* Updated: 2025/01/14 00:28:20 by ebabaogl ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#ifndef FDF_H
1414
# define FDF_H
1515

16-
#define BUFFER_SIZE 30
17-
#define COLOR_MASK 4294967295U
18-
#define DEFAULT_COLOR 0x00FFFFFF
16+
# include "window.h"
17+
# include <stddef.h>
1918

20-
#include "window.h"
21-
#include <stddef.h>
19+
# define BUFFER_SIZE 99999
2220

21+
# define COLOR_MASK 4294967295U
22+
# define LINE_COLOR 0x00D4D4D8
23+
# define BG_COLOR 0x0009090B
2324

24-
typedef struct s_vars
25+
typedef struct s_vars
2526
{
2627
t_mlx *mlx;
28+
2729
unsigned long **map;
28-
int height;
30+
int col_size;
31+
int row_size;
32+
33+
int anchor_x;
34+
int anchor_y;
2935
int map_x;
3036
int map_y;
31-
int w_coef;
32-
int s_coef;
33-
int a_coef;
34-
int d_coef;
37+
3538
double distance;
36-
int line_count;
37-
int line_len;
38-
int anchor_x;
39-
int anchor_y;
39+
double height;
40+
double zoom;
41+
double x_y_coef;
42+
double y_z_coef;
43+
double z_x_coef;
4044
} t_vars;
4145

42-
char *read_file(char *file_name);
43-
int init_win(t_mlx *mlx);
44-
unsigned int ft_atoi_hex(char *str);
45-
unsigned long point_to_ulong(char *point);
46-
unsigned long **map_string_to_arr_2d(char *whole_file);
47-
size_t ft_ptrarrlen(unsigned long *arr);
46+
typedef struct s_point
47+
{
48+
int x;
49+
int y;
50+
int z;
51+
} t_point;
4852

49-
unsigned long get_color(unsigned long);
50-
unsigned long get_z(unsigned long point);
53+
int init_map(t_vars *vars, char *filename);
54+
char *get_raw_map(char *filename);
55+
unsigned long **split_raw_map(char *raw_map);
5156

57+
void init_renderer(t_vars *vars);
5258
void render_map(t_vars *vars);
59+
void set_camera_props(t_vars *vars);
60+
void set_point(t_point *point, int x, int y, int z);
61+
void render_point(t_vars *vars, t_point *point);
62+
void zoom(t_vars *vars, t_point *point);
63+
void translate(t_vars *vars, t_point *point);
64+
void rotate_z_x(t_vars *vars, t_point *point);
65+
void rotate_y_z(t_vars *vars, t_point *point);
66+
void rotate_x_y(t_vars *vars, t_point *point);
67+
68+
void draw_background(t_vars *vars);
69+
int init_win(t_vars *vars);
70+
void destroy_win(t_mlx *mlx);
71+
int destroy_handler(t_mlx *mlx);
72+
int key_handler(int keycode, t_mlx *mlx);
73+
74+
void free_str_arr(char **arr);
75+
void free_ulong_arr(unsigned long **arr);
76+
unsigned long get_z(unsigned long point);
77+
unsigned long get_color(unsigned long point);
78+
unsigned int atoi_hex(char *str);
79+
int abs(int n);
5380

54-
int key_handler(int keycode, void *param);
55-
int close_win(void *param);
56-
void reset_camera(t_vars *vars);
5781
#endif

0 commit comments

Comments
 (0)