Load the sky texture as two separate textures.

The sky texture is normally 256x128, with each 128 wide side being the two
layers of the sky.
This commit is contained in:
Bill Currie 2012-01-11 21:09:57 +09:00
parent b43d03a98b
commit 7ba7130f42
2 changed files with 27 additions and 1 deletions

View file

@ -93,6 +93,7 @@ typedef struct texture_s {
unsigned int width, height;
int gl_texturenum;
int gl_fb_texturenum;
int sky_tex[2];
instsurf_t *tex_chain; // for gl_texsort drawing
instsurf_t **tex_chain_tail;
struct elechain_s *elechain;

View file

@ -52,6 +52,8 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/vid.h"
#include "QF/GLSL/defines.h"
#include "QF/GLSL/funcs.h"
#include "QF/GLSL/qf_textures.h"
#include "compat.h"
@ -59,7 +61,30 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
void
Mod_ProcessTexture (texture_t *tx)
{
if (!strncmp (tx->name, "sky", 3)) {
// sky textures need to be loaded as two separate textures to allow
// wrapping on both sky layers.
byte *data;
byte *tx_data;
int i, j;
if (tx->width != 256 || tx->height != 128)
Sys_Error ("Mod_ProcessTexture: invalid sky texture: %dx%d\n",
tx->width, tx->height);
data = alloca (128 * 128);
tx_data = (byte *)tx + tx->offsets[0];
for (i = 0; i < 2; i++) {
for (j = 0; j < 128; j++)
memcpy (&data[j * 128], &tx_data[j * 256 + i * 128], 128);
tx->sky_tex[i] = GL_LoadQuakeTexture (tx->name, 128, 128, data);
// GL_LoadQuakeTexture () leaves the texture bound
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
qfglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
tx->gl_texturenum = 0;
} else {
tx->gl_texturenum = GL_LoadQuakeMipTex (tx);
}
}
void