mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-30 00:10:53 +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;
|
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;
|
texinfo_t *in;
|
||||||
mtexinfo_t *out, *step;
|
mtexinfo_t *out, *step;
|
||||||
int i, j, count;
|
int i, j, count;
|
||||||
char name[MAX_QPATH];
|
|
||||||
int next;
|
int next;
|
||||||
|
|
||||||
in = (void *)(mod_base + l->fileofs);
|
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++)
|
for (i = 0; i < count; i++, in++, out++)
|
||||||
{
|
{
|
||||||
|
image_t *image;
|
||||||
|
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
out->vecs[0][j] = LittleFloat(in->vecs[0][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;
|
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 (!image)
|
||||||
|
|
||||||
if (!out->image || out->image == r_notexture)
|
|
||||||
{
|
{
|
||||||
Com_sprintf(name, sizeof(name), "textures/%s.m8", in->texture);
|
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
||||||
out->image = R_FindImage(name, it_wall);
|
image = r_notexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!out->image)
|
out->image = image;
|
||||||
{
|
|
||||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", name);
|
|
||||||
out->image = r_notexture;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count animation frames */
|
/* count animation frames */
|
||||||
|
|
|
@ -316,7 +316,6 @@ Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||||
texinfo_t *in;
|
texinfo_t *in;
|
||||||
mtexinfo_t *out, *step;
|
mtexinfo_t *out, *step;
|
||||||
int i, j, count;
|
int i, j, count;
|
||||||
char name[MAX_QPATH];
|
|
||||||
int next;
|
int next;
|
||||||
|
|
||||||
in = (void *)(mod_base + l->fileofs);
|
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++)
|
for (i = 0; i < count; i++, in++, out++)
|
||||||
{
|
{
|
||||||
|
gl3image_t *image;
|
||||||
|
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
out->vecs[0][j] = LittleFloat(in->vecs[0][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;
|
out->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Com_sprintf(name, sizeof(name), "textures/%s.wal", in->texture);
|
image = GetTexImage(in->texture, (findimage_t)GL3_FindImageUnsafe);
|
||||||
|
if (!image)
|
||||||
out->image = GL3_FindImage(name, it_wall);
|
|
||||||
|
|
||||||
if (!out->image || out->image == gl3_notexture)
|
|
||||||
{
|
{
|
||||||
Com_sprintf(name, sizeof(name), "textures/%s.m8", in->texture);
|
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
||||||
out->image = GL3_FindImage(name, it_wall);
|
image = gl3_notexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!out->image)
|
out->image = image;
|
||||||
{
|
|
||||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", name);
|
|
||||||
out->image = gl3_notexture;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count animation frames */
|
/* count animation frames */
|
||||||
|
|
|
@ -114,5 +114,6 @@ extern int Mod_ReLoadSkins(struct image_s **skins, findimage_t find_image,
|
||||||
void *extradata, modtype_t type);
|
void *extradata, modtype_t type);
|
||||||
extern struct image_s *GetSkyImage(const char *skyname, const char* surfname,
|
extern struct image_s *GetSkyImage(const char *skyname, const char* surfname,
|
||||||
qboolean palettedtexture, findimage_t find_image);
|
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_ */
|
#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;
|
texinfo_t *in;
|
||||||
mtexinfo_t *out, *step;
|
mtexinfo_t *out, *step;
|
||||||
int i, count;
|
int i, count;
|
||||||
char name[MAX_QPATH];
|
|
||||||
|
|
||||||
in = (void *)(mod_base + l->fileofs);
|
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++)
|
for ( i=0 ; i<count ; i++, in++, out++)
|
||||||
{
|
{
|
||||||
|
image_t *image;
|
||||||
int j, next;
|
int j, next;
|
||||||
float len1, len2;
|
float len1, len2;
|
||||||
|
|
||||||
|
@ -531,19 +531,15 @@ Mod_LoadTexinfo (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||||
out->next = NULL;
|
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 (!image)
|
||||||
if (!out->image || out->image == r_notexture_mip)
|
|
||||||
{
|
{
|
||||||
Com_sprintf (name, sizeof(name), "textures/%s.m8", in->texture);
|
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
||||||
out->image = R_FindImage (name, it_wall);
|
image = r_notexture_mip;
|
||||||
}
|
|
||||||
|
|
||||||
if (!out->image)
|
|
||||||
{
|
|
||||||
out->image = r_notexture_mip; // texture not found
|
|
||||||
out->flags = 0;
|
out->flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out->image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// count animation frames
|
// count animation frames
|
||||||
|
|
Loading…
Reference in a new issue