This commit is contained in:
2024-01-17 21:53:29 +01:00
parent 5ec8268935
commit 05f1323377
65 changed files with 144 additions and 15 deletions

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Binary file not shown.

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)

Binary file not shown.

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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));
}

Binary file not shown.