mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 15:21:44 +00:00
Image: Check skin image before use
This commit is contained in:
parent
a22bbc8719
commit
49a1478d44
12 changed files with 51 additions and 22 deletions
|
@ -327,7 +327,8 @@ GetPCXPalette (byte **colormap, unsigned *d_8to24table)
|
||||||
LoadPCX ("pics/colormap.pcx", colormap, &pal, NULL, NULL);
|
LoadPCX ("pics/colormap.pcx", colormap, &pal, NULL, NULL);
|
||||||
if (!*colormap || !pal)
|
if (!*colormap || !pal)
|
||||||
{
|
{
|
||||||
ri.Sys_Error (ERR_FATAL, "Couldn't load pics/colormap.pcx");
|
ri.Sys_Error (ERR_FATAL, "%s: Couldn't load pics/colormap.pcx",
|
||||||
|
__func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0 ; i<256 ; i++)
|
for (i=0 ; i<256 ; i++)
|
||||||
|
|
|
@ -40,7 +40,8 @@ Draw_InitLocal(void)
|
||||||
draw_chars = FindPic("conchars", (findimage_t)R_FindImageUnsafe);
|
draw_chars = FindPic("conchars", (findimage_t)R_FindImageUnsafe);
|
||||||
if (!draw_chars)
|
if (!draw_chars)
|
||||||
{
|
{
|
||||||
ri.Sys_Error(ERR_FATAL, "Couldn't load pics/conchars.pcx");
|
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars.pcx",
|
||||||
|
__func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1206,7 +1206,8 @@ R_InitImages(void)
|
||||||
|
|
||||||
if (!gl_state.d_16to8table)
|
if (!gl_state.d_16to8table)
|
||||||
{
|
{
|
||||||
ri.Sys_Error(ERR_FATAL, "Couldn't load pics/16to8.pcx");
|
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/16to8.pcx",
|
||||||
|
__func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,7 @@ R_DrawSpriteModel(entity_t *currententity, const model_t *currentmodel)
|
||||||
dsprframe_t *frame;
|
dsprframe_t *frame;
|
||||||
float *up, *right;
|
float *up, *right;
|
||||||
dsprite_t *psprite;
|
dsprite_t *psprite;
|
||||||
|
image_t *skin;
|
||||||
|
|
||||||
/* don't even bother culling, because it's just
|
/* don't even bother culling, because it's just
|
||||||
a single polygon without a surface cache */
|
a single polygon without a surface cache */
|
||||||
|
@ -208,7 +209,13 @@ R_DrawSpriteModel(entity_t *currententity, const model_t *currentmodel)
|
||||||
|
|
||||||
glColor4f(1, 1, 1, alpha);
|
glColor4f(1, 1, 1, alpha);
|
||||||
|
|
||||||
R_Bind(currentmodel->skins[currententity->frame]->texnum);
|
skin = currentmodel->skins[currententity->frame];
|
||||||
|
if (!skin)
|
||||||
|
{
|
||||||
|
skin = r_notexture; /* fallback... */
|
||||||
|
}
|
||||||
|
|
||||||
|
R_Bind(skin->texnum);
|
||||||
|
|
||||||
R_TexEnv(GL_MODULATE);
|
R_TexEnv(GL_MODULATE);
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ Mod_ForName (char *name, model_t *parent_model, qboolean crash)
|
||||||
{
|
{
|
||||||
mod->extradata = Mod_LoadMD2(mod->name, buf, modfilelen,
|
mod->extradata = Mod_LoadMD2(mod->name, buf, modfilelen,
|
||||||
mod->mins, mod->maxs,
|
mod->mins, mod->maxs,
|
||||||
(struct image_s **)mod->skins, (findimage_t)R_FindImage,
|
(struct image_s **)mod->skins, (findimage_t)R_FindImageUnsafe,
|
||||||
&(mod->type));
|
&(mod->type));
|
||||||
if (!mod->extradata)
|
if (!mod->extradata)
|
||||||
{
|
{
|
||||||
|
@ -263,7 +263,7 @@ Mod_ForName (char *name, model_t *parent_model, qboolean crash)
|
||||||
case IDSPRITEHEADER:
|
case IDSPRITEHEADER:
|
||||||
{
|
{
|
||||||
mod->extradata = Mod_LoadSP2(mod->name, buf, modfilelen,
|
mod->extradata = Mod_LoadSP2(mod->name, buf, modfilelen,
|
||||||
(struct image_s **)mod->skins, (findimage_t)R_FindImage,
|
(struct image_s **)mod->skins, (findimage_t)R_FindImageUnsafe,
|
||||||
&(mod->type));
|
&(mod->type));
|
||||||
if (!mod->extradata)
|
if (!mod->extradata)
|
||||||
{
|
{
|
||||||
|
@ -490,7 +490,8 @@ Mod_LoadTexinfo(model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||||
|
|
||||||
if (!image)
|
if (!image)
|
||||||
{
|
{
|
||||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
R_Printf(PRINT_ALL, "%s: Couldn't load %s\n",
|
||||||
|
__func__, in->texture);
|
||||||
image = r_notexture;
|
image = r_notexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ GL3_Draw_InitLocal(void)
|
||||||
draw_chars = FindPic("conchars", (findimage_t)GL3_FindImageUnsafe);
|
draw_chars = FindPic("conchars", (findimage_t)GL3_FindImageUnsafe);
|
||||||
if (!draw_chars)
|
if (!draw_chars)
|
||||||
{
|
{
|
||||||
ri.Sys_Error(ERR_FATAL, "Couldn't load pics/conchars.pcx");
|
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars.pcx",
|
||||||
|
__func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up attribute layout for 2D textured rendering
|
// set up attribute layout for 2D textured rendering
|
||||||
|
|
|
@ -819,6 +819,7 @@ GL3_DrawSpriteModel(entity_t *e, gl3model_t *currentmodel)
|
||||||
dsprframe_t *frame;
|
dsprframe_t *frame;
|
||||||
float *up, *right;
|
float *up, *right;
|
||||||
dsprite_t *psprite;
|
dsprite_t *psprite;
|
||||||
|
gl3image_t *skin;
|
||||||
|
|
||||||
/* don't even bother culling, because it's just
|
/* don't even bother culling, because it's just
|
||||||
a single polygon without a surface cache */
|
a single polygon without a surface cache */
|
||||||
|
@ -842,7 +843,13 @@ GL3_DrawSpriteModel(entity_t *e, gl3model_t *currentmodel)
|
||||||
GL3_UpdateUBO3D();
|
GL3_UpdateUBO3D();
|
||||||
}
|
}
|
||||||
|
|
||||||
GL3_Bind(currentmodel->skins[e->frame]->texnum);
|
skin = currentmodel->skins[e->frame];
|
||||||
|
if (!skin)
|
||||||
|
{
|
||||||
|
skin = gl3_notexture; /* fallback... */
|
||||||
|
}
|
||||||
|
|
||||||
|
GL3_Bind(skin->texnum);
|
||||||
|
|
||||||
if (alpha == 1.0)
|
if (alpha == 1.0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -357,7 +357,8 @@ Mod_LoadTexinfo(gl3model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||||
image = GetTexImage(in->texture, (findimage_t)GL3_FindImageUnsafe);
|
image = GetTexImage(in->texture, (findimage_t)GL3_FindImageUnsafe);
|
||||||
if (!image)
|
if (!image)
|
||||||
{
|
{
|
||||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
R_Printf(PRINT_ALL, "%s: Couldn't load %s\n",
|
||||||
|
__func__, in->texture);
|
||||||
image = gl3_notexture;
|
image = gl3_notexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,7 +1044,7 @@ Mod_ForName (char *name, gl3model_t *parent_model, qboolean crash)
|
||||||
{
|
{
|
||||||
mod->extradata = Mod_LoadMD2(mod->name, buf, modfilelen,
|
mod->extradata = Mod_LoadMD2(mod->name, buf, modfilelen,
|
||||||
mod->mins, mod->maxs,
|
mod->mins, mod->maxs,
|
||||||
(struct image_s **)mod->skins, (findimage_t)GL3_FindImage,
|
(struct image_s **)mod->skins, (findimage_t)GL3_FindImageUnsafe,
|
||||||
&(mod->type));
|
&(mod->type));
|
||||||
if (!mod->extradata)
|
if (!mod->extradata)
|
||||||
{
|
{
|
||||||
|
@ -1056,7 +1057,7 @@ Mod_ForName (char *name, gl3model_t *parent_model, qboolean crash)
|
||||||
case IDSPRITEHEADER:
|
case IDSPRITEHEADER:
|
||||||
{
|
{
|
||||||
mod->extradata = Mod_LoadSP2(mod->name, buf, modfilelen,
|
mod->extradata = Mod_LoadSP2(mod->name, buf, modfilelen,
|
||||||
(struct image_s **)mod->skins, (findimage_t)GL3_FindImage,
|
(struct image_s **)mod->skins, (findimage_t)GL3_FindImageUnsafe,
|
||||||
&(mod->type));
|
&(mod->type));
|
||||||
if (!mod->extradata)
|
if (!mod->extradata)
|
||||||
{
|
{
|
||||||
|
|
|
@ -190,13 +190,15 @@ int GL3_PrepareForWindow(void)
|
||||||
{
|
{
|
||||||
if (libgl == NULL)
|
if (libgl == NULL)
|
||||||
{
|
{
|
||||||
ri.Sys_Error(ERR_FATAL, "Couldn't load libGL: %s!", SDL_GetError());
|
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load libGL: %s!",
|
||||||
|
__func__, SDL_GetError());
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_Printf(PRINT_ALL, "Couldn't load libGL: %s!\n", SDL_GetError());
|
R_Printf(PRINT_ALL, "%s: Couldn't load libGL: %s!\n",
|
||||||
|
__func__, SDL_GetError());
|
||||||
R_Printf(PRINT_ALL, "Retrying with default...\n");
|
R_Printf(PRINT_ALL, "Retrying with default...\n");
|
||||||
|
|
||||||
ri.Cvar_Set("gl3_libgl", "");
|
ri.Cvar_Set("gl3_libgl", "");
|
||||||
|
|
|
@ -504,7 +504,9 @@ R_AliasSetupSkin(const entity_t *currententity, const model_t *currentmodel)
|
||||||
image_t *pskindesc;
|
image_t *pskindesc;
|
||||||
|
|
||||||
if (currententity->skin)
|
if (currententity->skin)
|
||||||
|
{
|
||||||
pskindesc = currententity->skin;
|
pskindesc = currententity->skin;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int skinnum;
|
int skinnum;
|
||||||
|
|
|
@ -200,7 +200,7 @@ Mod_ForName (char *name, model_t *parent_model, qboolean crash)
|
||||||
{
|
{
|
||||||
mod->extradata = Mod_LoadMD2(mod->name, buf, modfilelen,
|
mod->extradata = Mod_LoadMD2(mod->name, buf, modfilelen,
|
||||||
mod->mins, mod->maxs,
|
mod->mins, mod->maxs,
|
||||||
(struct image_s **)mod->skins, (findimage_t)R_FindImage,
|
(struct image_s **)mod->skins, (findimage_t)R_FindImageUnsafe,
|
||||||
&(mod->type));
|
&(mod->type));
|
||||||
if (!mod->extradata)
|
if (!mod->extradata)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +213,7 @@ Mod_ForName (char *name, model_t *parent_model, qboolean crash)
|
||||||
case IDSPRITEHEADER:
|
case IDSPRITEHEADER:
|
||||||
{
|
{
|
||||||
mod->extradata = Mod_LoadSP2(mod->name, buf, modfilelen,
|
mod->extradata = Mod_LoadSP2(mod->name, buf, modfilelen,
|
||||||
(struct image_s **)mod->skins, (findimage_t)R_FindImage,
|
(struct image_s **)mod->skins, (findimage_t)R_FindImageUnsafe,
|
||||||
&(mod->type));
|
&(mod->type));
|
||||||
if (!mod->extradata)
|
if (!mod->extradata)
|
||||||
{
|
{
|
||||||
|
@ -534,9 +534,8 @@ Mod_LoadTexinfo (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||||
image = GetTexImage(in->texture, (findimage_t)R_FindImageUnsafe);
|
image = GetTexImage(in->texture, (findimage_t)R_FindImageUnsafe);
|
||||||
if (!image)
|
if (!image)
|
||||||
{
|
{
|
||||||
R_Printf(PRINT_ALL, "Couldn't load %s\n", in->texture);
|
R_Printf(PRINT_ALL, "%s: Couldn't load %s\n", __func__, in->texture);
|
||||||
image = r_notexture_mip;
|
image = r_notexture_mip;
|
||||||
out->flags = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out->image = image;
|
out->image = image;
|
||||||
|
|
|
@ -39,16 +39,22 @@ R_DrawSprite(entity_t *currententity, const model_t *currentmodel)
|
||||||
vec3_t left, up, right, down;
|
vec3_t left, up, right, down;
|
||||||
dsprite_t *s_psprite;
|
dsprite_t *s_psprite;
|
||||||
dsprframe_t *s_psprframe;
|
dsprframe_t *s_psprframe;
|
||||||
|
image_t *skin;
|
||||||
|
|
||||||
s_psprite = (dsprite_t *)currentmodel->extradata;
|
s_psprite = (dsprite_t *)currentmodel->extradata;
|
||||||
currententity->frame %= s_psprite->numframes;
|
currententity->frame %= s_psprite->numframes;
|
||||||
|
|
||||||
s_psprframe = &s_psprite->frames[currententity->frame];
|
s_psprframe = &s_psprite->frames[currententity->frame];
|
||||||
|
|
||||||
r_polydesc.pixels = currentmodel->skins[currententity->frame]->pixels[0];
|
skin = currentmodel->skins[currententity->frame];
|
||||||
r_polydesc.pixel_width = s_psprframe->width;
|
if (!skin)
|
||||||
r_polydesc.pixel_height = s_psprframe->height;
|
{
|
||||||
|
skin = r_notexture_mip;
|
||||||
|
}
|
||||||
|
|
||||||
|
r_polydesc.pixels = skin->pixels[0];
|
||||||
|
r_polydesc.pixel_width = min(s_psprframe->width, skin->width);
|
||||||
|
r_polydesc.pixel_height = min(s_psprframe->height, skin->height);
|
||||||
r_polydesc.dist = 0;
|
r_polydesc.dist = 0;
|
||||||
|
|
||||||
// generate the sprite's axes, completely parallel to the viewplane.
|
// generate the sprite's axes, completely parallel to the viewplane.
|
||||||
|
|
Loading…
Reference in a new issue