Fix custom textures with EXTERNAL_DATA
This commit is contained in:
parent
f25416d194
commit
8eb0a7d838
|
@ -332,8 +332,6 @@ static bool gfx_texture_cache_lookup(int tile, struct TextureHashmapNode **n, co
|
||||||
#undef CMPADDR
|
#undef CMPADDR
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EXTERNAL_DATA
|
|
||||||
|
|
||||||
static void import_texture_rgba32(int tile) {
|
static void import_texture_rgba32(int tile) {
|
||||||
uint32_t width = rdp.texture_tile.line_size_bytes / 2;
|
uint32_t width = rdp.texture_tile.line_size_bytes / 2;
|
||||||
uint32_t height = (rdp.loaded_texture[tile].size_bytes / 2) / rdp.texture_tile.line_size_bytes;
|
uint32_t height = (rdp.loaded_texture[tile].size_bytes / 2) / rdp.texture_tile.line_size_bytes;
|
||||||
|
@ -506,7 +504,8 @@ static void import_texture_ci8(int tile) {
|
||||||
gfx_rapi->upload_texture(rgba32_buf, width, height);
|
gfx_rapi->upload_texture(rgba32_buf, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // EXTERNAL_DATA
|
|
||||||
|
#ifdef EXTERNAL_DATA
|
||||||
|
|
||||||
static inline void load_texture(const char *fullpath) {
|
static inline void load_texture(const char *fullpath) {
|
||||||
int w, h;
|
int w, h;
|
||||||
|
@ -620,10 +619,25 @@ static void import_texture(int tile) {
|
||||||
#ifdef EXTERNAL_DATA
|
#ifdef EXTERNAL_DATA
|
||||||
// the "texture data" is actually a C string with the path to our texture in it
|
// the "texture data" is actually a C string with the path to our texture in it
|
||||||
// load it from an external image in our data path
|
// load it from an external image in our data path
|
||||||
char texname[SYS_MAX_PATH];
|
const char* texid = (const char*)rdp.loaded_texture[tile].addr;
|
||||||
snprintf(texname, sizeof(texname), FS_TEXTUREDIR "/%s.png", (const char*)rdp.loaded_texture[tile].addr);
|
|
||||||
load_texture(texname);
|
// make sure the texture id is a printable ascii string
|
||||||
#else
|
bool texidIsPrintable = true;
|
||||||
|
char* c = (char*)texid;
|
||||||
|
while (c != NULL && *c != '\0') {
|
||||||
|
if (*c < 33 || *c > 126) {
|
||||||
|
texidIsPrintable = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
if (texidIsPrintable) {
|
||||||
|
char texname[SYS_MAX_PATH];
|
||||||
|
snprintf(texname, sizeof(texname), FS_TEXTUREDIR "/%s.png", texid);
|
||||||
|
load_texture(texname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// the texture data is actual texture data
|
// the texture data is actual texture data
|
||||||
//int t0 = get_time();
|
//int t0 = get_time();
|
||||||
if (fmt == G_IM_FMT_RGBA) {
|
if (fmt == G_IM_FMT_RGBA) {
|
||||||
|
@ -666,7 +680,6 @@ static void import_texture(int tile) {
|
||||||
}
|
}
|
||||||
//int t1 = get_time();
|
//int t1 = get_time();
|
||||||
//printf("Time diff: %d\n", t1 - t0);
|
//printf("Time diff: %d\n", t1 - t0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_normalize_vector(float v[3]) {
|
static void gfx_normalize_vector(float v[3]) {
|
||||||
|
|
Loading…
Reference in New Issue