a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

commit a05dabc83199550810933de7c46033b1ab00534a
parent 0ce7c308dc7fe8d998d05e8495100b3d4ed9a9b5
Author: amin <dev@aminmesbah.com>
Date:   Tue, 16 Jul 2019 02:35:29 +0000

Actually allocate space for mipmaps

Now the tiles look nice again!

FossilOrigin-Name: 5f9f9bd06bae27fe5d5dc62d1840b4d4011ee4062aee900b23b9df1cfd31b3d4
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); }