diff --git a/includes/cub3d.h b/includes/cub3d.h index 191c01d..a1bfd7a 100644 --- a/includes/cub3d.h +++ b/includes/cub3d.h @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/30 16:30:26 by rparodi #+# #+# */ -/* Updated: 2024/12/16 14:48:17 by bgoulard ### ########.fr */ +/* Updated: 2024/12/16 15:35:29 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,49 +23,47 @@ # include // raycasting -void draw_bg(t_info *data); -void set_step(t_ipoint *step, t_dpoint raydir); -void set_side_dist(t_dpoint *side_dist, t_dpoint *tb, t_ipoint pos_i); +void draw_bg(t_info *data); +void set_step(t_ipoint *step, t_dpoint raydir); +void set_side_dist(t_dpoint *side_dist, t_dpoint *tb, t_ipoint pos_i); t_texture *get_texture(int side, t_ipoint step, t_info *data); -void draw_(int *ti, double *td, t_ipoint step, t_info *data); +void draw_(int *ti, double *td, t_ipoint step, t_info *data); // utils -void draw_floor(t_info *data); -int render_frame(t_info *data); -void my_mlx_pixel_put(t_info *data, int x, int y, int color); -double deg2rad(int deg); -void rotate_plane(t_dpoint *plane, double angle); +void draw_floor(t_info *data); +int render_frame(t_info *data); +void my_mlx_pixel_put(t_info *data, int x, int y, int color); +double deg2rad(int deg); +void rotate_plane(t_dpoint *plane, double angle); // key pressed func -void look_left(t_info *data); -void look_right(t_info *data); -void move_straight(t_info *data); -void move_backward(t_info *data); -void move_left(t_info *data); -void move_right(t_info *data); +void look_left(t_info *data); +void look_right(t_info *data); +void move_straight(t_info *data); +void move_backward(t_info *data); +void move_left(t_info *data); +void move_right(t_info *data); -int keyrelease_feature(int keycode, t_info *data); -int keypress_feature(int keycode, t_info *data); -int displacement_hook(t_info *data); -int get_cl(int side, t_ipoint step); -t_tile *c3_get_cell(t_tile *map, t_ipoint dimensions, t_ipoint pos); +int keyrelease_feature(int keycode, t_info *data); +int keypress_feature(int keycode, t_info *data); +int displacement_hook(t_info *data); +int get_cl(int side, t_ipoint step); +t_tile *c3_get_cell(t_tile *map, t_ipoint dimensions, t_ipoint pos); /// @brief Createsa a blank map for rapahael to test the raycasting /// @note Dev only function. -void blank(t_info *info); +void blank(t_info *info); +int init_mlx_env(t_info *info); +void cleanup_info(t_info *info); -int init_mlx_env(t_info *info); +int c3_options(t_info *info, int argc, char *argv[]); +void c3_perror(t_info *info); +void print_error(const char *msg, int errno_state); -void cleanup_info(t_info *info); +void parse_map(t_info *info); +void parse_args(char *arg, t_info *inf); -int c3_options(t_info *info, int argc, char *argv[]); -void c3_perror(t_info *info); -void print_error(const char *msg, int errno_state); - -void parse_map(t_info *info); -void parse_args(char *arg, t_info *inf); - -int main(int argc, char *argv[]); -int shelves_launch(t_info *info); +int main(int argc, char *argv[]); +int shelves_launch(t_info *info); #endif /* CUB3D_H */ diff --git a/includes/ft_addons.h b/includes/ft_addons.h index 78c7492..c531d3d 100644 --- a/includes/ft_addons.h +++ b/includes/ft_addons.h @@ -6,11 +6,12 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/16 06:09:01 by bgoulard #+# #+# */ -/* Updated: 2024/12/16 09:36:19 by bgoulard ### ########.fr */ +/* Updated: 2024/12/16 15:34:31 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_ADDONS_H +# define FT_ADDONS_H # include @@ -19,14 +20,14 @@ /// @param value The value to check /// @param min The lower bound /// @param max The upper bound -/// @return true if the value is in the range, false otherwise -bool ft_inrange_ex(int value, int min, int max); +/// @return true if the value is in the range, false otherwise +bool ft_inrange_ex(int value, int min, int max); /// @brief Says if a value is in a range including the bounds /// @param value The value to check /// @param min The lower bound /// @param max The upper bound /// @return true if the value is in the range, false otherwise -bool ft_inrange(int value, int min, int max); +bool ft_inrange(int value, int min, int max); #endif diff --git a/includes/mlx_functions.h b/includes/mlx_functions.h deleted file mode 100644 index 85d15b8..0000000 --- a/includes/mlx_functions.h +++ /dev/null @@ -1,292 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* mlx_functions.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/11/08 21:54:56 by bgoulard #+# #+# */ -/* Updated: 2024/11/11 21:54:26 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef MLX_FUNCTIONS_H -# define MLX_FUNCTIONS_H - -# include "mlx_structs.h" - -/** - * @brief Initializes the MLX library. - * @return Pointer to the MLX instance structure. - */ -t_xvar *mlx_init(void); - -/** - * @brief Creates a new window. - * @param mlx_ptr Pointer to the MLX instance. - * @param size_x Width of the window. - * @param size_y Height of the window. - * @param title Title of the window. - * @return Pointer to the new window structure. - */ -t_win_list *mlx_new_window(\ - t_xvar *mlx_ptr, int size_x, int size_y, char *title); - -/** - * @brief Gets the screen size. - * @param mlx_ptr Pointer to the MLX instance. - * @param sizex Output parameter for the screen width. - * @param sizey Output parameter for the screen height. - * @return 0 on success, non-zero on error. - */ -int mlx_get_screen_size(t_xvar *mlx_ptr, int *sizex, int *sizey); - -/** - * @brief Clears the specified window. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window to clear. - * @return 0 on success, non-zero on error. - */ -int mlx_clear_window(t_xvar *mlx_ptr, t_win_list *win_ptr); - -/** - * @brief Draws a pixel in the specified window. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @param x X coordinate of the pixel. - * @param y Y coordinate of the pixel. - * @param color Color of the pixel. - * @return 0 on success, non-zero on error. - */ -int mlx_pixel_put(t_xvar *mlx_ptr, t_win_list *win_ptr, \ - int x, int y, int color); - -/** - * @brief Creates a new image. - * @param mlx_ptr Pointer to the MLX instance. - * @param width Width of the image. - * @param height Height of the image. - * @return Pointer to the new image structure. - */ -t_img *mlx_new_image(t_xvar *mlx_ptr, int width, int height); - -/** - * @brief Retrieves the address of the image data. - * @param img_ptr Pointer to the image. - * @param bits_per_pixel Bits per pixel of the image. - * @param size_line Size of each line in bytes. - * @param endian Endian of the image (0 for little-endian, 1 for big-endian). - * @return Pointer to the image data. - */ -char *mlx_get_data_addr(t_img *img_ptr, int *bits_per_pixel, \ - int *size_line, int *endian); - -/** - * @brief Puts an image into a window. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @param img_ptr Pointer to the image. - * @param x X coordinate in the window. - * @param y Y coordinate in the window. - * @return 0 on success, non-zero on error. - */ -int mlx_put_image_to_window(t_xvar *mlx_ptr, t_win_list *win_ptr, \ - t_img *img_ptr, int x, int y); - -/** - * @brief Gets the color value for the specified color. - * @param mlx_ptr Pointer to the MLX instance. - * @param color The color to retrieve the value for. - * @return The color value. - */ -int mlx_get_color_value(t_xvar *mlx_ptr, int color); - -/** - * @brief Sets a mouse hook on the window. - * @param win_ptr Pointer to the window. - * @param funct_ptr Pointer to the function to call on mouse events. - * @param param Parameter passed to the hook function. - * @return 0 on success, non-zero on error. - */ -int mlx_mouse_hook(t_win_list *win_ptr, int (*funct_ptr)(), \ - void *param); - -/** - * @brief Sets a keyboard hook on the window. - * @param win_ptr Pointer to the window. - * @param funct_ptr Pointer to the function to call on key events. - * @param param Parameter passed to the hook function. - * @return 0 on success, non-zero on error. - */ -int mlx_key_hook(t_win_list *win_ptr, int (*funct_ptr)(), void *param); - -/** - * @brief Sets an expose hook on the window. - * @param win_ptr Pointer to the window. - * @param funct_ptr Pointer to the function to call on expose events. - * @param param Parameter passed to the hook function. - * @return 0 on success, non-zero on error. - */ -int mlx_expose_hook(t_win_list *win_ptr, int (*funct_ptr)(), \ - void *param); - -/** - * @brief Sets a loop hook for repeated execution. - * @param mlx_ptr Pointer to the MLX instance. - * @param funct_ptr Pointer to the function to call in the loop. - * @param param Parameter passed to the hook function. - * @return 0 on success, non-zero on error. - */ -int mlx_loop_hook(t_xvar *mlx_ptr, int (*funct_ptr)(), void *param); - -/** - * @brief Starts the main loop for MLX. - * @param mlx_ptr Pointer to the MLX instance. - * @return 0 on success, non-zero on error. - */ -int mlx_loop(t_xvar *mlx_ptr); - -/** - * @brief Ends the main loop for MLX. - * @param mlx_ptr Pointer to the MLX instance. - * @return 0 on success, non-zero on error. - */ -int mlx_loop_end(t_xvar *mlx_ptr); - -/** - * @brief Draws a string in the specified window. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @param x X coordinate for the string. - * @param y Y coordinate for the string. - * @param color Color of the string. - * @param string The string to display. - * @return 0 on success, non-zero on error. - */ -int mlx_string_put(t_xvar *mlx_ptr, t_win_list *win_ptr, \ - int x, int y, int color, char *string); - -/** - * @brief Sets the font for the window. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @param name The font name. - */ -void mlx_set_font(t_xvar *mlx_ptr, t_win_list *win_ptr, char *name); - -/** - * @brief Converts XPM data to an image. - * @param mlx_ptr Pointer to the MLX instance. - * @param xpm_data The XPM data. - * @param width Output parameter for the width of the image. - * @param height Output parameter for the height of the image. - * @return Pointer to the created image. - */ -t_img *mlx_xpm_to_image(t_xvar *mlx_ptr, char **xpm_data, int *width, \ - int *height); - -/** - * @brief Converts an XPM file to an image. - * @param mlx_ptr Pointer to the MLX instance. - * @param filename The XPM file name. - * @param width Output parameter for the width of the image. - * @param height Output parameter for the height of the image. - * @return Pointer to the created image. - */ -t_img *mlx_xpm_file_to_image(t_xvar *mlx_ptr, char *filename, \ - int *width, int *height); - -/** - * @brief Destroys a window. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @return 0 on success, non-zero on error. - */ -int mlx_destroy_window(t_xvar *mlx_ptr, t_win_list *win_ptr); - -/** - * @brief Destroys an image. - * @param mlx_ptr Pointer to the MLX instance. - * @param img_ptr Pointer to the image. - * @return 0 on success, non-zero on error. - */ -int mlx_destroy_image(t_xvar *mlx_ptr, t_img *img_ptr); - -/** - * @brief Destroys the MLX display. - * @param mlx_ptr Pointer to the MLX instance. - * @return 0 on success, non-zero on error. - */ -int mlx_destroy_display(t_xvar *mlx_ptr); - -/** - * @brief Sets an event hook for a specific event. - * @param win_ptr Pointer to the window. - * @param x_event The event type. - * @param x_mask The event mask. - * @param funct Function to call for the event. - * @param param Parameter passed to the hook function. - * @return 0 on success, non-zero on error. - */ -int mlx_hook(t_win_list *win_ptr, int x_event, int x_mask, \ - int (*funct)(), void *param); - -/** - * @brief Disables key auto-repeat. - * @param mlx_ptr Pointer to the MLX instance. - * @return 0 on success, non-zero on error. - */ -int mlx_do_key_autorepeatoff(t_xvar *mlx_ptr); - -/** - * @brief Enables key auto-repeat. - * @param mlx_ptr Pointer to the MLX instance. - * @return 0 on success, non-zero on error. - */ -int mlx_do_key_autorepeaton(t_xvar *mlx_ptr); - -/** - * @brief Synchronizes the MLX display. - * @param mlx_ptr Pointer to the MLX instance. - * @return 0 on success, non-zero on error. - */ -int mlx_do_sync(t_xvar *mlx_ptr); - -/** - * @brief Retrieves the current mouse position. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @param x Output parameter for the X coordinate. - * @param y Output parameter for the Y coordinate. - * @return 0 on success, non-zero on error. - */ -int mlx_mouse_get_pos(t_xvar *mlx_ptr, t_win_list *win_ptr, \ - int *x, int *y); - -/** - * @brief Moves the mouse to a specified position. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @param x X coordinate to move to. - * @param y Y coordinate to move to. - * @return 0 on success, non-zero on error. - */ -int mlx_mouse_move(t_xvar *mlx_ptr, t_win_list *win_ptr, int x, int y); - -/** - * @brief Hides the mouse cursor. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @return 0 on success, non-zero on error. - */ -int mlx_mouse_hide(t_xvar *mlx_ptr, t_win_list *win_ptr); - -/** - * @brief Shows the mouse cursor. - * @param mlx_ptr Pointer to the MLX instance. - * @param win_ptr Pointer to the window. - * @return 0 on success, non-zero on error. - */ -int mlx_mouse_show(t_xvar *mlx_ptr, t_win_list *win_ptr); - -#endif /* FIXED_MLX_H */ diff --git a/mlx_layer/keys_event.c b/mlx_layer/keys_event.c index ad7b0c9..fa25583 100644 --- a/mlx_layer/keys_event.c +++ b/mlx_layer/keys_event.c @@ -11,7 +11,7 @@ /* ************************************************************************** */ #include "cub3d_struct.h" -#include "mlx_functions.h" +#include "mlx.h" #include #include diff --git a/mlx_layer/mlx_init.c b/mlx_layer/mlx_init.c index b844d19..5dcff99 100644 --- a/mlx_layer/mlx_init.c +++ b/mlx_layer/mlx_init.c @@ -6,14 +6,14 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/11 19:53:42 by rparodi #+# #+# */ -/* Updated: 2024/12/16 15:07:09 by bgoulard ### ########.fr */ +/* Updated: 2024/12/16 15:36:35 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ #include "cub3d.h" #include "cub3d_struct.h" -#include "mlx_functions.h" +#include "mlx.h" #include "mlx_structs.h" #include "ft_math.h" diff --git a/parsing/load_textures.c b/parsing/load_textures.c index 78cce53..ae608ec 100644 --- a/parsing/load_textures.c +++ b/parsing/load_textures.c @@ -15,7 +15,7 @@ #include "ft_string.h" -#include "mlx_functions.h" +#include "mlx.h" #include #include diff --git a/raycast/frame_update.c b/raycast/frame_update.c index f7406d1..005c100 100644 --- a/raycast/frame_update.c +++ b/raycast/frame_update.c @@ -13,7 +13,7 @@ #include "cub3d.h" #include "cub3d_struct.h" -#include "mlx_functions.h" +#include "mlx.h" #include "ft_string.h" #include diff --git a/sources/cleanups.c b/sources/cleanups.c index 898db8d..05fac29 100644 --- a/sources/cleanups.c +++ b/sources/cleanups.c @@ -12,7 +12,7 @@ #include "cub3d_struct.h" #include "ft_string.h" -#include "mlx_functions.h" +#include "mlx.h" static void cleanup_cli(t_cli *cli_ctx) { diff --git a/sources/main.c b/sources/main.c index adf56bc..e8e3e01 100644 --- a/sources/main.c +++ b/sources/main.c @@ -13,7 +13,7 @@ #include "cub3d.h" #include "cub3d_struct.h" #include "ft_string.h" -#include "mlx_functions.h" +#include "mlx.h" #include #include