From: Lukas Jiriste Date: Fri, 22 Nov 2024 11:55:04 +0000 (+0100) Subject: Bring the project closer to compileability X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=0800cfd62715c61e88ae83e18a6bfea41552f04c;p=42%2FminiRT.git Bring the project closer to compileability Fix Makefile includes and links. Comment line prototypes out of main.c. Rearrange the functions in main.c (I really should just write the declarations into the header file...). --- diff --git a/Makefile b/Makefile index cb2f068..da0a728 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC := gcc CFLAGS = -std=c99 -Wall -Wextra -Werror -Wpedantic -INCGRAPH := minilibx-linux /usr/include Libft/inc +INCGRAPH := minilibx-linux /usr/include LINKGRAPH := -Lminilibx-linux -lmlx -L/usr/lib -lXext -lX11 -lm -lbsd -LLibft -lft ifneq ("$(wildcard .debug)","") @@ -15,7 +15,7 @@ MLX := $(MLXDIR)libmlx_Linux.a LFTDIR := Libft/ LFT := $(LFTDIR)libft.a -INCDIR := inc $(LFTDIR)inc/ $(MLXDIR) +INCDIR := inc $(LFTDIR)inc/ $(INCGRAPH) INCLUDE := $(addprefix -I, $(INCDIR)) SRCDIR := src @@ -45,7 +45,7 @@ nodebug : touch $@ $(NAME) : $(OBJECTS) $(LFT) $(MLX) - $(CC) $(CFLAGS) -o $@ $^ $(LINKS) + $(CC) $(CFLAGS) -o $@ $^ $(LINKGRAPH) FORCE: ; diff --git a/inc/miniRT.h b/inc/miniRT.h index d2f0fef..dfe55ec 100644 --- a/inc/miniRT.h +++ b/inc/miniRT.h @@ -118,9 +118,6 @@ typedef struct s_session t_scene scene; } t_session; -t_ray get_camera_ray(int x, int y, const t_session *session); -double get_intersection_arg_cylinder(const t_ray *ray, - const t_cylinder *cylinder); t_color trace_ray(const t_ray *ray, const t_scene *scene); #endif // MINIRT_H diff --git a/src/main.c b/src/main.c index a43f1c8..a706b99 100644 --- a/src/main.c +++ b/src/main.c @@ -6,35 +6,6 @@ #include #include -int handle_key_press(int keycode, t_session *s) -{ - if (keycode == XK_Escape) - close_win(s); - else if (keycode == XK_Up || keycode == XK_w) - else if (keycode == XK_Left || keycode == XK_a) - else if (keycode == XK_Down || keycode == XK_s) - else if (keycode == XK_Right || keycode == XK_d) - else if (keycode == XK_KP_Add) - else if (keycode == XK_KP_Subtract) - if (keycode != XK_Escape) - draw(s); - return (0); -} - -int handle_mouse_press(int button, int x, int y, t_session *s) -{ - if (button == Button4) - else if (button == Button5) - if (button == Button4 || button == Button5) - draw(s); - return (0); -} - -int no_event_handle(t_session *s) -{ - return (0); -} - void *get_pixel(t_img *img, int x, int y) { return (img->addr + y * img->bpl + x * img->bpp / CHAR_BIT); @@ -112,7 +83,6 @@ void draw(t_session *s) { int x; int y; - double param; t_ray ray; x = 0; @@ -131,6 +101,46 @@ void draw(t_session *s) return ; } +int close_win(t_session *s) +{ + mlx_destroy_window(s->mlx, s->win); + s->win = NULL; + return (0); +} + +int handle_key_press(int keycode, t_session *s) +{ + if (keycode == XK_Escape) + close_win(s); + /* + else if (keycode == XK_Up || keycode == XK_w) + else if (keycode == XK_Left || keycode == XK_a) + else if (keycode == XK_Down || keycode == XK_s) + else if (keycode == XK_Right || keycode == XK_d) + else if (keycode == XK_KP_Add) + else if (keycode == XK_KP_Subtract) + */ + if (keycode != XK_Escape) + draw(s); + return (0); +} + +int handle_mouse_press(int button, __attribute__((unused)) int x, __attribute__((unused)) int y, t_session *s) +{ + /* + if (button == Button4) + else if (button == Button5) + */ + if (button == Button4 || button == Button5) + draw(s); + return (0); +} + +int no_event_handle(__attribute__((unused)) t_session *s) +{ + return (0); +} + void init_session(t_session *s) { s->mlx = mlx_init(); @@ -140,13 +150,6 @@ void init_session(t_session *s) &s->img.bpp, &s->img.bpl, &s->img.endian); } -int close_win(t_session *s) -{ - mlx_destroy_window(s->mlx, s->win); - s->win = NULL; - return (0); -} - static void free_session(t_session *s) { mlx_destroy_display(s->mlx); @@ -167,16 +170,18 @@ void set_defaults(t_session *s) s->img.height = 1011; } -int main(int argc, char **argv) +int main(void) { t_session s; set_defaults(&s); + /* if (parse_args(argc, argv, &s)) { print_help(); return (1); } + */ init_session(&s); mlx_hook(s.win, KeyPress, KeyPressMask, handle_key_press, &s); mlx_hook(s.win, ButtonPress, ButtonPressMask, handle_mouse_press, &s);