mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-02 14:01:26 +00:00
q64 sky texture now display correctly
see https://github.com/Novum/vkQuake/pull/358
This commit is contained in:
parent
f13887e8a5
commit
0fc09fd95d
3 changed files with 65 additions and 9 deletions
|
@ -457,8 +457,6 @@ void Mod_LoadTextures (lump_t *l)
|
|||
extern byte *hunk_base;
|
||||
//johnfitz
|
||||
|
||||
miptex64_t *mt64; //Quake64
|
||||
|
||||
//johnfitz -- don't return early if no textures; still need to create dummy texture
|
||||
if (!l->filelen)
|
||||
{
|
||||
|
@ -526,7 +524,7 @@ void Mod_LoadTextures (lump_t *l)
|
|||
}
|
||||
else
|
||||
{ // Q64 bsp
|
||||
mt64 = (miptex64_t *)mt;
|
||||
miptex64_t *mt64 = (miptex64_t *)mt;
|
||||
tx->shift = LittleLong (mt64->shift);
|
||||
memcpy ( tx+1, mt64+1, pixels);
|
||||
}
|
||||
|
@ -535,7 +533,12 @@ void Mod_LoadTextures (lump_t *l)
|
|||
if (!isDedicated) //no texture uploading for dedicated server
|
||||
{
|
||||
if (!q_strncasecmp(tx->name,"sky",3)) //sky texture //also note -- was Q_strncmp, changed to match qbsp
|
||||
{
|
||||
if (loadmodel->bspversion == BSPVERSION_QUAKE64)
|
||||
Sky_LoadTextureQ64 (tx);
|
||||
else
|
||||
Sky_LoadTexture (tx);
|
||||
}
|
||||
else if (tx->name[0] == '*') //warping texture
|
||||
{
|
||||
//external textures -- first look in "textures/mapname/" then look in "textures/"
|
||||
|
@ -1284,7 +1287,7 @@ void Mod_LoadFaces (lump_t *l, qboolean bsp2)
|
|||
|
||||
// lighting info
|
||||
if (loadmodel->bspversion == BSPVERSION_QUAKE64)
|
||||
lofs /= 2; // Q64 lightdata is 2 bytes per samples {Tone, color}?
|
||||
lofs /= 2; // Q64 samples are 16bits instead 8 in normal Quake
|
||||
|
||||
if (lofs == -1)
|
||||
out->samples = NULL;
|
||||
|
|
|
@ -143,6 +143,59 @@ void Sky_LoadTexture (texture_t *mt)
|
|||
skyflatcolor[2] = (float)b/(count*255);
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Sky_LoadTextureQ64
|
||||
|
||||
Quake64 sky textures are 32*64
|
||||
==============
|
||||
*/
|
||||
void Sky_LoadTextureQ64 (texture_t *mt)
|
||||
{
|
||||
char texturename[64];
|
||||
int i, p, r, g, b, count;
|
||||
byte *front, *back, *front_rgba;
|
||||
unsigned *rgba;
|
||||
|
||||
// pointers to both layer textures
|
||||
front = (byte *)(mt+1);
|
||||
back = (byte *)(mt+1) + (32*32);
|
||||
front_rgba = (byte *) Hunk_Alloc(4*(32*32));
|
||||
|
||||
// Normal indexed texture for the back layer
|
||||
q_snprintf(texturename, sizeof(texturename), "%s:%s_back", loadmodel->name, mt->name);
|
||||
solidskytexture = TexMgr_LoadImage (loadmodel, texturename, 32, 32, SRC_INDEXED, back, "", (src_offset_t)back, TEXPREF_NONE);
|
||||
|
||||
// front layer, convert to RGBA and upload
|
||||
p = r = g = b = count = 0;
|
||||
|
||||
for (i=0 ; i < (32*32) ; i++)
|
||||
{
|
||||
rgba = &d_8to24table[*front++];
|
||||
|
||||
// RGB
|
||||
front_rgba[p++] = ((byte*)rgba)[0];
|
||||
front_rgba[p++] = ((byte*)rgba)[1];
|
||||
front_rgba[p++] = ((byte*)rgba)[2];
|
||||
// Alpha
|
||||
front_rgba[p++] = 128; // this look ok to me!
|
||||
|
||||
// Fast sky
|
||||
r += ((byte *)rgba)[0];
|
||||
g += ((byte *)rgba)[1];
|
||||
b += ((byte *)rgba)[2];
|
||||
count++;
|
||||
}
|
||||
|
||||
q_snprintf(texturename, sizeof(texturename), "%s:%s_front", loadmodel->name, mt->name);
|
||||
alphaskytexture = TexMgr_LoadImage (loadmodel, texturename, 32, 32, SRC_RGBA, front_rgba, "", (src_offset_t)front_rgba, TEXPREF_NONE);
|
||||
|
||||
// calculate r_fastsky color based on average of all opaque foreground colors
|
||||
skyflatcolor[0] = (float)r/(count*255);
|
||||
skyflatcolor[1] = (float)g/(count*255);
|
||||
skyflatcolor[2] = (float)b/(count*255);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Sky_LoadSkyBox
|
||||
|
|
|
@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#ifndef __GLQUAKE_H
|
||||
#define __GLQUAKE_H
|
||||
#ifndef GLQUAKE_H
|
||||
#define GLQUAKE_H
|
||||
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height);
|
||||
void GL_EndRendering (void);
|
||||
|
@ -400,6 +400,7 @@ void Sky_ClearAll (void);
|
|||
void Sky_DrawSky (void);
|
||||
void Sky_NewMap (void);
|
||||
void Sky_LoadTexture (texture_t *mt);
|
||||
void Sky_LoadTextureQ64 (texture_t *mt);
|
||||
void Sky_LoadSkyBox (const char *name);
|
||||
|
||||
void TexMgr_RecalcWarpImageSize (void);
|
||||
|
@ -419,5 +420,4 @@ void R_ScaleView_DeleteTexture (void);
|
|||
|
||||
float GL_WaterAlphaForSurface (msurface_t *fa);
|
||||
|
||||
#endif /* __GLQUAKE_H */
|
||||
|
||||
#endif /* GLQUAKE_H */
|
||||
|
|
Loading…
Reference in a new issue