diff --git a/src/game/scenes/ingame.c b/src/game/scenes/ingame.c index 66e36f9..21bdec3 100644 --- a/src/game/scenes/ingame.c +++ b/src/game/scenes/ingame.c @@ -11,20 +11,20 @@ static void ingame_tick(struct state *state) { world_drawdef(scn->world); player_calc(scn->player); - unfurl_triangle("/assets/player/baron-walk.png", + unfurl_triangle("/assets/big-violet.png", (t_fvec3){ -1, -1, 0 }, (t_fvec3){ 1, -1, 0 }, (t_fvec3){ 1, 1, 0 }, (t_shvec2){ 0, 0 }, - (t_shvec2){ 48, 0 }, - (t_shvec2){ 48, 48 }); + (t_shvec2){ 2048, 0 }, + (t_shvec2){ 2048, 2048 }); - unfurl_triangle("/assets/player/baron-walk.png", + unfurl_triangle("/assets/big-violet.png", (t_fvec3){ 1, 1, 0 }, (t_fvec3){ -1, 1, 0 }, (t_fvec3){ -1, -1, 0 }, - (t_shvec2){ 48, 48 }, - (t_shvec2){ 0, 48 }, + (t_shvec2){ 2048, 2048 }, + (t_shvec2){ 0, 2048 }, (t_shvec2){ 0, 0 }); } diff --git a/src/private/textures.h b/src/private/textures.h index f7abb32..6f5d727 100644 --- a/src/private/textures.h +++ b/src/private/textures.h @@ -25,8 +25,7 @@ struct texture_cache_item { struct texture_cache { - /* from context */ - SDL_Window *window; + SDL_Window *window; /* from context */ struct texture_cache_item *hash; @@ -34,7 +33,7 @@ struct texture_cache { SDL_Surface **atlas_surfaces; GLuint *atlas_textures; /* shared by atlas textures */ - int atlas_index; + int atlas_index; /* atlas that is currently being built */ bool is_dirty; /* current atlas needs to be recreated */ }; diff --git a/src/rendering.c b/src/rendering.c index e9d5786..eeed4ea 100644 --- a/src/rendering.c +++ b/src/rendering.c @@ -537,7 +537,6 @@ void render(void) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glRotatef(60, 1, 0, 0); glEnable(GL_CULL_FACE); glDepthFunc(GL_LESS); diff --git a/src/textures.c b/src/textures.c index 1ee060d..e10ff1a 100644 --- a/src/textures.c +++ b/src/textures.c @@ -125,6 +125,7 @@ static void upload_texture_from_surface(GLuint texture, SDL_Surface *surface) { static void recreate_current_atlas_texture(struct texture_cache *cache) { /* TODO: figure out if SDL_UpdateTexture alone is faster than blitting */ + /* TODO: should surfaces be freed after they cannot be referenced in atlas builing? */ SDL_Surface *atlas_surface = cache->atlas_surfaces[cache->atlas_index]; /* clear */ @@ -132,9 +133,14 @@ static void recreate_current_atlas_texture(struct texture_cache *cache) { /* blit the texture surfaces onto the atlas */ for (size_t i = 0; i < shlenu(cache->hash); ++i) { + /* skip all that aren't part of currently built one */ if (cache->hash[i].value.atlas_index != cache->atlas_index) continue; + /* skip loners */ + if (cache->hash[i].value.loner_texture != 0) + continue; + SDL_BlitSurface(cache->hash[i].value.data, NULL, atlas_surface, @@ -155,7 +161,10 @@ static void recreate_current_atlas_texture(struct texture_cache *cache) { static stbrp_rect *create_rects_from_cache(struct texture_cache *cache) { stbrp_rect *rects = NULL; for (size_t i = 0; i < shlenu(cache->hash); ++i) { - SDL_Surface *surface_data = cache->hash[i].value.data; + if (cache->hash[i].value.loner_texture != 0) + continue; + + const SDL_Surface *surface_data = cache->hash[i].value.data; stbrp_rect new_rect = { .w = surface_data->w, .h = surface_data->h, @@ -293,7 +302,7 @@ static t_texture_key textures_load(struct texture_cache *cache, const char *path new_texture.data = surface; /* it's a "loner texture," it doesn't fit in an atlas so it's not in one */ - if (surface->w > TEXTURE_ATLAS_SIZE || surface->h > TEXTURE_ATLAS_SIZE) { + if (surface->w >= TEXTURE_ATLAS_SIZE || surface->h >= TEXTURE_ATLAS_SIZE) { new_texture.loner_texture = new_gl_texture(); upload_texture_from_surface(new_texture.loner_texture, surface); new_texture.srcrect = (t_rect) { .w = surface->w, .h = surface->h };