mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-08 00:41:01 +00:00
Allow any NxN or 2NxN sky texture for glsl.
Maps that specify a skybox often use a fake sky texture, sometimes 16x16. Having a hardcoded requiredment of 256x128 is a tad inappropriate.
This commit is contained in:
parent
d6a1daaf30
commit
6ba6959205
1 changed files with 36 additions and 12 deletions
|
@ -66,6 +66,8 @@ glsl_brush_clear (model_t *m)
|
||||||
// NOTE: some maps (eg e1m2) have empty texture slots
|
// NOTE: some maps (eg e1m2) have empty texture slots
|
||||||
if (m->textures[i] && m->textures[i]->gl_texturenum) {
|
if (m->textures[i] && m->textures[i]->gl_texturenum) {
|
||||||
GLSL_ReleaseTexture (m->textures[i]->gl_texturenum);
|
GLSL_ReleaseTexture (m->textures[i]->gl_texturenum);
|
||||||
|
GLSL_ReleaseTexture (m->textures[i]->sky_tex[0]);
|
||||||
|
GLSL_ReleaseTexture (m->textures[i]->sky_tex[1]);
|
||||||
m->textures[i]->gl_texturenum = 0;
|
m->textures[i]->gl_texturenum = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +79,18 @@ glsl_brush_clear (model_t *m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
load_skytex (texture_t *tx, byte *data)
|
||||||
|
{
|
||||||
|
int tex;
|
||||||
|
|
||||||
|
tex = GLSL_LoadQuakeTexture (tx->name, tx->height, tx->height, data);
|
||||||
|
// GLSL_LoadQuakeTexture () leaves the texture bound
|
||||||
|
qfeglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
qfeglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glsl_Mod_ProcessTexture (texture_t *tx)
|
glsl_Mod_ProcessTexture (texture_t *tx)
|
||||||
{
|
{
|
||||||
|
@ -85,22 +99,32 @@ glsl_Mod_ProcessTexture (texture_t *tx)
|
||||||
// wrapping on both sky layers.
|
// wrapping on both sky layers.
|
||||||
byte *data;
|
byte *data;
|
||||||
byte *tx_data;
|
byte *tx_data;
|
||||||
|
int tx_w, tx_h;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (tx->width != 256 || tx->height != 128)
|
tx_w = tx->width;
|
||||||
Sys_Error ("Mod_ProcessTexture: invalid sky texture: %dx%d\n",
|
tx_h = tx->height;
|
||||||
tx->width, tx->height);
|
|
||||||
data = alloca (128 * 128);
|
|
||||||
tx_data = (byte *)tx + tx->offsets[0];
|
tx_data = (byte *)tx + tx->offsets[0];
|
||||||
for (i = 0; i < 2; i++) {
|
|
||||||
for (j = 0; j < 128; j++)
|
if (tx_w == tx_h) {
|
||||||
memcpy (&data[j * 128], &tx_data[j * 256 + i * 128], 128);
|
// a square sky texture probably means it's black, but just in
|
||||||
tx->sky_tex[i] = GLSL_LoadQuakeTexture (tx->name, 128, 128, data);
|
// case some other magic is being done, duplicate the square to
|
||||||
// GLSL_LoadQuakeTexture () leaves the texture bound
|
// both sky layers.
|
||||||
qfeglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
tx->sky_tex[0] = load_skytex (tx, tx_data);
|
||||||
qfeglTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
tx->sky_tex[1] = tx->sky_tex[0];
|
||||||
|
} else if (tx_w == 2 * tx_h) {
|
||||||
|
data = alloca (tx_h * tx_h);
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
for (j = 0; j < tx_h; j++)
|
||||||
|
memcpy (&data[j * tx_h], &tx_data[j * tx_w + i * tx_h],
|
||||||
|
tx_h);
|
||||||
|
tx->sky_tex[i] = load_skytex (tx, data);
|
||||||
|
}
|
||||||
|
tx->gl_texturenum = 0;
|
||||||
|
} else {
|
||||||
|
Sys_Error ("Mod_ProcessTexture: invalid sky texture: %dx%d\n",
|
||||||
|
tx_w, tx_h);
|
||||||
}
|
}
|
||||||
tx->gl_texturenum = 0;
|
|
||||||
} else {
|
} else {
|
||||||
tx->gl_texturenum = GLSL_LoadQuakeMipTex (tx);
|
tx->gl_texturenum = GLSL_LoadQuakeMipTex (tx);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue