a-game

2D platformer written from scratch.
Log | Files | Refs | README | LICENSE

commit fd494c04be18034d98aded0809ba4812018b4d3e
parent 442dcd3a62736a2519b63232074a71ae6c63638c
Author: Amin Mesbah <dev@aminmesbah.com>
Date:   Mon, 15 Jul 2019 19:35:29 -0700

Actually allocate space for mipmaps

Now the tiles look nice again!

Diffstat:
Msrc/render.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/render.c b/src/render.c @@ -57,7 +57,8 @@ internal void renderer_init(struct RendererState *renderer, struct Image *images u32 texture_id; glGenTextures(1, &texture_id); glBindTexture(GL_TEXTURE_2D_ARRAY, texture_id); - glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, tile_dim.x, tile_dim.y, tileset_dim.x * tileset_dim.y); + u32 mip_map_levels = 4; + glTexStorage3D(GL_TEXTURE_2D_ARRAY, mip_map_levels, GL_RGBA8, tile_dim.x, tile_dim.y, tileset_dim.x * tileset_dim.y); size_t marker = mem_st_get_marker(allocator); { @@ -100,11 +101,11 @@ internal void renderer_init(struct RendererState *renderer, struct Image *images } mem_st_free_to_marker(allocator, marker); - // TODO: fix the _hideous_ aliasing that happens when scaling down. - glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glGenerateMipmap(GL_TEXTURE_2D_ARRAY); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glActiveTexture(GL_TEXTURE0); }