Bring the project closer to compileability
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 22 Nov 2024 11:55:04 +0000 (12:55 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Sat, 23 Nov 2024 11:05:51 +0000 (12:05 +0100)
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...).

Makefile
inc/miniRT.h
src/main.c

index cb2f06855ef2e2b8d90eb6a69120ce88baee07bf..da0a728669acb41b562b510ddacd2c475a7eb593 100644 (file)
--- 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: ;
 
index d2f0fef7a77442d25f911780b9511994667966d2..dfe55ec4d037f0992c76b50061a3f18b809e1dc1 100644 (file)
@@ -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
index a43f1c864247c864245592e14955ba4e5c522fa9..a706b9945f583cd7d80a4b91ba42f0f77697f1cd 100644 (file)
@@ -6,35 +6,6 @@
 #include <limits.h>
 #include <stdlib.h>
 
-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);