e->render.flags = e->state_current.flags;
e->render.effects = e->state_current.effects;
VectorScale(e->state_current.colormod, (1.0f / 32.0f), e->render.colormod);
+ e->render.entitynumber = e - cl.entities;
if (e->state_current.flags & RENDER_COLORMAPPED)
{
int cb;
model_t *model;
// current uninterpolated animation frame (for things which do not use interpolation)
int frame;
+ // number of the entity represents, or 0 for non-network entities
+ int entitynumber;
// entity shirt and pants colors (-1 if not colormapped)
int colormap;
// literal colors for renderer
// currently selected permutation
r_glsl_permutation_t *r_glsl_permutation;
+char r_qwskincache[MAX_SCOREBOARD][MAX_QPATH];
+skinframe_t *r_qwskincache_skinframe[MAX_SCOREBOARD];
+
// vertex coordinates for a quad that covers the screen exactly
const static float r_screenvertex3f[12] =
{
return item;
}
-skinframe_t *R_SkinFrame_LoadExternal(const char *name, int textureflags)
+skinframe_t *R_SkinFrame_LoadExternal(const char *name, int textureflags, qboolean complain)
{
// FIXME: it should be possible to disable loading various layers using
// cvars, to prevent wasted loading time and memory usage if the user does
if (skinframe && skinframe->base)
return skinframe;
- basepixels = loadimagepixels(name, false, 0, 0);
+ basepixels = loadimagepixels(name, complain, 0, 0);
if (basepixels == NULL)
return NULL;
r_refdef.fogmasktable[x] = bound(0, alpha, 1);
}
+ memset(r_qwskincache, 0, sizeof(r_qwskincache));
+ memset(r_qwskincache_skinframe, 0, sizeof(r_qwskincache_skinframe));
+
// set up r_skinframe loading system for textures
memset(&r_skinframe, 0, sizeof(r_skinframe));
r_skinframe.loadsequence = 1;
void gl_main_shutdown(void)
{
+ memset(r_qwskincache, 0, sizeof(r_qwskincache));
+ memset(r_qwskincache_skinframe, 0, sizeof(r_qwskincache_skinframe));
+
// clear out the r_skinframe state
Mem_ExpandableArray_FreeArray(&r_skinframe.array);
memset(&r_skinframe, 0, sizeof(r_skinframe));
void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
{
+ int i;
model_t *model = ent->model;
// switch to an alternate material if this is a q1bsp animated material
texture->currentframe = t;
}
- // pick a new currentskinframe if the material is animated
- if (t->numskinframes >= 2)
+ // update currentskinframe to be a qw skin or animation frame
+ if ((i = ent->entitynumber - 1) >= 0 && i < cl.maxclients)
+ {
+ if (strcmp(r_qwskincache[i], cl.scores[i].qw_skin))
+ {
+ strlcpy(r_qwskincache[i], cl.scores[i].qw_skin, sizeof(r_qwskincache[i]));
+ Con_DPrintf("loading skins/%s\n", r_qwskincache[i]);
+ r_qwskincache_skinframe[i] = R_SkinFrame_LoadExternal(va("skins/%s", r_qwskincache[i]), TEXF_PRECACHE | (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_PICMIP, developer.integer > 0);
+ }
+ t->currentskinframe = r_qwskincache_skinframe[i];
+ if (t->currentskinframe == NULL)
+ t->currentskinframe = t->skinframes[(int)(t->skinframerate * (cl.time - ent->frame2time)) % t->numskinframes];
+ }
+ else if (t->numskinframes >= 2)
t->currentskinframe = t->skinframes[(int)(t->skinframerate * (cl.time - ent->frame2time)) % t->numskinframes];
if (t->backgroundnumskinframes >= 2)
t->backgroundcurrentskinframe = t->backgroundskinframes[(int)(t->backgroundskinframerate * (cl.time - ent->frame2time)) % t->backgroundnumskinframes];
{
if(t->width && !strcasecmp(t->name, r))
{
- if ((skinframe = R_SkinFrame_LoadExternal((char*)newt, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP)))
+ if ((skinframe = R_SkinFrame_LoadExternal((char*)newt, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, true)))
{
t->skinframes[0] = skinframe;
Con_Printf("%s replaced with %s\n", r, newt);
// leave the skin unitialized (nodraw) if the replacement is "common/nodraw" or "textures/common/nodraw"
if (!strcmp(skinfileitem->name, meshname) && strcmp(skinfileitem->replacement, "common/nodraw") && strcmp(skinfileitem->replacement, "textures/common/nodraw"))
{
- tempskinframe = R_SkinFrame_LoadExternal(skinfileitem->replacement, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP);
+ tempskinframe = R_SkinFrame_LoadExternal(skinfileitem->replacement, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false);
if (!tempskinframe)
if (cls.state != ca_dedicated)
Con_DPrintf("mesh \"%s\": failed to load skin #%i \"%s\"\n", meshname, i, skinfileitem->replacement);
}
else
{
- tempskinframe = R_SkinFrame_LoadExternal(shadername, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP);
+ tempskinframe = R_SkinFrame_LoadExternal(shadername, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false);
if (!tempskinframe)
if (cls.state != ca_dedicated)
Con_Printf("Can't find texture \"%s\" for mesh \"%s\", using grey checkerboard\n", shadername, meshname);
sprintf (name, "%s_%i_%i", loadmodel->name, i, j);
else
sprintf (name, "%s_%i", loadmodel->name, i);
- tempskinframe = R_SkinFrame_LoadExternal(name, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PICMIP);
+ tempskinframe = R_SkinFrame_LoadExternal(name, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PICMIP, false);
if (!tempskinframe)
tempskinframe = R_SkinFrame_LoadInternal(name, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_PICMIP, true, r_fullbrights.integer, (unsigned char *)datapointer, skinwidth, skinheight, 8, NULL, NULL);
Mod_BuildAliasSkinFromSkinFrame(loadmodel->data_textures + totalskins * loadmodel->num_surfaces, tempskinframe);
}
// check for skins that don't exist in the model, but do exist as external images
// (this was added because yummyluv kept pestering me about support for it)
- while ((tempskinframe = R_SkinFrame_LoadExternal(va("%s_%i", loadmodel->name, loadmodel->numskins), (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PICMIP)))
+ while ((tempskinframe = R_SkinFrame_LoadExternal(va("%s_%i", loadmodel->name, loadmodel->numskins), (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PICMIP, false)))
{
// expand the arrays to make room
tempskinscenes = loadmodel->skinscenes;
loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t));
for (i = 0;i < loadmodel->numskins;i++, inskin += MD2_SKINNAME)
{
- tempskinframe = R_SkinFrame_LoadExternal(inskin, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP);
+ tempskinframe = R_SkinFrame_LoadExternal(inskin, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false);
if (!tempskinframe)
Con_Printf("%s is missing skin \"%s\"\n", loadmodel->name, inskin);
Mod_BuildAliasSkinFromSkinFrame(loadmodel->data_textures + i * loadmodel->num_surfaces, tempskinframe);
}
else
{
- skinframe = R_SkinFrame_LoadExternal(gamemode == GAME_TENEBRAE ? tx->name : va("textures/%s/%s", mapname, tx->name), TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP);
+ skinframe = R_SkinFrame_LoadExternal(gamemode == GAME_TENEBRAE ? tx->name : va("textures/%s/%s", mapname, tx->name), TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false);
if (!skinframe)
- skinframe = R_SkinFrame_LoadExternal(gamemode == GAME_TENEBRAE ? tx->name : va("textures/%s", tx->name), TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP);
+ skinframe = R_SkinFrame_LoadExternal(gamemode == GAME_TENEBRAE ? tx->name : va("textures/%s", tx->name), TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false);
if (!skinframe)
{
// did not find external texture, load it from the bsp or wad3
out->numskinframes = shader->primarylayer->numframes;
out->skinframerate = shader->primarylayer->framerate;
for (j = 0;j < shader->primarylayer->numframes;j++)
- if (!(out->skinframes[j] = R_SkinFrame_LoadExternal(shader->primarylayer->texturename[j], ((shader->surfaceparms & Q3SURFACEPARM_NOMIPMAPS) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (shader->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP) | (shader->primarylayer->clampmap ? TEXF_CLAMP : 0))))
+ if (!(out->skinframes[j] = R_SkinFrame_LoadExternal(shader->primarylayer->texturename[j], ((shader->surfaceparms & Q3SURFACEPARM_NOMIPMAPS) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (shader->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP) | (shader->primarylayer->clampmap ? TEXF_CLAMP : 0), false)))
Con_DPrintf("%s: could not load texture \"%s\" (frame %i) for shader \"%s\"\n", loadmodel->name, shader->primarylayer->texturename[j], j, out->name);
}
if (shader->backgroundlayer)
out->backgroundskinframerate = shader->backgroundlayer->framerate;
for (j = 0;j < shader->backgroundlayer->numframes;j++)
{
- if (!(out->backgroundskinframes[j] = R_SkinFrame_LoadExternal(shader->backgroundlayer->texturename[j], ((shader->surfaceparms & Q3SURFACEPARM_NOMIPMAPS) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (shader->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP) | (shader->backgroundlayer->clampmap ? TEXF_CLAMP : 0))))
+ if (!(out->backgroundskinframes[j] = R_SkinFrame_LoadExternal(shader->backgroundlayer->texturename[j], ((shader->surfaceparms & Q3SURFACEPARM_NOMIPMAPS) ? 0 : TEXF_MIPMAP) | TEXF_ALPHA | TEXF_PRECACHE | (shader->textureflags & Q3TEXTUREFLAG_NOPICMIP ? 0 : TEXF_PICMIP) | (shader->backgroundlayer->clampmap ? TEXF_CLAMP : 0), false)))
{
Con_DPrintf("%s: could not load texture \"%s\" (frame %i) for shader \"%s\"\n", loadmodel->name, shader->backgroundlayer->texturename[j], j, out->name);
out->backgroundskinframes[j] = R_SkinFrame_LoadMissing();
//if (R_TextureHasAlpha(out->skinframes[0].base))
// out->surfaceparms |= Q3SURFACEPARM_TRANS;
out->numskinframes = 1;
- if (!(out->skinframes[0] = R_SkinFrame_LoadExternal(out->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP)))
+ if (!(out->skinframes[0] = R_SkinFrame_LoadExternal(out->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, false)))
Con_DPrintf("%s: could not load texture for missing shader \"%s\"\n", loadmodel->name, out->name);
}
// init the animation variables
sprintf (name, "%s_%i_%i", loadmodel->name, i, j);
else
sprintf (name, "%s_%i", loadmodel->name, i);
- if (!(skinframe = R_SkinFrame_LoadExternal(name, texflags)))
+ if (!(skinframe = R_SkinFrame_LoadExternal(name, texflags, false)))
{
if (groupframes > 1)
sprintf (fogname, "%s_%i_%ifog", loadmodel->name, i, j);
{
const dsprite2frame_t *pinframe;
pinframe = &pinqsprite->frames[i];
- if (!(skinframe = R_SkinFrame_LoadExternal(pinframe->name, texflags)))
+ if (!(skinframe = R_SkinFrame_LoadExternal(pinframe->name, texflags, false)))
{
Con_Printf("Mod_IDS2_Load: failed to load %s", pinframe->name);
skinframe = R_SkinFrame_LoadMissing();
void R_SkinFrame_MarkUsed(skinframe_t *skinframe);
void R_SkinFrame_Purge(void);
skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qboolean add);
-skinframe_t *R_SkinFrame_LoadExternal(const char *name, int textureflags);
+skinframe_t *R_SkinFrame_LoadExternal(const char *name, int textureflags, qboolean complain);
skinframe_t *R_SkinFrame_LoadInternal(const char *name, int textureflags, int loadpantsandshirt, int loadglowtexture, const unsigned char *skindata, int width, int height, int bitsperpixel, const unsigned int *palette, const unsigned int *alphapalette);
skinframe_t *R_SkinFrame_LoadMissing(void);