mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
Start working on the new GL skin code.
This commit is contained in:
parent
695b38e5e5
commit
df87cffe15
5 changed files with 71 additions and 8 deletions
|
@ -64,6 +64,9 @@ void Skin_SetupSkin (skin_t *skin, int cmap);
|
||||||
void Skin_SetTranslation (int cmap, int top, int bottom);
|
void Skin_SetTranslation (int cmap, int top, int bottom);
|
||||||
void Skin_ProcessTranslation (int cmap, const byte *translation);
|
void Skin_ProcessTranslation (int cmap, const byte *translation);
|
||||||
void Skin_InitTranslations (void);
|
void Skin_InitTranslations (void);
|
||||||
|
int Skin_Init_Textures (int base); // only GL
|
||||||
|
void Skin_SetPlayerSkin (int width, int height, const byte *data); // only GL
|
||||||
|
|
||||||
void Skin_Init (void);
|
void Skin_Init (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,7 +52,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
VISIBLE byte player_8bit_texels[640 * 400];
|
|
||||||
int alias_cache = 1;
|
int alias_cache = 1;
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
@ -70,11 +69,9 @@ Mod_LoadSkin (byte * skin, int skinsize, int snum, int gnum, qboolean group,
|
||||||
|
|
||||||
Mod_FloodFillSkin (pskin, pheader->mdl.skinwidth, pheader->mdl.skinheight);
|
Mod_FloodFillSkin (pskin, pheader->mdl.skinwidth, pheader->mdl.skinheight);
|
||||||
// save 8 bit texels for the player model to remap
|
// save 8 bit texels for the player model to remap
|
||||||
if (strequal (loadmodel->name, "progs/player.mdl")) {
|
if (strequal (loadmodel->name, "progs/player.mdl"))
|
||||||
if (skinsize > (int) sizeof (player_8bit_texels))
|
Skin_SetPlayerSkin (pheader->mdl.skinwidth, pheader->mdl.skinheight,
|
||||||
Sys_Error ("Player skin too large");
|
pskin);
|
||||||
memcpy (player_8bit_texels, pskin, skinsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
QFS_StripExtension (loadmodel->name, modname);
|
QFS_StripExtension (loadmodel->name, modname);
|
||||||
|
|
||||||
|
|
|
@ -50,17 +50,64 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||||
#include "QF/GL/defines.h"
|
#include "QF/GL/defines.h"
|
||||||
#include "QF/GL/funcs.h"
|
#include "QF/GL/funcs.h"
|
||||||
|
|
||||||
|
static int skin_textures;
|
||||||
|
static int skin_fb_textures;
|
||||||
|
static byte skin_cmap[MAX_TRANSLATIONS][256];
|
||||||
|
static tex_t *skin_tex[MAX_TRANSLATIONS];
|
||||||
|
static tex_t *player_tex;
|
||||||
|
|
||||||
|
void
|
||||||
|
Skin_SetPlayerSkin (int width, int height, const byte *data)
|
||||||
|
{
|
||||||
|
int size = width * height;
|
||||||
|
|
||||||
|
player_tex = realloc (player_tex, field_offset(tex_t, data[size]));
|
||||||
|
player_tex->width = width;
|
||||||
|
player_tex->height = height;
|
||||||
|
player_tex->format = tex_palette;
|
||||||
|
player_tex->palette = vid.palette;
|
||||||
|
memcpy (player_tex->data, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Skin_ProcessTranslation (int cmap, const byte *translation)
|
Skin_ProcessTranslation (int cmap, const byte *translation)
|
||||||
{
|
{
|
||||||
|
int changed;
|
||||||
|
|
||||||
|
// simplify cmap usage (texture offset/array index)
|
||||||
|
cmap--;
|
||||||
|
// skip over the colormap (GL can't use it) to the translated palette
|
||||||
|
translation += VID_GRADES * 256;
|
||||||
|
changed = memcmp (skin_cmap[cmap], translation, 256);
|
||||||
|
memcpy (skin_cmap[cmap], translation, 256);
|
||||||
|
if (!changed)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Skin_SetupSkin (skin_t *skin, int cmap)
|
Skin_SetupSkin (skin_t *skin, int cmap)
|
||||||
{
|
{
|
||||||
|
int changed;
|
||||||
|
|
||||||
|
// simplify cmap usage (texture offset/array index)
|
||||||
|
cmap--;
|
||||||
|
changed = (skin_tex[cmap] != skin->texels);
|
||||||
|
skin_tex[cmap] = skin->texels;
|
||||||
|
if (!changed)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Skin_InitTranslations (void)
|
Skin_InitTranslations (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Skin_Init_Textures (int base)
|
||||||
|
{
|
||||||
|
skin_textures = base;
|
||||||
|
base += MAX_TRANSLATIONS;
|
||||||
|
skin_fb_textures = base;
|
||||||
|
base += MAX_TRANSLATIONS;
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
|
@ -59,7 +59,9 @@ typedef struct skinbank_s {
|
||||||
int users;
|
int users;
|
||||||
} skinbank_t;
|
} skinbank_t;
|
||||||
|
|
||||||
static byte translations[MAX_TRANSLATIONS][VID_GRADES * 256];
|
// each translation has one extra line for palette (vs colormap) based
|
||||||
|
// translation (for 32bit rendering)
|
||||||
|
static byte translations[MAX_TRANSLATIONS][(VID_GRADES + 1) * 256];
|
||||||
static hashtab_t *skin_cache;
|
static hashtab_t *skin_cache;
|
||||||
|
|
||||||
static skin_t *
|
static skin_t *
|
||||||
|
@ -102,6 +104,20 @@ Skin_SetTranslation (int cmap, int top, int bottom)
|
||||||
for (j = 0; j < 16; j++)
|
for (j = 0; j < 16; j++)
|
||||||
dest[BOTTOM_RANGE + j] = source[bottom + 15 - j];
|
dest[BOTTOM_RANGE + j] = source[bottom + 15 - j];
|
||||||
}
|
}
|
||||||
|
// set up the palette translation
|
||||||
|
// dest currently points to the palette line
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
dest[i] = i;
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
if (top < 128)
|
||||||
|
dest[TOP_RANGE + i] = top + i;
|
||||||
|
else
|
||||||
|
dest[TOP_RANGE + i] = top + 15 - i;
|
||||||
|
if (bottom < 128)
|
||||||
|
dest[BOTTOM_RANGE + i] = bottom + i;
|
||||||
|
else
|
||||||
|
dest[BOTTOM_RANGE + i] = bottom + 15 - i;
|
||||||
|
}
|
||||||
Skin_ProcessTranslation (cmap, translations[cmap - 1]);
|
Skin_ProcessTranslation (cmap, translations[cmap - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ R_Init (void)
|
||||||
|
|
||||||
texture_extension_number = R_InitGraphTextures (texture_extension_number);
|
texture_extension_number = R_InitGraphTextures (texture_extension_number);
|
||||||
|
|
||||||
//FIXME texture_extension_number = Skin_Init_Textures (texture_extension_number);
|
texture_extension_number = Skin_Init_Textures (texture_extension_number);
|
||||||
|
|
||||||
r_init = 1;
|
r_init = 1;
|
||||||
R_InitParticles ();
|
R_InitParticles ();
|
||||||
|
|
Loading…
Reference in a new issue