diff --git a/src/init/set_textures.c b/src/init/set_textures.c index 78139e3..fd59671 100644 --- a/src/init/set_textures.c +++ b/src/init/set_textures.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* set_textures.c :+: :+: */ +/* set_textures.c :+: :+: */ /* +:+ */ /* By: yzaim +#+ */ /* +#+ */ /* Created: 2024/01/08 15:56:45 by yzaim #+# #+# */ -/* Updated: 2024/03/06 11:36:14 by yzaim ######## odam.nl */ +/* Updated: 2024/03/26 18:41:38 by yesimzaim ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -91,5 +91,7 @@ int set_textures(t_attr *attributes) return (pr_err(MLX_ERROR)); if (set_door_texture(&attributes->doors)) return (pr_err(MLX_ERROR)); + printf("DIMENSIONS:\n"); + printf("N: W %d H %d BPP %d \n", attributes->n.tex->width, attributes->n.tex->height, attributes->n.tex->bytes_per_pixel); return (EXIT_SUCCESS); } diff --git a/src/renderer/draw_func.c b/src/renderer/draw_func.c index d0b4224..cdf6756 100644 --- a/src/renderer/draw_func.c +++ b/src/renderer/draw_func.c @@ -6,7 +6,7 @@ /* By: yzaim +#+ */ /* +#+ */ /* Created: 2024/01/08 15:28:08 by yzaim #+# #+# */ -/* Updated: 2024/03/06 11:33:33 by yzaim ######## odam.nl */ +/* Updated: 2024/03/26 18:44:51 by yesimzaim ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -18,24 +18,20 @@ #include #include -static void calculate_texture_points(mlx_texture_t *texture, \ - t_ray *ray, uint32_t h) +static void calculate_texture_points(mlx_texture_t *texture, t_ray *ray, uint32_t h) { double offset; offset = 0; ray->texture_point.x = (int)(ray->wall_x * texture->width); - if ((ray->hit_side == SIDE_E || ray->hit_side == SIDE_W) \ - && ray->direction.x > 0) + if ((ray->hit_side == SIDE_E || ray->hit_side == SIDE_W) && ray->direction.x > 0) ray->texture_point.x = texture->width - ray->texture_point.x - 1; - if ((ray->hit_side == SIDE_S || ray->hit_side == SIDE_N) \ - && ray->direction.y < 0) + if ((ray->hit_side == SIDE_S || ray->hit_side == SIDE_N) && ray->direction.y < 0) ray->texture_point.x = texture->width - ray->texture_point.x - 1; if (ray->line_height > h) offset = (ray->line_height - h) / 2; ray->step = texture->height / ray->line_height; - ray->texture_position = ((ray->line_point.x + offset) + \ - (ray->line_height - h) / 2) * ray->step; + ray->texture_position = ((ray->line_point.x + offset) + (ray->line_height - h) / 2) * ray->step; } void draw_column(t_meta *meta, t_ray *ray, uint32_t col, uint32_t h) @@ -51,11 +47,9 @@ void draw_column(t_meta *meta, t_ray *ray, uint32_t col, uint32_t h) y = 0; while (y < ray->line_point.y && y < (int32_t)WINDOW_HEIGHT) { - ray->texture_point.y = ((int) ray->texture_position) & \ - (texture->height - 1); + ray->texture_point.y = ((int) ray->texture_position) & (texture->height - 1); ray->texture_position += ray->step; - color = pixel_picker(texture, (int)round(ray->texture_point.x), \ - (int)round(ray->texture_point.y)); + color = pixel_picker(texture, (int)round(ray->texture_point.x), (int)round(ray->texture_point.y)); mlx_put_pixel(meta->image, col, y, color); y++; } diff --git a/src/renderer/pixel_picker.c b/src/renderer/pixel_picker.c index d13dcc5..3cfda80 100644 --- a/src/renderer/pixel_picker.c +++ b/src/renderer/pixel_picker.c @@ -6,7 +6,7 @@ /* By: yzaim +#+ */ /* +#+ */ /* Created: 2024/01/08 15:26:51 by yzaim #+# #+# */ -/* Updated: 2024/02/28 14:33:23 by yzaim ######## odam.nl */ +/* Updated: 2024/03/25 14:38:24 by yesimzaim ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -45,7 +45,7 @@ uint32_t pixel_picker(mlx_texture_t *texture, int32_t x, int32_t y) uint8_t a; uint32_t index; - index = y * texture->width * 4 + x * 4; + index = (y * texture->width + x) * texture->bytes_per_pixel; r = texture->pixels[index]; g = texture->pixels[index + 1]; b = texture->pixels[index + 2]; diff --git a/src/renderer/render_minimap.c b/src/renderer/render_minimap.c index 451ce65..ac62a12 100644 --- a/src/renderer/render_minimap.c +++ b/src/renderer/render_minimap.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* render_minimap.c :+: :+: */ +/* render_minimap.c :+: :+: */ /* +:+ */ /* By: yzaim +#+ */ /* +#+ */ /* Created: 2024/01/08 15:27:53 by yzaim #+# #+# */ -/* Updated: 2024/03/10 16:40:57 by joppe ######## odam.nl */ +/* Updated: 2024/03/27 12:16:56 by yesimzaim ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -59,17 +59,14 @@ static void render_minimap_level(mlx_image_t *image, const t_map *map, \ image_center.y - (MINIMAP_PLAYER_SIZE / 2) }; const size_t size = p->meta->minimap.tile_size; - render_clear_bg(image, MINIMAP_COLOR_BACKGROUND); beep_boop(image, image_center, p, map); +(void) map; i = 0; while (i < WINDOW_WIDTH) { r = &p->hrays[i]; - draw_line(image, image_center, vec2d_to_vec2i(vec2d_add((t_vec2d) \ - {image_center.x, image_center.y}, \ - vec2d_scalar_product(r->direction, (r->length) * \ - size))), (t_rgba){0x999999FF}); + draw_line(image, image_center, vec2d_to_vec2i(vec2d_add((t_vec2d){image_center.x, image_center.y}, vec2d_scalar_product(r->direction, r->length * size))), (t_rgba){0x999999FF}); i++; } draw_rect(image, pos, (t_vec2u){MINIMAP_PLAYER_SIZE, \ diff --git a/src/renderer/render_viewport.c b/src/renderer/render_viewport.c index 198eeec..cee1a7c 100644 --- a/src/renderer/render_viewport.c +++ b/src/renderer/render_viewport.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* render_viewport.c :+: :+: */ +/* render_viewport.c :+: :+: */ /* +:+ */ /* By: yzaim +#+ */ /* +#+ */ /* Created: 2024/01/08 15:28:08 by yzaim #+# #+# */ -/* Updated: 2024/03/01 19:09:32 by joppe ######## odam.nl */ +/* Updated: 2024/03/27 12:16:45 by yesimzaim ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -53,6 +53,12 @@ void render_walls(mlx_image_t *image, t_player *p) } } +static uint32_t index_at(uint32_t x, uint32_t y, uint32_t width, uint8_t bpp) +{ + int index = (x + y * width) * bpp; //Looping over every pixel; + return (index); +} + void render_viewport(mlx_image_t *image, t_player *p) { const int32_t crosshair_size = 8; @@ -63,4 +69,5 @@ void render_viewport(mlx_image_t *image, t_player *p) (WINDOW_HEIGHT / 2 - (crosshair_size / 2))}, \ (t_vec2u){crosshair_size, \ crosshair_size}, 0xFFFFFFFF); + } diff --git a/test_maps/map_with_extras.cub b/test_maps/map_with_extras.cub index 1cc852e..d7068b2 100644 --- a/test_maps/map_with_extras.cub +++ b/test_maps/map_with_extras.cub @@ -1,15 +1,12 @@ -NO texture_examples/bw_splash.png -WE texture_examples/bw_splash.png -EA texture_examples/bw_splash.png -SO texture_examples/bw_splash.png +NO texture_examples/bw_wall.png +WE texture_examples/bw_wall.png +EA texture_examples/bw_wall.png +SO texture_examples/bw_wall.png F 0,0,0 C 0,0,0 -D texture_examples/wood.png -SP texture_examples/pillar.png 4.5 2.5 -SP texture_examples/barrel.png 5.5 3.5 -SP texture_examples/sexy.png 9.5 3.5 -SP texture_examples/hoofd.png 8.5 2.5 +D texture_examples/ceiling.png + 11111111111111 10000100011111 diff --git a/texture_examples/.DS_Store b/texture_examples/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/texture_examples/.DS_Store differ diff --git a/texture_examples/IMG_4274.jpeg b/texture_examples/IMG_4274.jpeg deleted file mode 100644 index 5f0b39e..0000000 Binary files a/texture_examples/IMG_4274.jpeg and /dev/null differ diff --git a/texture_examples/IMG_4275.jpeg b/texture_examples/IMG_4275.jpeg deleted file mode 100644 index 5765c35..0000000 Binary files a/texture_examples/IMG_4275.jpeg and /dev/null differ diff --git a/texture_examples/IMG_9093.JPG b/texture_examples/IMG_9093.JPG deleted file mode 100644 index 1aa8b46..0000000 Binary files a/texture_examples/IMG_9093.JPG and /dev/null differ diff --git a/texture_examples/bw_wall_2.png b/texture_examples/bw_wall_2.png new file mode 100644 index 0000000..6ef57fb Binary files /dev/null and b/texture_examples/bw_wall_2.png differ diff --git a/texture_examples/runningcat.png b/texture_examples/runningcat.png deleted file mode 100644 index b9ee97b..0000000 Binary files a/texture_examples/runningcat.png and /dev/null differ