mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
Make top/bottom color work for GLSL.
Works quite nicely (love those colormaps).
This commit is contained in:
parent
9a4b065eaf
commit
08990ebb5a
10 changed files with 281 additions and 10 deletions
|
@ -57,7 +57,10 @@ typedef struct skin_s {
|
|||
} skin_t;
|
||||
|
||||
skin_t *Skin_SetColormap (skin_t *skin, int cmap);
|
||||
void Skin_SetColormap_ (skin_t *skin, int cmap);
|
||||
void Skin_SetTranslation (int cmap, int top, int bottom);
|
||||
void Skin_ProcessTranslation (int cmap, const byte *translation);
|
||||
void Skin_InitTranslations (void);
|
||||
|
||||
extern byte player_8bit_texels[640 * 400];
|
||||
extern skin_t skin_cache[MAX_CACHED_SKINS];
|
||||
|
|
|
@ -18,19 +18,19 @@ gl_LIBS= \
|
|||
alias/libalias_gl.la brush/libbrush_gl.la sprite/libsprite_gl.la
|
||||
libQFmodels_gl_la_LDFLAGS= -version-info $(QUAKE_LIBRARY_VERSION_INFO) -rpath $(libdir)
|
||||
libQFmodels_gl_la_LIBADD= $(gl_LIBS) $(top_builddir)/libs/util/libQFutil.la
|
||||
libQFmodels_gl_la_SOURCES= $(models_sources) gl_model_fullbright.c
|
||||
libQFmodels_gl_la_SOURCES= $(models_sources) gl_model_fullbright.c gl_skin.c
|
||||
libQFmodels_gl_la_DEPENDENCIES= $(gl_LIBS)
|
||||
|
||||
glsl_LIBS= \
|
||||
alias/libalias_glsl.la brush/libbrush_glsl.la sprite/libsprite_glsl.la
|
||||
libQFmodels_glsl_la_LDFLAGS= -version-info $(QUAKE_LIBRARY_VERSION_INFO) -rpath $(libdir)
|
||||
libQFmodels_glsl_la_LIBADD= $(glsl_LIBS) $(top_builddir)/libs/util/libQFutil.la
|
||||
libQFmodels_glsl_la_SOURCES= $(models_sources) gl_model_fullbright.c
|
||||
libQFmodels_glsl_la_SOURCES= $(models_sources) glsl_skin.c
|
||||
libQFmodels_glsl_la_DEPENDENCIES= $(glsl_LIBS)
|
||||
|
||||
sw_LIBS= \
|
||||
alias/libalias_sw.la brush/libbrush_sw.la sprite/libsprite_sw.la
|
||||
libQFmodels_sw_la_LDFLAGS= -version-info $(QUAKE_LIBRARY_VERSION_INFO) -rpath $(libdir) -no-undefined
|
||||
libQFmodels_sw_la_LIBADD= $(sw_LIBS) $(top_builddir)/libs/util/libQFutil.la
|
||||
libQFmodels_sw_la_SOURCES= $(models_sources)
|
||||
libQFmodels_sw_la_SOURCES= $(models_sources) sw_skin.c
|
||||
libQFmodels_sw_la_DEPENDENCIES= $(sw_LIBS)
|
||||
|
|
70
libs/models/gl_skin.c
Normal file
70
libs/models/gl_skin.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
glsl_skin.c
|
||||
|
||||
GLSL Skin support
|
||||
|
||||
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
|
||||
|
||||
Author: Bill Currie <bill@taniwha.org>
|
||||
Date: 2012/1/23
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include "string.h"
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include "strings.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/image.h"
|
||||
#include "QF/model.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/GL/defines.h"
|
||||
#include "QF/GL/funcs.h"
|
||||
|
||||
// if more than 32 clients are to be supported, then this will need to be
|
||||
// updated
|
||||
#define MAX_TRANSLATIONS 32
|
||||
|
||||
void
|
||||
Skin_ProcessTranslation (int cmap, const byte *translation)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Skin_SetColormap_ (skin_t *skin, int cmap)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Skin_InitTranslations (void)
|
||||
{
|
||||
}
|
128
libs/models/glsl_skin.c
Normal file
128
libs/models/glsl_skin.c
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
glsl_skin.c
|
||||
|
||||
GLSL Skin support
|
||||
|
||||
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
|
||||
|
||||
Author: Bill Currie <bill@taniwha.org>
|
||||
Date: 2012/1/23
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include "string.h"
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include "strings.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/image.h"
|
||||
#include "QF/model.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/GLSL/defines.h"
|
||||
#include "QF/GLSL/funcs.h"
|
||||
|
||||
// if more than 32 clients are to be supported, then this will need to be
|
||||
// updated
|
||||
#define MAX_TRANSLATIONS 32
|
||||
static GLuint cmap_tex[MAX_TRANSLATIONS];
|
||||
|
||||
void
|
||||
Skin_ProcessTranslation (int cmap, const byte *translation)
|
||||
{
|
||||
byte top[4 * VID_GRADES * 16];
|
||||
byte bottom[4 * VID_GRADES * 16];
|
||||
const byte *src;
|
||||
byte *dst;
|
||||
int i, j;
|
||||
|
||||
src = translation + TOP_RANGE;
|
||||
for (i = 0, dst = top; i < VID_GRADES; i++, src += 256 - 16) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
byte c = *src++;
|
||||
byte *in = vid.palette + c * 3;
|
||||
*dst++ = *in++;
|
||||
*dst++ = *in++;
|
||||
*dst++ = *in++;
|
||||
*dst++ = 255; // alpha = 1
|
||||
}
|
||||
}
|
||||
src = translation + BOTTOM_RANGE;
|
||||
for (i = 0, dst = bottom; i < VID_GRADES; i++, src += 256 - 16) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
byte c = *src++;
|
||||
byte *in = vid.palette + c * 3;
|
||||
*dst++ = *in++;
|
||||
*dst++ = *in++;
|
||||
*dst++ = *in++;
|
||||
*dst++ = 255; // alpha = 1
|
||||
}
|
||||
}
|
||||
qfglBindTexture (GL_TEXTURE_2D, cmap_tex[cmap - 1]);
|
||||
qfglTexSubImage2D (GL_TEXTURE_2D, 0, TOP_RANGE, 0, 16, VID_GRADES,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, top);
|
||||
qfglTexSubImage2D (GL_TEXTURE_2D, 0, BOTTOM_RANGE, 0, 16, VID_GRADES,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, bottom);
|
||||
}
|
||||
|
||||
void
|
||||
Skin_SetColormap_ (skin_t *skin, int cmap)
|
||||
{
|
||||
if (cmap)
|
||||
skin->auxtex = cmap_tex[cmap - 1];
|
||||
}
|
||||
|
||||
void
|
||||
Skin_InitTranslations (void)
|
||||
{
|
||||
byte map[4 * VID_GRADES * 256];
|
||||
byte *src, *dst;
|
||||
int i;
|
||||
|
||||
for (i = 0, dst = map, src = vid.colormap8; i < 256 * VID_GRADES; i++) {
|
||||
byte c = *src++;
|
||||
byte *in = vid.palette + c * 3;
|
||||
*dst++ = *in++;
|
||||
*dst++ = *in++;
|
||||
*dst++ = *in++;
|
||||
*dst++ = 255; // alpha = 1
|
||||
}
|
||||
qfglGenTextures (MAX_TRANSLATIONS, cmap_tex);
|
||||
for (i = 0; i < MAX_TRANSLATIONS; i++) {
|
||||
qfglBindTexture (GL_TEXTURE_2D, cmap_tex[i]);
|
||||
qfglTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 256, VID_GRADES, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, map);
|
||||
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
}
|
|
@ -94,6 +94,7 @@ Skin_SetTranslation (int cmap, int top, int bottom)
|
|||
for (j = 0; j < 16; j++)
|
||||
dest[BOTTOM_RANGE + j] = source[bottom + 15 - j];
|
||||
}
|
||||
Skin_ProcessTranslation (cmap, translations[cmap - 1]);
|
||||
}
|
||||
|
||||
skin_t *
|
||||
|
@ -102,9 +103,18 @@ Skin_SetColormap (skin_t *skin, int cmap)
|
|||
if (!skin)
|
||||
skin = new_skin ();
|
||||
skin->colormap = 0;
|
||||
if (cmap < 0 || cmap > MAX_TRANSLATIONS)
|
||||
if (cmap < 0 || cmap > MAX_TRANSLATIONS) {
|
||||
Sys_MaskPrintf (SYS_SKIN, "invalid skin slot: %d\n", cmap);
|
||||
if (cmap > 0 && cmap <= MAX_TRANSLATIONS)
|
||||
cmap = 0;
|
||||
}
|
||||
if (cmap)
|
||||
skin->colormap = translations[cmap - 1];
|
||||
Skin_SetColormap_ (skin, cmap);
|
||||
return skin;
|
||||
}
|
||||
|
||||
void
|
||||
Skin_Init (void)
|
||||
{
|
||||
Skin_InitTranslations ();
|
||||
}
|
||||
|
|
51
libs/models/sw_skin.c
Normal file
51
libs/models/sw_skin.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
sw_skin.c
|
||||
|
||||
SW Skin support
|
||||
|
||||
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
|
||||
|
||||
Author: Bill Currie <bill@taniwha.org>
|
||||
Date: 2012/1/23
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||
|
||||
#include "QF/skin.h"
|
||||
|
||||
void
|
||||
Skin_ProcessTranslation (int cmap, const byte *translation)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Skin_SetColormap_ (skin_t *skin, int cmap)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Skin_InitTranslations (void)
|
||||
{
|
||||
}
|
|
@ -203,6 +203,7 @@ R_DrawAlias (void)
|
|||
vec_t norm_mat[9];
|
||||
mat4_t mvp_mat;
|
||||
int skin_tex;
|
||||
int colormap;
|
||||
aliasvrt_t *pose1 = 0; // VBO's are null based
|
||||
aliasvrt_t *pose2 = 0; // VBO's are null based
|
||||
|
||||
|
@ -226,7 +227,10 @@ R_DrawAlias (void)
|
|||
Mat4Mult (ent->transform, mvp_mat, mvp_mat);
|
||||
Mat4Mult (alias_vp, mvp_mat, mvp_mat);
|
||||
|
||||
if (ent->skin) {
|
||||
colormap = glsl_colormap;
|
||||
if (ent->skin && ent->skin->auxtex)
|
||||
colormap = ent->skin->auxtex;
|
||||
if (ent->skin && ent->skin->texnum) {
|
||||
skin_t *skin = ent->skin;
|
||||
skin_tex = skin->texnum;
|
||||
} else {
|
||||
|
@ -242,6 +246,9 @@ R_DrawAlias (void)
|
|||
skin_size[0] = hdr->mdl.skinwidth;
|
||||
skin_size[1] = hdr->mdl.skinheight;
|
||||
|
||||
qfglActiveTexture (GL_TEXTURE0 + 1);
|
||||
qfglBindTexture (GL_TEXTURE_2D, colormap);
|
||||
qfglActiveTexture (GL_TEXTURE0 + 0);
|
||||
qfglBindTexture (GL_TEXTURE_2D, skin_tex);
|
||||
|
||||
#ifndef TETRAHEDRON
|
||||
|
@ -297,7 +304,6 @@ R_AliasBegin (void)
|
|||
qfglUniform1i (quake_mdl.colormap.location, 1);
|
||||
qfglActiveTexture (GL_TEXTURE0 + 1);
|
||||
qfglEnable (GL_TEXTURE_2D);
|
||||
qfglBindTexture (GL_TEXTURE_2D, glsl_colormap);
|
||||
|
||||
qfglUniform1i (quake_mdl.skin.location, 0);
|
||||
qfglActiveTexture (GL_TEXTURE0 + 0);
|
||||
|
|
|
@ -403,7 +403,8 @@ CL_ClearState (void)
|
|||
memset (&cl, 0, sizeof (cl));
|
||||
r_force_fullscreen = 0;
|
||||
|
||||
// Note: we should probably hack around this and give diff values for diff gamedirs
|
||||
// Note: we should probably hack around this and give diff values for
|
||||
// diff gamedirs
|
||||
cl.fpd = FPD_DEFAULT;
|
||||
cl.fbskins = FBSKINS_DEFAULT;
|
||||
|
||||
|
|
|
@ -1097,7 +1097,8 @@ CL_ProcessUserInfo (int slot, player_info_t *player)
|
|||
|
||||
s = Info_ValueForKey (player->userinfo, "name");
|
||||
if (!*s && player->userid)
|
||||
Info_SetValueForKey (player->userinfo, "name", va ("user-%i [exploit]", player->userid), 1);
|
||||
Info_SetValueForKey (player->userinfo, "name",
|
||||
va ("user-%i [exploit]", player->userid), 1);
|
||||
strncpy (player->name, Info_ValueForKey (player->userinfo, "name"),
|
||||
sizeof (player->name) - 1);
|
||||
player->_topcolor = player->_bottomcolor = -1;
|
||||
|
|
|
@ -42,6 +42,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
#include "QF/cvar.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
|
@ -192,7 +193,7 @@ skin_f (cvar_t *var)
|
|||
void
|
||||
CL_Skin_Init (void)
|
||||
{
|
||||
//Skin_Init ();
|
||||
Skin_Init ();
|
||||
//Skin_Init_Cvars ();
|
||||
Cmd_AddCommand ("skins", CL_Skins_f, "Download all skins that are "
|
||||
"currently in use");
|
||||
|
|
Loading…
Reference in a new issue