mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 15:21:44 +00:00
Image: Share loadSky textures
Add support of `r_palettedtextures` to all renders.
This commit is contained in:
parent
18bc788335
commit
f6f6639a89
14 changed files with 146 additions and 68 deletions
|
@ -560,3 +560,41 @@ LoadImage(const char *name, const char* namewe, const char *ext, imagetype_t typ
|
|||
|
||||
return image;
|
||||
}
|
||||
|
||||
struct image_s*
|
||||
GetSkyImage(const char *skyname, const char* surfname, qboolean palettedtexture,
|
||||
findimage_t find_image)
|
||||
{
|
||||
struct image_s *image = NULL;
|
||||
char pathname[MAX_QPATH];
|
||||
|
||||
if (palettedtexture)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "env/%s%s.pcx",
|
||||
skyname, surfname);
|
||||
image = find_image(pathname, it_sky);
|
||||
}
|
||||
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "env/%s%s.tga",
|
||||
skyname, surfname);
|
||||
image = find_image(pathname, it_sky);
|
||||
}
|
||||
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "pics/Skies/%s%s.m32",
|
||||
skyname, surfname);
|
||||
image = find_image(pathname, it_sky);
|
||||
}
|
||||
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "pics/Skies/%s%s.m8",
|
||||
skyname, surfname);
|
||||
image = find_image(pathname, it_sky);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
|
|
@ -854,7 +854,7 @@ R_Upload8(byte *data, int width, int height, qboolean mipmap, qboolean is_sky)
|
|||
* This is also used as an entry point for the generated r_notexture
|
||||
*/
|
||||
image_t *
|
||||
R_LoadPic(char *name, byte *pic, int width, int realwidth,
|
||||
R_LoadPic(const char *name, byte *pic, int width, int realwidth,
|
||||
int height, int realheight, size_t data_size, imagetype_t type, int bits)
|
||||
{
|
||||
image_t *image;
|
||||
|
@ -1028,10 +1028,10 @@ R_LoadPic(char *name, byte *pic, int width, int realwidth,
|
|||
}
|
||||
|
||||
/*
|
||||
* Finds or loads the given image
|
||||
* Finds or loads the given image or null
|
||||
*/
|
||||
image_t *
|
||||
R_FindImage(char *name, imagetype_t type)
|
||||
R_FindImageUnsafe(const char *name, imagetype_t type)
|
||||
{
|
||||
image_t *image;
|
||||
int i, len;
|
||||
|
@ -1084,6 +1084,19 @@ R_FindImage(char *name, imagetype_t type)
|
|||
image = (image_t *)LoadImage(name, namewe, ext, type,
|
||||
r_retexturing->value, (loadimage_t)R_LoadPic);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds or loads the given image or notexture
|
||||
*/
|
||||
image_t *
|
||||
R_FindImage(const char *name, imagetype_t type)
|
||||
{
|
||||
image_t *image;
|
||||
|
||||
image = R_FindImageUnsafe(name, type);
|
||||
|
||||
if (!image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
|
||||
|
|
|
@ -1263,7 +1263,7 @@ R_Register(void)
|
|||
gl_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);
|
||||
r_lockpvs = ri.Cvar_Get("r_lockpvs", "0", 0);
|
||||
|
||||
gl1_palettedtexture = ri.Cvar_Get("gl1_palettedtexture", "0", CVAR_ARCHIVE);
|
||||
gl1_palettedtexture = ri.Cvar_Get("r_palettedtextures", "0", CVAR_ARCHIVE);
|
||||
gl1_pointparameters = ri.Cvar_Get("gl1_pointparameters", "1", CVAR_ARCHIVE);
|
||||
|
||||
gl_drawbuffer = ri.Cvar_Get("gl_drawbuffer", "GL_BACK", 0);
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#define ON_EPSILON 0.1 /* point on plane side epsilon */
|
||||
#define MAX_CLIP_VERTS 64
|
||||
|
||||
char skyname[MAX_QPATH];
|
||||
float skyrotate;
|
||||
vec3_t skyaxis;
|
||||
image_t *sky_images[6];
|
||||
|
@ -740,8 +739,8 @@ R_DrawSkyBox(void)
|
|||
void
|
||||
RI_SetSky(char *name, float rotate, vec3_t axis)
|
||||
{
|
||||
char skyname[MAX_QPATH];
|
||||
int i;
|
||||
char pathname[MAX_QPATH];
|
||||
|
||||
Q_strlcpy(skyname, name, sizeof(skyname));
|
||||
skyrotate = rotate;
|
||||
|
@ -749,33 +748,22 @@ RI_SetSky(char *name, float rotate, vec3_t axis)
|
|||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (gl_config.palettedtexture)
|
||||
image_t *image;
|
||||
|
||||
image = (image_t *)GetSkyImage(skyname, suf[i],
|
||||
gl_config.palettedtexture, (findimage_t)R_FindImageUnsafe);
|
||||
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "env/%s%s.pcx",
|
||||
skyname, suf[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "env/%s%s.tga",
|
||||
skyname, suf[i]);
|
||||
R_Printf(PRINT_ALL, "%s: can't load %s:%s sky\n",
|
||||
__func__, skyname, suf[i]);
|
||||
image = r_notexture;
|
||||
}
|
||||
|
||||
sky_images[i] = R_FindImage(pathname, it_sky);
|
||||
|
||||
if (!sky_images[i] || sky_images[i] == r_notexture)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "pics/Skies/%s%s.m8",
|
||||
skyname, suf[i]);
|
||||
sky_images[i] = R_FindImage(pathname, it_sky);
|
||||
}
|
||||
|
||||
if (!sky_images[i])
|
||||
{
|
||||
sky_images[i] = r_notexture;
|
||||
sky_images[i] = image;
|
||||
}
|
||||
|
||||
sky_min = 1.0 / 512;
|
||||
sky_max = 511.0 / 512;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -281,9 +281,10 @@ void COM_StripExtension(char *in, char *out);
|
|||
|
||||
void R_SwapBuffers(int);
|
||||
|
||||
image_t *R_LoadPic(char *name, byte *pic, int width, int realwidth,
|
||||
image_t *R_LoadPic(const char *name, byte *pic, int width, int realwidth,
|
||||
int height, int realheight, size_t data_size, imagetype_t type, int bits);
|
||||
image_t *R_FindImage(char *name, imagetype_t type);
|
||||
image_t *R_FindImageUnsafe(const char *name, imagetype_t type);
|
||||
image_t *R_FindImage(const char *name, imagetype_t type);
|
||||
void R_TextureMode(char *string);
|
||||
void R_ImageList_f(void);
|
||||
|
||||
|
|
|
@ -598,10 +598,10 @@ GL3_LoadPic(char *name, byte *pic, int width, int realwidth,
|
|||
}
|
||||
|
||||
/*
|
||||
* Finds or loads the given image
|
||||
* Finds or loads the given image or NULL
|
||||
*/
|
||||
gl3image_t *
|
||||
GL3_FindImage(char *name, imagetype_t type)
|
||||
GL3_FindImageUnsafe(const char *name, imagetype_t type)
|
||||
{
|
||||
gl3image_t *image;
|
||||
int i, len;
|
||||
|
@ -654,6 +654,18 @@ GL3_FindImage(char *name, imagetype_t type)
|
|||
image = (gl3image_t *)LoadImage(name, namewe, ext, type,
|
||||
r_retexturing->value, (loadimage_t)GL3_LoadPic);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds or loads the given image or notexture
|
||||
*/
|
||||
gl3image_t *
|
||||
GL3_FindImage(const char *name, imagetype_t type)
|
||||
{
|
||||
gl3image_t *image;
|
||||
|
||||
image = GL3_FindImageUnsafe(name, type);
|
||||
if (!image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
|
||||
|
|
|
@ -129,6 +129,7 @@ cvar_t *gl_shadows;
|
|||
cvar_t *gl3_debugcontext;
|
||||
cvar_t *gl3_usebigvbo;
|
||||
cvar_t *r_fixsurfsky;
|
||||
cvar_t *r_palettedtexture;
|
||||
cvar_t *gl3_usefbo;
|
||||
|
||||
// Yaw-Pitch-Roll
|
||||
|
@ -228,6 +229,7 @@ GL3_Register(void)
|
|||
r_drawworld = ri.Cvar_Get("r_drawworld", "1", 0);
|
||||
r_fullbright = ri.Cvar_Get("r_fullbright", "0", 0);
|
||||
r_fixsurfsky = ri.Cvar_Get("r_fixsurfsky", "0", CVAR_ARCHIVE);
|
||||
r_palettedtexture = ri.Cvar_Get("r_palettedtexture", "0", 0);
|
||||
|
||||
/* don't bilerp characters and crosshairs */
|
||||
gl_nolerp_list = ri.Cvar_Get("r_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", CVAR_ARCHIVE);
|
||||
|
|
|
@ -313,9 +313,8 @@ int vec_to_st[6][3] = {
|
|||
void
|
||||
GL3_SetSky(char *name, float rotate, vec3_t axis)
|
||||
{
|
||||
int i;
|
||||
char pathname[MAX_QPATH];
|
||||
char skyname[MAX_QPATH];
|
||||
int i;
|
||||
|
||||
Q_strlcpy(skyname, name, sizeof(skyname));
|
||||
skyrotate = rotate;
|
||||
|
@ -323,28 +322,24 @@ GL3_SetSky(char *name, float rotate, vec3_t axis)
|
|||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
// NOTE: there might be a paletted .pcx version, which was only used
|
||||
// if gl_config.palettedtexture so it *shouldn't* be relevant for he GL3 renderer
|
||||
Com_sprintf(pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
|
||||
gl3image_t *image;
|
||||
|
||||
sky_images[i] = GL3_FindImage(pathname, it_sky);
|
||||
image = (gl3image_t *)GetSkyImage(skyname, suf[i],
|
||||
r_palettedtexture->value, (findimage_t)GL3_FindImageUnsafe);
|
||||
|
||||
if (sky_images[i] == NULL || sky_images[i] == gl3_notexture)
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf(pathname, sizeof(pathname), "pics/Skies/%s%s.m8", skyname, suf[i]);
|
||||
|
||||
sky_images[i] = GL3_FindImage(pathname, it_sky);
|
||||
R_Printf(PRINT_ALL, "%s: can't load %s:%s sky\n",
|
||||
__func__, skyname, suf[i]);
|
||||
image = gl3_notexture;
|
||||
}
|
||||
|
||||
if (sky_images[i] == NULL)
|
||||
{
|
||||
sky_images[i] = gl3_notexture;
|
||||
sky_images[i] = image;
|
||||
}
|
||||
|
||||
sky_min = 1.0 / 512;
|
||||
sky_max = 511.0 / 512;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
DrawSkyPolygon(int nump, vec3_t vecs)
|
||||
|
|
|
@ -442,7 +442,8 @@ extern void GL3_BindLightmap(int lightmapnum);
|
|||
extern gl3image_t *GL3_LoadPic(char *name, byte *pic, int width, int realwidth,
|
||||
int height, int realheight, size_t data_size,
|
||||
imagetype_t type, int bits);
|
||||
extern gl3image_t *GL3_FindImage(char *name, imagetype_t type);
|
||||
extern gl3image_t *GL3_FindImageUnsafe(const char *name, imagetype_t type);
|
||||
extern gl3image_t *GL3_FindImage(const char *name, imagetype_t type);
|
||||
extern gl3image_t *GL3_RegisterSkin(char *name);
|
||||
extern void GL3_ShutdownImages(void);
|
||||
extern void GL3_FreeUnusedImages(void);
|
||||
|
@ -548,6 +549,7 @@ extern cvar_t *r_modulate;
|
|||
extern cvar_t *gl_lightmap;
|
||||
extern cvar_t *gl_shadows;
|
||||
extern cvar_t *r_fixsurfsky;
|
||||
extern cvar_t *r_palettedtexture;
|
||||
|
||||
extern cvar_t *gl3_debugcontext;
|
||||
|
||||
|
|
|
@ -105,12 +105,14 @@ extern const byte* Mod_DecompressVis(const byte *in, int row);
|
|||
|
||||
/* Shared models load */
|
||||
typedef struct image_s* (*findimage_t)(char *name, imagetype_t type);
|
||||
void *Mod_LoadMD2 (const char *mod_name, const void *buffer, int modfilelen,
|
||||
extern void *Mod_LoadMD2 (const char *mod_name, const void *buffer, int modfilelen,
|
||||
vec3_t mins, vec3_t maxs, struct image_s **skins,
|
||||
findimage_t find_image, modtype_t *type);
|
||||
extern void *Mod_LoadSP2 (const char *mod_name, const void *buffer, int modfilelen,
|
||||
struct image_s **skins, findimage_t find_image, modtype_t *type);
|
||||
extern int Mod_ReLoadSkins(struct image_s **skins, findimage_t find_image,
|
||||
void *extradata, modtype_t type);
|
||||
extern struct image_s *GetSkyImage(const char *skyname, const char* surfname,
|
||||
qboolean palettedtexture, findimage_t find_image);
|
||||
|
||||
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
||||
|
|
|
@ -588,7 +588,8 @@ void RE_Draw_FadeScreen (void);
|
|||
extern byte d_8to24table[256 * 4];
|
||||
void R_InitImages(void);
|
||||
void R_ShutdownImages(void);
|
||||
image_t *R_FindImage(char *name, imagetype_t type);
|
||||
image_t *R_FindImageUnsafe(const char *name, imagetype_t type);
|
||||
image_t *R_FindImage(const char *name, imagetype_t type);
|
||||
byte *Get_BestImageSize(const image_t *image, int *req_width, int *req_height);
|
||||
void R_FreeUnusedImages(void);
|
||||
qboolean R_ImageHasFreeSpace(void);
|
||||
|
|
|
@ -476,13 +476,13 @@ R_ApplyLight(pixel_t pix, const light3_t light)
|
|||
|
||||
/*
|
||||
===============
|
||||
R_FindImage
|
||||
R_FindImageUnsafe
|
||||
|
||||
Finds or loads the given image
|
||||
Finds or loads the given image or NULL
|
||||
===============
|
||||
*/
|
||||
image_t *
|
||||
R_FindImage(char *name, imagetype_t type)
|
||||
R_FindImageUnsafe(const char *name, imagetype_t type)
|
||||
{
|
||||
image_t *image;
|
||||
int i, len;
|
||||
|
@ -541,6 +541,22 @@ R_FindImage(char *name, imagetype_t type)
|
|||
image = (image_t *)LoadImage(name, namewe, ext, type,
|
||||
r_retexturing->value, (loadimage_t)R_LoadPic);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
R_FindImage
|
||||
|
||||
Finds or loads the given image or no_texture
|
||||
===============
|
||||
*/
|
||||
image_t *
|
||||
R_FindImage(const char *name, imagetype_t type)
|
||||
{
|
||||
image_t *image;
|
||||
|
||||
image = R_FindImageUnsafe(name, type);
|
||||
if (!image)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
|
||||
|
|
|
@ -54,7 +54,6 @@ refimport_t ri;
|
|||
|
||||
byte d_8to24table[256 * 4];
|
||||
|
||||
char skyname[MAX_QPATH];
|
||||
vec3_t skyaxis;
|
||||
|
||||
refdef_t r_newrefdef;
|
||||
|
@ -173,6 +172,7 @@ static cvar_t *vid_fullscreen;
|
|||
static cvar_t *vid_gamma;
|
||||
|
||||
static cvar_t *r_lockpvs;
|
||||
static cvar_t *r_palettedtexture;
|
||||
|
||||
// sw_vars.c
|
||||
|
||||
|
@ -411,6 +411,7 @@ R_RegisterVariables (void)
|
|||
r_customwidth = ri.Cvar_Get("r_customwidth", "1024", CVAR_ARCHIVE);
|
||||
r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE);
|
||||
r_fixsurfsky = ri.Cvar_Get("r_fixsurfsky", "0", CVAR_ARCHIVE);
|
||||
r_palettedtexture = ri.Cvar_Get("r_palettedtexture", "0", 0);
|
||||
|
||||
vid_fullscreen = ri.Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE );
|
||||
vid_gamma = ri.Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE );
|
||||
|
@ -1728,21 +1729,27 @@ extern mtexinfo_t r_skytexinfo[6];
|
|||
static void
|
||||
RE_SetSky (char *name, float rotate, vec3_t axis)
|
||||
{
|
||||
char skyname[MAX_QPATH];
|
||||
int i;
|
||||
char pathname[MAX_QPATH];
|
||||
|
||||
Q_strlcpy (skyname, name, sizeof(skyname));
|
||||
VectorCopy (axis, skyaxis);
|
||||
|
||||
for (i=0 ; i<6 ; i++)
|
||||
{
|
||||
Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[r_skysideimage[i]]);
|
||||
r_skytexinfo[i].image = R_FindImage (pathname, it_sky);
|
||||
if (!r_skytexinfo[i].image)
|
||||
image_t *image;
|
||||
|
||||
image = (image_t *)GetSkyImage(skyname, suf[r_skysideimage[i]],
|
||||
r_palettedtexture->value, (findimage_t)R_FindImageUnsafe);
|
||||
|
||||
if (!image)
|
||||
{
|
||||
Com_sprintf (pathname, sizeof(pathname), "pics/Skies/%s%s.m8", skyname, suf[r_skysideimage[i]]);
|
||||
r_skytexinfo[i].image = R_FindImage (pathname, it_sky);
|
||||
R_Printf(PRINT_ALL, "%s: can't load %s:%s sky\n",
|
||||
__func__, skyname, suf[r_skysideimage[i]]);
|
||||
image = r_notexture_mip;
|
||||
}
|
||||
|
||||
r_skytexinfo[i].image = image;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,8 @@ replacement_t replacements[] = {
|
|||
{"gl_mode", "r_mode"},
|
||||
{"gl_modulate", "r_modulate"},
|
||||
{"gl_overbrightbits", "gl1_overbrightbits"},
|
||||
{"gl_palettedtextures", "gl1_palettedtextures"},
|
||||
{"gl_palettedtextures", "r_palettedtextures"},
|
||||
{"gl1_palettedtextures", "r_palettedtextures"},
|
||||
{"gl_particle_min_size", "gl1_particle_min_size"},
|
||||
{"gl_particle_max_size", "gl1_particle_max_size"},
|
||||
{"gl_particle_size", "gl1_particle_size"},
|
||||
|
|
Loading…
Reference in a new issue