twn_textures.c: add debug hints about unportable texture dimensions
This commit is contained in:
parent
752dbaad8a
commit
66678a27cf
@ -170,4 +170,9 @@ static inline t_fvec2 fast_cossine(float a) {
|
||||
};
|
||||
}
|
||||
|
||||
static inline bool is_power_of_two(int x)
|
||||
{
|
||||
return (x != 0) && ((x & (x - 1)) == 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "twn_textures_c.h"
|
||||
#include "twn_config.h"
|
||||
#include "twn_util.h"
|
||||
#include "twn_engine_context_c.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <physfs.h>
|
||||
@ -342,6 +343,12 @@ static t_texture_key textures_load(struct texture_cache *cache, const char *path
|
||||
|
||||
/* 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 (ctx.game.debug) {
|
||||
if (surface->w > TEXTURE_ATLAS_SIZE || surface->h > TEXTURE_ATLAS_SIZE)
|
||||
log_warn("Unportable texture dimensions for %s, use 2048x2048 at max", path);
|
||||
if (!is_power_of_two(surface->w) || !is_power_of_two(surface->h))
|
||||
log_warn("Unportable texture dimensions for %s, should be powers of 2", path);
|
||||
}
|
||||
new_texture.loner_texture = create_gpu_texture(TEXTURE_FILTER_NEAREAST, true);
|
||||
upload_texture_from_surface(new_texture.loner_texture, surface);
|
||||
new_texture.srcrect = (t_frect) { .w = (float)surface->w, .h = (float)surface->h };
|
||||
|
Loading…
Reference in New Issue
Block a user