mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-10 14:52:08 +00:00
Fixed 'skybug'
This commit is contained in:
parent
a495278595
commit
3b337ab41d
2 changed files with 57 additions and 43 deletions
|
@ -1002,20 +1002,25 @@ R_InitSky
|
|||
A sky texture is 256*128, with the right side being a masked overlay
|
||||
==============
|
||||
*/
|
||||
void R_InitSky (texture_t *mt)
|
||||
void R_InitSky (byte *src, int bytesperpixel) //texture_t *mt)
|
||||
{
|
||||
int i, j, p;
|
||||
byte *src;
|
||||
unsigned trans[128*128];
|
||||
unsigned transpix;
|
||||
int r, g, b;
|
||||
unsigned *rgba;
|
||||
extern int skytexturenum;
|
||||
|
||||
src = (byte *)mt + mt->offsets[0];
|
||||
|
||||
if (bytesperpixel == 4)
|
||||
{
|
||||
for (i = 0;i < 128;i++)
|
||||
for (j = 0;j < 128;j++)
|
||||
trans[(i*128) + j] = src[i*256+j+128];
|
||||
}
|
||||
else
|
||||
{
|
||||
// make an average value for the back to avoid
|
||||
// a fringe on the top level
|
||||
|
||||
r = g = b = 0;
|
||||
for (i=0 ; i<128 ; i++)
|
||||
for (j=0 ; j<128 ; j++)
|
||||
|
@ -1032,16 +1037,25 @@ void R_InitSky (texture_t *mt)
|
|||
((byte *)&transpix)[1] = g/(128*128);
|
||||
((byte *)&transpix)[2] = b/(128*128);
|
||||
((byte *)&transpix)[3] = 0;
|
||||
|
||||
}
|
||||
|
||||
if (!solidskytexture)
|
||||
solidskytexture = texture_extension_number++;
|
||||
|
||||
GL_Bind (solidskytexture );
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
if (bytesperpixel == 4)
|
||||
{
|
||||
for (i = 0;i < 128;i++)
|
||||
for (j = 0;j < 128;j++)
|
||||
trans[(i*128) + j] = src[i*256+j];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0 ; i<128 ; i++)
|
||||
for (j=0 ; j<128 ; j++)
|
||||
{
|
||||
|
@ -1051,12 +1065,13 @@ void R_InitSky (texture_t *mt)
|
|||
else
|
||||
trans[(i*128) + j] = d_8to24table[p];
|
||||
}
|
||||
}
|
||||
|
||||
if (!alphaskytexture)
|
||||
alphaskytexture = texture_extension_number++;
|
||||
|
||||
GL_Bind(alphaskytexture);
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
|
||||
|
|
|
@ -234,8 +234,7 @@ void HL_Mod_LoadTextures (lump_t *l)
|
|||
if (!strncmp(mt->name,"sky",3))
|
||||
{
|
||||
tx->transparent = FALSE;
|
||||
// R_InitSky (data, bytesperpixel);
|
||||
R_InitSky (tx);
|
||||
R_InitSky (data, bytesperpixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue