mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-30 16:50:48 +00:00
Sky & warning fixes.
This commit is contained in:
parent
dd81394eb0
commit
1d1529cb4b
5 changed files with 64 additions and 27 deletions
|
@ -1070,32 +1070,67 @@ R_InitSky_32
|
|||
A sky texture is 256*128, with the right side being a masked overlay
|
||||
==============
|
||||
*/
|
||||
void R_InitSky_32 (byte *src)
|
||||
void R_InitSky_32 (byte *src, int bytesperpixel)
|
||||
{
|
||||
int i, j;
|
||||
int i, j, p;
|
||||
unsigned trans[128*128];
|
||||
unsigned transpix;
|
||||
int r, g, b;
|
||||
unsigned *rgba;
|
||||
extern int skytexturenum;
|
||||
|
||||
for (i = 0;i < 128;i++)
|
||||
for (j = 0;j < 128;j++)
|
||||
trans[(i*128) + j] = src[i*256+j+128];
|
||||
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++) {
|
||||
p = src[i*256 + j + 128];
|
||||
rgba = &d_8to24table[p];
|
||||
trans[(i*128) + j] = *rgba;
|
||||
r += ((byte *)rgba)[0];
|
||||
g += ((byte *)rgba)[1];
|
||||
b += ((byte *)rgba)[2];
|
||||
}
|
||||
|
||||
((byte *)&transpix)[0] = r/(128*128);
|
||||
((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);
|
||||
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);
|
||||
|
||||
for (i = 0;i < 128;i++)
|
||||
for (j = 0;j < 128;j++)
|
||||
trans[(i*128) + j] = src[i*256+j];
|
||||
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++) {
|
||||
p = src[i*256 + j];
|
||||
if (p == 0)
|
||||
trans[(i*128) + j] = transpix;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue