mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 12:41:21 +00:00
Image: Share GetTexImage
This commit is contained in:
parent
f6f6639a89
commit
395641e1dc
5 changed files with 45 additions and 36 deletions
|
@ -598,3 +598,26 @@ GetSkyImage(const char *skyname, const char* surfname, qboolean palettedtexture,
|
|||
|
||||
return image;
|
||||
}
|
||||
|
||||
struct image_s *GetTexImage(const char *name, findimage_t find_image)
|
||||
{
|
||||
struct image_s *image = NULL;
|
||||
char pathname[MAX_QPATH];
|
||||
|
||||
Com_sprintf(pathname, sizeof(pathname), "textures/%s.wal", name);
|
||||
image = find_image(pathname, it_wall);
|
||||
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "textures/%s.m32", name);
|
||||
image = find_image(pathname, it_wall);
|
||||
}
|
||||
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "textures/%s.m8", name);
|
||||
image = find_image(pathname, it_wall);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
|
|
@ -448,7 +448,6 @@ Mod_LoadTexinfo(model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
texinfo_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, j, count;
|
||||
char name[MAX_QPATH];
|
||||
int next;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
@ -467,6 +466,8 @@ Mod_LoadTexinfo(model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
image_t *image;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
out->vecs[0][j] = LittleFloat(in->vecs[0][j]);
|
||||
|
@ -485,21 +486,15 @@ Mod_LoadTexinfo(model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
out->next = NULL;
|
||||
}
|
||||
|
||||
Com_sprintf(name, sizeof(name), "textures/%s.wal", in->texture);
|
||||
image = GetTexImage(in->texture, (findimage_t)R_FindImageUnsafe);
|
||||
|
||||
out->image = R_FindImage(name, it_wall);
|
||||
|
||||
if (!out->image || out->image == r_notexture)
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(name, sizeof(name), "textures/%s.m8", in->texture);
|
||||
out->image = R_FindImage(name, it_wall);
|
||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
||||
image = r_notexture;
|
||||
}
|
||||
|
||||
if (!out->image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", name);
|
||||
out->image = r_notexture;
|
||||
}
|
||||
out->image = image;
|
||||
}
|
||||
|
||||
/* count animation frames */
|
||||
|
|
|
@ -316,7 +316,6 @@ Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
texinfo_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, j, count;
|
||||
char name[MAX_QPATH];
|
||||
int next;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
@ -335,6 +334,8 @@ Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
{
|
||||
gl3image_t *image;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
out->vecs[0][j] = LittleFloat(in->vecs[0][j]);
|
||||
|
@ -353,21 +354,14 @@ Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
out->next = NULL;
|
||||
}
|
||||
|
||||
Com_sprintf(name, sizeof(name), "textures/%s.wal", in->texture);
|
||||
|
||||
out->image = GL3_FindImage(name, it_wall);
|
||||
|
||||
if (!out->image || out->image == gl3_notexture)
|
||||
image = GetTexImage(in->texture, (findimage_t)GL3_FindImageUnsafe);
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(name, sizeof(name), "textures/%s.m8", in->texture);
|
||||
out->image = GL3_FindImage(name, it_wall);
|
||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
||||
image = gl3_notexture;
|
||||
}
|
||||
|
||||
if (!out->image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", name);
|
||||
out->image = gl3_notexture;
|
||||
}
|
||||
out->image = image;
|
||||
}
|
||||
|
||||
/* count animation frames */
|
||||
|
|
|
@ -114,5 +114,6 @@ extern int Mod_ReLoadSkins(struct image_s **skins, findimage_t find_image,
|
|||
void *extradata, modtype_t type);
|
||||
extern struct image_s *GetSkyImage(const char *skyname, const char* surfname,
|
||||
qboolean palettedtexture, findimage_t find_image);
|
||||
extern struct image_s *GetTexImage(const char *name, findimage_t find_image);
|
||||
|
||||
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
||||
|
|
|
@ -486,7 +486,6 @@ Mod_LoadTexinfo (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
texinfo_t *in;
|
||||
mtexinfo_t *out, *step;
|
||||
int i, count;
|
||||
char name[MAX_QPATH];
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
|
||||
|
@ -504,6 +503,7 @@ Mod_LoadTexinfo (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
|
||||
for ( i=0 ; i<count ; i++, in++, out++)
|
||||
{
|
||||
image_t *image;
|
||||
int j, next;
|
||||
float len1, len2;
|
||||
|
||||
|
@ -531,19 +531,15 @@ Mod_LoadTexinfo (model_t *loadmodel, byte *mod_base, lump_t *l)
|
|||
out->next = NULL;
|
||||
}
|
||||
|
||||
Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
|
||||
out->image = R_FindImage (name, it_wall);
|
||||
if (!out->image || out->image == r_notexture_mip)
|
||||
image = GetTexImage(in->texture, (findimage_t)R_FindImageUnsafe);
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf (name, sizeof(name), "textures/%s.m8", in->texture);
|
||||
out->image = R_FindImage (name, it_wall);
|
||||
}
|
||||
|
||||
if (!out->image)
|
||||
{
|
||||
out->image = r_notexture_mip; // texture not found
|
||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
||||
image = r_notexture_mip;
|
||||
out->flags = 0;
|
||||
}
|
||||
|
||||
out->image = image;
|
||||
}
|
||||
|
||||
// count animation frames
|
||||
|
|
Loading…
Reference in a new issue