diff --git a/versionmod/.vscode/c_cpp_properties.json b/versionmod/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..c2098a2 --- /dev/null +++ b/versionmod/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "linux-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "linux-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/versionmod/.vscode/launch.json b/versionmod/.vscode/launch.json new file mode 100644 index 0000000..633d781 --- /dev/null +++ b/versionmod/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": false, + "cwd": "/home/fgras-ca/Bureau/Nouveau dossier/cub3D/versionmod", + "program": "/home/fgras-ca/Bureau/Nouveau dossier/cub3D/versionmod/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/versionmod/.vscode/settings.json b/versionmod/.vscode/settings.json new file mode 100644 index 0000000..bb879da --- /dev/null +++ b/versionmod/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/versionmod/cub3d b/versionmod/cub3d index c7c5981..38597f2 100755 Binary files a/versionmod/cub3d and b/versionmod/cub3d differ diff --git a/versionmod/draw/ft_2d_view.c b/versionmod/draw/ft_2d_view.c index 96ef8af..c483305 100644 --- a/versionmod/draw/ft_2d_view.c +++ b/versionmod/draw/ft_2d_view.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 17:49:42 by fgras-ca #+# #+# */ -/* Updated: 2024/01/15 18:44:32 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/17 21:47:17 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/versionmod/draw/ft_2d_view.o b/versionmod/draw/ft_2d_view.o index 3dcb557..44f516d 100644 Binary files a/versionmod/draw/ft_2d_view.o and b/versionmod/draw/ft_2d_view.o differ diff --git a/versionmod/draw/ft_load_textures.c b/versionmod/draw/ft_load_textures.c index 8ae31e9..ab92523 100644 --- a/versionmod/draw/ft_load_textures.c +++ b/versionmod/draw/ft_load_textures.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/14 20:30:59 by fgras-ca #+# #+# */ -/* Updated: 2024/01/16 17:36:23 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/17 21:45:36 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,8 +16,8 @@ void load_texture(t_structure_main *w, char *file_path, void **texture_ptr) { int width; int height; - - //printf("load texture %s\n", file_path); + //w->s_win.mlx = mlx_init(); + printf("file path %s\n", file_path); width = 0; height = 0; *texture_ptr = mlx_xpm_file_to_image(w->s_win.mlx, @@ -29,15 +29,24 @@ void load_texture(t_structure_main *w, char *file_path, void **texture_ptr) } w->s_img.texture_width = width; w->s_img.texture_height = height; + printf("height %d\n", height); + printf("width %d\n", width); } void load_wall_textures(t_structure_main *w) { - printf("loadtexture %s\n", w->t->north); + printf("load wall texture %s\n", w->t->north); + printf("load wall texture %s\n", w->t->south); + printf("load wall texture %s\n", w->t->east); + printf("load wall texture %s\n", w->t->west); load_texture(w, w->t->north, (void **)&w->s_img.north_texture); load_texture(w, w->t->south, (void **)&w->s_img.south_texture); load_texture(w, w->t->west, (void **)&w->s_img.west_texture); load_texture(w, w->t->east, (void **)&w->s_img.east_texture); + printf("load wall texture %s\n", w->t->north); + printf("load wall texture %s\n", w->t->south); + printf("load wall texture %s\n", w->t->east); + printf("load wall texture %s\n", w->t->west); } void exit_error(t_structure_main *w) diff --git a/versionmod/draw/ft_load_textures.o b/versionmod/draw/ft_load_textures.o index c9db34b..2a1d67c 100644 Binary files a/versionmod/draw/ft_load_textures.o and b/versionmod/draw/ft_load_textures.o differ diff --git a/versionmod/draw/ft_textures.c b/versionmod/draw/ft_textures.c index 93c9817..5cba2a6 100644 --- a/versionmod/draw/ft_textures.c +++ b/versionmod/draw/ft_textures.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 17:39:11 by fgras-ca #+# #+# */ -/* Updated: 2024/01/16 16:55:50 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/17 21:38:40 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,6 +36,7 @@ void draw_texture_line(t_texture_params *params, float y, int textureY) put_pixel_img(params->w, x, y, color); x++; } + printf("draw_texture_line: texturex = %d, textureY = %d, color = %d\n", texturex, textureY, color); } void draw_texture(t_texture_params *params) @@ -55,11 +56,13 @@ void draw_texture(t_texture_params *params) texturey = textureheight - 1; draw_texture_line(params, y, texturey); y++; - } + }printf("draw_texture: y = %f, texturey = %d\n", y, texturey); + } void *get_selected_texture(t_structure_main *w, WallDirection wallDir) { + void *texture = NULL; if (wallDir == NORTH) return (w->t->north); else if (wallDir == SOUTH) @@ -74,6 +77,11 @@ void *get_selected_texture(t_structure_main *w, WallDirection wallDir) exit_error(w); return (NULL); } + if (texture == NULL) { + fprintf(stderr, "get_selected_texture: selected texture is NULL\n"); + } else { + printf("get_selected_texture: selected texture = %p\n", texture); + } } t_texture_data get_texture_data(void *texture) @@ -82,6 +90,7 @@ t_texture_data get_texture_data(void *texture) texture_data.data = mlx_get_data_addr(texture, &texture_data.bpp, &texture_data.size_line, &texture_data.endian); + printf("get_texture_data: bpp = %d, size_line = %d, endian = %d\n", texture_data.bpp, texture_data.size_line, texture_data.endian); return (texture_data); } @@ -97,8 +106,10 @@ int get_texture_color(t_structure_main *w, WallDirection wallDir, { return (0); } + texture_data = get_texture_data(selected_texture); pixel_pos = (textureX + textureY * w->s_img.texture_width) * (texture_data.bpp / 8); + printf("get_texture_color: textureX = %d, textureY = %d, pixel_pos = %d\n", textureX, textureY, pixel_pos); return (*(int *)(texture_data.data + pixel_pos)); } diff --git a/versionmod/draw/ft_textures.o b/versionmod/draw/ft_textures.o index b53ed6e..179aaa0 100644 Binary files a/versionmod/draw/ft_textures.o and b/versionmod/draw/ft_textures.o differ diff --git a/versionmod/libft/Makefile b/versionmod/libft/Makefile old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_atoi.c b/versionmod/libft/ft_atoi.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_bzero.c b/versionmod/libft/ft_bzero.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_calloc.c b/versionmod/libft/ft_calloc.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_isalnum.c b/versionmod/libft/ft_isalnum.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_isalpha.c b/versionmod/libft/ft_isalpha.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_isascii.c b/versionmod/libft/ft_isascii.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_isdigit.c b/versionmod/libft/ft_isdigit.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_isprint.c b/versionmod/libft/ft_isprint.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_itoa.c b/versionmod/libft/ft_itoa.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstadd_back.c b/versionmod/libft/ft_lstadd_back.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstadd_front.c b/versionmod/libft/ft_lstadd_front.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstclear.c b/versionmod/libft/ft_lstclear.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstdelone.c b/versionmod/libft/ft_lstdelone.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstiter.c b/versionmod/libft/ft_lstiter.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstlast.c b/versionmod/libft/ft_lstlast.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstmap.c b/versionmod/libft/ft_lstmap.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstnew.c b/versionmod/libft/ft_lstnew.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_lstsize.c b/versionmod/libft/ft_lstsize.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_memchr.c b/versionmod/libft/ft_memchr.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_memcmp.c b/versionmod/libft/ft_memcmp.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_memcpy.c b/versionmod/libft/ft_memcpy.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_memmove.c b/versionmod/libft/ft_memmove.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_memset.c b/versionmod/libft/ft_memset.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_putchar_fd.c b/versionmod/libft/ft_putchar_fd.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_putendl_fd.c b/versionmod/libft/ft_putendl_fd.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_putnbr_fd.c b/versionmod/libft/ft_putnbr_fd.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_putstr_fd.c b/versionmod/libft/ft_putstr_fd.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_realloc.c b/versionmod/libft/ft_realloc.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_reallocarray.c b/versionmod/libft/ft_reallocarray.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strcat.c b/versionmod/libft/ft_strcat.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strchr.c b/versionmod/libft/ft_strchr.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strcmp.c b/versionmod/libft/ft_strcmp.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strcpy.c b/versionmod/libft/ft_strcpy.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_striteri.c b/versionmod/libft/ft_striteri.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strlcat.c b/versionmod/libft/ft_strlcat.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strlcpy.c b/versionmod/libft/ft_strlcpy.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strmapi.c b/versionmod/libft/ft_strmapi.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strncmp.c b/versionmod/libft/ft_strncmp.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strncpy.c b/versionmod/libft/ft_strncpy.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strnstr.c b/versionmod/libft/ft_strnstr.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strrchr.c b/versionmod/libft/ft_strrchr.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strstr.c b/versionmod/libft/ft_strstr.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strtok.c b/versionmod/libft/ft_strtok.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strtol.c b/versionmod/libft/ft_strtol.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_strtrim.c b/versionmod/libft/ft_strtrim.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_substr.c b/versionmod/libft/ft_substr.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_tolower.c b/versionmod/libft/ft_tolower.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/ft_toupper.c b/versionmod/libft/ft_toupper.c old mode 100755 new mode 100644 diff --git a/versionmod/libft/libft.h b/versionmod/libft/libft.h old mode 100755 new mode 100644 diff --git a/versionmod/main.c b/versionmod/main.c index 4969b67..94923ef 100644 --- a/versionmod/main.c +++ b/versionmod/main.c @@ -6,21 +6,20 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 18:45:52 by fgras-ca #+# #+# */ -/* Updated: 2024/01/16 17:55:57 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/17 21:22:18 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "cub3d.h" -int setup_and_load_map(int argc, char **argv, t_structure_main *w) +int setup_and_load_map(int argc, char **argv, t_structure_main *w, t_texture *textures) { - t_texture textures; if (argc > 2) { fprintf(stderr, "Usage: %s\n", argv[0]); return (0); } - if (!load_cub_file("map.cub", &textures, &w->s_map)) + if (!load_cub_file("map.cub", textures, &w->s_map)) { printf("Failed to load the map or map is not closed. Exiting...\n"); return (0); @@ -30,6 +29,10 @@ int setup_and_load_map(int argc, char **argv, t_structure_main *w) printf("Failed to load the map.\n"); return (0); } + printf("set_up_andloadmap %s\n", textures->north); + printf("set_up_andloadmap %s\n", textures->south); + printf("set_up_andloadmap %s\n", textures->east); + printf("set_up_andloadmap %s\n", textures->west); return (1); } @@ -47,9 +50,12 @@ int main(int argc, char **argv) global_struct.w = &w; global_struct.state.jkl = -1; global_struct.state.yui = 0; - if (!setup_and_load_map(argc, argv, &w)) + if (!setup_and_load_map(argc, argv, &w, w.t)) return (1); - load_wall_textures(&w); + printf("main textures %s\n", w.t->north); + printf("main textures %s\n", w.t->south); + printf("main textures %s\n", w.t->east); + printf("main textures %s\n", w.t->west); init_windows(&w); mlx_loop_hook(w.s_win.mlx, (void *)sleep_mouse, &global_struct); mlx_hook(w.s_win.win, 2, 1L << 0, deal_key, &w); diff --git a/versionmod/main.o b/versionmod/main.o index 5d6e737..7402269 100644 Binary files a/versionmod/main.o and b/versionmod/main.o differ diff --git a/versionmod/window/ft_player.c b/versionmod/window/ft_player.c index dc96efe..9e36ea5 100644 --- a/versionmod/window/ft_player.c +++ b/versionmod/window/ft_player.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/14 20:09:23 by fgras-ca #+# #+# */ -/* Updated: 2024/01/14 20:16:05 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/17 21:15:02 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/versionmod/window/ft_window.c b/versionmod/window/ft_window.c index 1b61581..afa5379 100644 --- a/versionmod/window/ft_window.c +++ b/versionmod/window/ft_window.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/14 19:15:53 by fgras-ca #+# #+# */ -/* Updated: 2024/01/16 17:55:37 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/17 21:26:12 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -92,7 +92,9 @@ void init_windows(t_structure_main *w) w->s_win.height = HEIGHT; init_player(w); init_mlx_and_window(w); + load_textures(w, &temp); init_buffer(w); + load_wall_textures(w); printf("Window Dimensions: Width = %d, Height = %d\n", w->s_win.width, w->s_win.height); printf("Texture Dimensions: Width = %d, Height = %d\n", diff --git a/versionmod/window/ft_window.o b/versionmod/window/ft_window.o index 9e55565..8ac64b7 100644 Binary files a/versionmod/window/ft_window.o and b/versionmod/window/ft_window.o differ