GL_Bind () wanted to be tied up and spanked. Since QuakeForge is a nice,

wholesome, family project (yeah right), it will not be seen anymore.

But fret not.  If you need a replacement, just use glBindTexture the way
SGI intended.  In fact, every single GL_Bind (target) call was simply
replaced with glBindTexture (GL_TEXTURE_2D, target)..  Since that's more
or less all GL_Bind () did anyway, save a function call!
This commit is contained in:
Joseph Carter 2000-06-11 07:00:01 +00:00
parent b62e9e6104
commit e140ca0b83
8 changed files with 69 additions and 174 deletions

View file

@ -175,8 +175,6 @@ extern texture_t *r_notexture_mip;
extern int d_lightstylevalue[256]; // 8.8 fraction of base light value extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
extern qboolean envmap; extern qboolean envmap;
extern int currenttexture;
extern int cnttextures[2];
extern int particletexture; extern int particletexture;
extern int netgraphtexture; // netgraph texture extern int netgraphtexture; // netgraph texture
extern int playertextures; extern int playertextures;
@ -232,7 +230,6 @@ extern const char *gl_version;
extern const char *gl_extensions; extern const char *gl_extensions;
void R_TranslatePlayerSkin (int playernum); void R_TranslatePlayerSkin (int playernum);
void GL_Bind (int texnum);
// Multitexture // Multitexture
#define TEXTURE0_SGIS 0x835E #define TEXTURE0_SGIS 0x835E

View file

@ -122,16 +122,6 @@ typedef struct
gltexture_t gltextures[MAX_GLTEXTURES]; gltexture_t gltextures[MAX_GLTEXTURES];
int numgltextures; int numgltextures;
void GL_Bind (int texnum)
{
if (gl_nobind->value)
texnum = char_texture;
if (currenttexture == texnum)
return;
currenttexture = texnum;
glBindTexture (GL_TEXTURE_2D, texnum);
}
/* /*
============================================================================= =============================================================================
@ -200,7 +190,7 @@ int scrap_uploads;
void Scrap_Upload (void) void Scrap_Upload (void)
{ {
scrap_uploads++; scrap_uploads++;
GL_Bind(scrap_texnum); glBindTexture (GL_TEXTURE_2D, scrap_texnum);
GL_Upload8 (scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, true); GL_Upload8 (scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, true);
scrap_dirty = false; scrap_dirty = false;
} }
@ -372,7 +362,7 @@ void Draw_TextureMode_f (void)
{ {
if (glt->mipmap) if (glt->mipmap)
{ {
GL_Bind (glt->texnum); glBindTexture (GL_TEXTURE_2D, glt->texnum);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
} }
@ -475,7 +465,7 @@ void Draw_Character8 (int x, int y, int num)
fcol = col*0.0625; fcol = col*0.0625;
size = 0.0625; size = 0.0625;
GL_Bind (char_texture); glBindTexture (GL_TEXTURE_2D, char_texture);
glColor3f (0.5, 0.5, 0.5); glColor3f (0.5, 0.5, 0.5);
glBegin (GL_QUADS); glBegin (GL_QUADS);
@ -532,7 +522,7 @@ void Draw_Crosshair(void)
pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value]; pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value];
glColor4ubv ( pColor ); glColor4ubv ( pColor );
GL_Bind (cs_texture); glBindTexture (GL_TEXTURE_2D, cs_texture);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (0, 0); glTexCoord2f (0, 0);
@ -577,7 +567,7 @@ void Draw_Pic (int x, int y, qpic_t *pic)
Scrap_Upload (); Scrap_Upload ();
gl = (glpic_t *)pic->data; gl = (glpic_t *)pic->data;
glColor3f (0.4, 0.4, 0.4); glColor3f (0.4, 0.4, 0.4);
GL_Bind (gl->texnum); glBindTexture (GL_TEXTURE_2D, gl->texnum);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (gl->sl, gl->tl); glTexCoord2f (gl->sl, gl->tl);
glVertex2f (x, y); glVertex2f (x, y);
@ -603,7 +593,7 @@ void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
Scrap_Upload (); Scrap_Upload ();
gl = (glpic_t *)pic->data; gl = (glpic_t *)pic->data;
glColor4f (0.4, 0.4, 0.4, alpha); glColor4f (0.4, 0.4, 0.4, alpha);
GL_Bind (gl->texnum); glBindTexture (GL_TEXTURE_2D, gl->texnum);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (gl->sl, gl->tl); glTexCoord2f (gl->sl, gl->tl);
glVertex2f (x, y); glVertex2f (x, y);
@ -637,7 +627,7 @@ void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int h
newth = newtl + (height*oldglheight)/pic->height; newth = newtl + (height*oldglheight)/pic->height;
glColor3f (0.4, 0.4, 0.4); glColor3f (0.4, 0.4, 0.4);
GL_Bind (gl->texnum); glBindTexture (GL_TEXTURE_2D, gl->texnum);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (newsl, newtl); glTexCoord2f (newsl, newtl);
glVertex2f (x, y); glVertex2f (x, y);
@ -682,7 +672,7 @@ void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation)
byte *src; byte *src;
int p; int p;
GL_Bind (translate_texture); glBindTexture (GL_TEXTURE_2D, translate_texture);
c = pic->width * pic->height; c = pic->width * pic->height;
@ -775,7 +765,7 @@ Draw_ConsoleBackground ( int lines )
glColor4f (0.5, 0.5, 0.5, alpha); glColor4f (0.5, 0.5, 0.5, alpha);
// draw the console texture // draw the console texture
GL_Bind (gl->texnum); glBindTexture (GL_TEXTURE_2D, gl->texnum);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (gl->sl, gl->tl + ofs); glTexCoord2f (gl->sl, gl->tl + ofs);
glVertex2f (0, 0); glVertex2f (0, 0);
@ -818,7 +808,7 @@ refresh window.
void Draw_TileClear (int x, int y, int w, int h) void Draw_TileClear (int x, int y, int w, int h)
{ {
glColor3f (0.5, 0.5, 0.5); glColor3f (0.5, 0.5, 0.5);
GL_Bind (*(int *)draw_backtile->data); glBindTexture (GL_TEXTURE_2D, *(int *)draw_backtile->data);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (x/64.0, y/64.0); glTexCoord2f (x/64.0, y/64.0);
glVertex2f (x, y); glVertex2f (x, y);
@ -1376,7 +1366,7 @@ SetupTexture:
glt->height = height; glt->height = height;
glt->mipmap = mipmap; glt->mipmap = mipmap;
GL_Bind(glt->texnum); glBindTexture (GL_TEXTURE_2D, glt->texnum);
GL_Upload8 (data, width, height, mipmap, alpha); GL_Upload8 (data, width, height, mipmap, alpha);
@ -1395,17 +1385,10 @@ int GL_LoadPicTexture (qpic_t *pic)
/****************************************/ /****************************************/
static GLenum oldtarget = 0; // TEXTURE0_SGIS;
void GL_SelectTexture (GLenum target) void GL_SelectTexture (GLenum target)
{ {
if (!gl_mtexable) if (!gl_mtexable)
return; return;
qglSelectTexture (target + gl_mtex_enum); qglSelectTexture (target + gl_mtex_enum);
if (target == oldtarget)
return;
cnttextures[oldtarget] = currenttexture;
currenttexture = cnttextures[target];
oldtarget = target;
} }

View file

@ -149,7 +149,7 @@ void R_NetGraph (void)
Draw_String8 (8, y, st); Draw_String8 (8, y, st);
y += 8; y += 8;
GL_Bind(netgraphtexture); glBindTexture (GL_TEXTURE_2D, netgraphtexture);
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format,
NET_TIMINGS, NET_GRAPHHEIGHT, 0, GL_RGBA, NET_TIMINGS, NET_GRAPHHEIGHT, 0, GL_RGBA,

View file

@ -494,7 +494,7 @@ void R_DrawParticles (void)
float scale; float scale;
qboolean alphaTestEnabled; qboolean alphaTestEnabled;
GL_Bind(particletexture); glBindTexture (GL_TEXTURE_2D, particletexture);
alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
if (alphaTestEnabled) if (alphaTestEnabled)

View file

@ -60,9 +60,6 @@ int c_brush_polys, c_alias_polys;
qboolean envmap; // true during envmap command capture qboolean envmap; // true during envmap command capture
int currenttexture = -1; // to avoid unnecessary texture sets
int cnttextures[2] = {-1, -1}; // cached
int particletexture; // little dot for particles int particletexture; // little dot for particles
int playertextures; // up to 16 color translated skins int playertextures; // up to 16 color translated skins
@ -292,7 +289,7 @@ void R_DrawSpriteModel (entity_t *e)
GL_DisableMultitexture(); GL_DisableMultitexture();
GL_Bind(frame->gl_texturenum); glBindTexture (GL_TEXTURE_2D, frame->gl_texturenum);
glEnable (GL_ALPHA_TEST); glEnable (GL_ALPHA_TEST);
glBegin (GL_QUADS); glBegin (GL_QUADS);
@ -606,7 +603,7 @@ void R_DrawAliasModel (entity_t *e)
} }
anim = (int)(cl.time*10) & 3; anim = (int)(cl.time*10) & 3;
GL_Bind(paliashdr->gl_texturenum[currententity->skinnum][anim]); glBindTexture (GL_TEXTURE_2D, paliashdr->gl_texturenum[currententity->skinnum][anim]);
// we can't dynamically colormap textures, so they are cached // we can't dynamically colormap textures, so they are cached
// seperately for the players. Heads are just uncolored. // seperately for the players. Heads are just uncolored.
@ -618,7 +615,7 @@ void R_DrawAliasModel (entity_t *e)
R_TranslatePlayerSkin(i); R_TranslatePlayerSkin(i);
} }
if (i >= 0 && i<MAX_CLIENTS) if (i >= 0 && i<MAX_CLIENTS)
GL_Bind(playertextures + i); glBindTexture (GL_TEXTURE_2D, playertextures + i);
} }
if (gl_smoothmodels->value) if (gl_smoothmodels->value)

View file

@ -114,7 +114,7 @@ void R_InitParticleTexture (void)
// particle texture // particle texture
// //
particletexture = texture_extension_number++; particletexture = texture_extension_number++;
GL_Bind(particletexture); glBindTexture (GL_TEXTURE_2D, particletexture);
for (x=0 ; x<8 ; x++) for (x=0 ; x<8 ; x++)
{ {
@ -243,7 +243,7 @@ void R_Init (void)
r_speeds = Cvar_Get("r_speeds", "0", CVAR_NONE, "None"); r_speeds = Cvar_Get("r_speeds", "0", CVAR_NONE, "None");
r_netgraph = Cvar_Get("r_netgraph", "0", CVAR_NONE, "None"); r_netgraph = Cvar_Get("r_netgraph", "0", CVAR_NONE, "None");
gl_clear = Cvar_Get("gl_clear", "1", CVAR_NONE, "None"); gl_clear = Cvar_Get("gl_clear", "0", CVAR_NONE, "None");
gl_texsort = Cvar_Get("gl_texsort", "1", CVAR_NONE, "None"); gl_texsort = Cvar_Get("gl_texsort", "1", CVAR_NONE, "None");
if (gl_mtexable) if (gl_mtexable)
@ -361,7 +361,7 @@ void R_TranslatePlayerSkin (int playernum)
// because this happens during gameplay, do it fast // because this happens during gameplay, do it fast
// instead of sending it through gl_upload 8 // instead of sending it through gl_upload 8
GL_Bind(playertextures + playernum); glBindTexture (GL_TEXTURE_2D, playertextures + playernum);
#if 0 #if 0
s = 320*200; s = 320*200;

View file

@ -395,11 +395,11 @@ void R_DrawSequentialPoly (msurface_t *s)
t = R_TextureAnimation (s->texinfo->texture); t = R_TextureAnimation (s->texinfo->texture);
// Binds world to texture env 0 // Binds world to texture env 0
GL_SelectTexture(0); GL_SelectTexture(0);
GL_Bind (t->gl_texturenum); glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
// Binds lightmap to texenv 1 // Binds lightmap to texenv 1
GL_EnableMultitexture(); // Same as SelectTexture (TEXTURE1) GL_EnableMultitexture(); // Same as SelectTexture (TEXTURE1)
GL_Bind (lightmap_textures + s->lightmaptexturenum); glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum);
i = s->lightmaptexturenum; i = s->lightmaptexturenum;
if (lightmap_modified[i]) if (lightmap_modified[i])
{ {
@ -428,7 +428,7 @@ void R_DrawSequentialPoly (msurface_t *s)
p = s->polys; p = s->polys;
t = R_TextureAnimation (s->texinfo->texture); t = R_TextureAnimation (s->texinfo->texture);
GL_Bind (t->gl_texturenum); glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
glBegin (GL_POLYGON); glBegin (GL_POLYGON);
v = p->verts[0]; v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE) for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
@ -438,7 +438,7 @@ void R_DrawSequentialPoly (msurface_t *s)
} }
glEnd (); glEnd ();
GL_Bind (lightmap_textures + s->lightmaptexturenum); glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum);
glBegin (GL_POLYGON); glBegin (GL_POLYGON);
v = p->verts[0]; v = p->verts[0];
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE) for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
@ -458,7 +458,7 @@ void R_DrawSequentialPoly (msurface_t *s)
if (s->flags & SURF_DRAWTURB) if (s->flags & SURF_DRAWTURB)
{ {
GL_DisableMultitexture(); GL_DisableMultitexture();
GL_Bind (s->texinfo->texture->gl_texturenum); glBindTexture (GL_TEXTURE_2D, s->texinfo->texture->gl_texturenum);
EmitWaterPolys (s); EmitWaterPolys (s);
return; return;
} }
@ -469,13 +469,13 @@ void R_DrawSequentialPoly (msurface_t *s)
if (s->flags & SURF_DRAWSKY) if (s->flags & SURF_DRAWSKY)
{ {
GL_DisableMultitexture(); GL_DisableMultitexture();
GL_Bind (solidskytexture); glBindTexture (GL_TEXTURE_2D, solidskytexture);
speedscale = realtime*8; speedscale = realtime*8;
speedscale -= (int)speedscale & ~127; speedscale -= (int)speedscale & ~127;
EmitSkyPolys (s); EmitSkyPolys (s);
GL_Bind (alphaskytexture); glBindTexture (GL_TEXTURE_2D, alphaskytexture);
speedscale = realtime*16; speedscale = realtime*16;
speedscale -= (int)speedscale & ~127; speedscale -= (int)speedscale & ~127;
EmitSkyPolys (s); EmitSkyPolys (s);
@ -493,9 +493,9 @@ void R_DrawSequentialPoly (msurface_t *s)
t = R_TextureAnimation (s->texinfo->texture); t = R_TextureAnimation (s->texinfo->texture);
GL_SelectTexture(0); GL_SelectTexture(0);
GL_Bind (t->gl_texturenum); glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
GL_EnableMultitexture(); GL_EnableMultitexture();
GL_Bind (lightmap_textures + s->lightmaptexturenum); glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum);
i = s->lightmaptexturenum; i = s->lightmaptexturenum;
if (lightmap_modified[i]) if (lightmap_modified[i])
{ {
@ -528,10 +528,10 @@ void R_DrawSequentialPoly (msurface_t *s)
p = s->polys; p = s->polys;
t = R_TextureAnimation (s->texinfo->texture); t = R_TextureAnimation (s->texinfo->texture);
GL_Bind (t->gl_texturenum); glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
DrawGLWaterPoly (p); DrawGLWaterPoly (p);
GL_Bind (lightmap_textures + s->lightmaptexturenum); glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum);
DrawGLWaterPolyLightmap (p); DrawGLWaterPolyLightmap (p);
} }
} }
@ -635,7 +635,7 @@ void R_BlendLightmaps (void)
p = lightmap_polys[i]; p = lightmap_polys[i];
if (!p) if (!p)
continue; continue;
GL_Bind(lightmap_textures+i); glBindTexture (GL_TEXTURE_2D, lightmap_textures+i);
if (lightmap_modified[i]) if (lightmap_modified[i])
{ {
lightmap_modified[i] = false; lightmap_modified[i] = false;
@ -686,42 +686,6 @@ void R_BlendLightmaps (void)
glDepthMask (1); // back to normal Z buffering glDepthMask (1); // back to normal Z buffering
} }
// Ender: Half-Life BSP loading
void R_RenderBrushPolyTransparent (msurface_t *fa)
{
texture_t *t;
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL, 0.05f);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
c_brush_polys++;
if (fa->flags & SURF_DRAWSKY)
{ // warp texture, no lightmaps
EmitBothSkyLayers (fa);
return;
}
t = R_TextureAnimation (fa->texinfo->texture);
GL_Bind (t->gl_texturenum);
if (fa->flags & SURF_DRAWTURB)
{ // warp texture, no lightmaps
EmitWaterPolys (fa);
return;
}
if (fa->flags & SURF_UNDERWATER)
DrawGLWaterPoly (fa->polys);
else
DrawGLPoly (fa->polys);
glDisable(GL_ALPHA_TEST);
}
/* /*
================ ================
R_RenderBrushPoly R_RenderBrushPoly
@ -735,11 +699,6 @@ void R_RenderBrushPoly (msurface_t *fa)
glRect_t *theRect; glRect_t *theRect;
int smax, tmax; int smax, tmax;
if (fa->texinfo->texture->transparent) {
R_RenderBrushPolyTransparent(fa);
return;
}
c_brush_polys++; c_brush_polys++;
if (fa->flags & SURF_DRAWSKY) if (fa->flags & SURF_DRAWSKY)
@ -749,7 +708,7 @@ void R_RenderBrushPoly (msurface_t *fa)
} }
t = R_TextureAnimation (fa->texinfo->texture); t = R_TextureAnimation (fa->texinfo->texture);
GL_Bind (t->gl_texturenum); glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
if (fa->flags & SURF_DRAWTURB) if (fa->flags & SURF_DRAWTURB)
{ // warp texture, no lightmaps { // warp texture, no lightmaps
@ -909,7 +868,7 @@ void R_DrawWaterSurfaces (void)
return; return;
for ( s = waterchain ; s ; s=s->texturechain) { for ( s = waterchain ; s ; s=s->texturechain) {
GL_Bind (s->texinfo->texture->gl_texturenum); glBindTexture (GL_TEXTURE_2D, s->texinfo->texture->gl_texturenum);
EmitWaterPolys (s); EmitWaterPolys (s);
} }
@ -929,7 +888,7 @@ void R_DrawWaterSurfaces (void)
// set modulate mode explicitly // set modulate mode explicitly
GL_Bind (t->gl_texturenum); glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
for ( ; s ; s=s->texturechain) for ( ; s ; s=s->texturechain)
EmitWaterPolys (s); EmitWaterPolys (s);
@ -1011,7 +970,6 @@ void R_DrawBrushModel (entity_t *e)
qboolean rotated; qboolean rotated;
currententity = e; currententity = e;
currenttexture = -1;
clmodel = e->model; clmodel = e->model;
@ -1249,7 +1207,6 @@ void R_DrawWorld (void)
VectorCopy (r_refdef.vieworg, modelorg); VectorCopy (r_refdef.vieworg, modelorg);
currententity = &ent; currententity = &ent;
currenttexture = -1;
glColor3f (1.0, 1.0, 1.0); glColor3f (1.0, 1.0, 1.0);
memset (lightmap_polys, 0, sizeof(lightmap_polys)); memset (lightmap_polys, 0, sizeof(lightmap_polys));
@ -1584,7 +1541,7 @@ void GL_BuildLightmaps (void)
lightmap_rectchange[i].t = BLOCK_HEIGHT; lightmap_rectchange[i].t = BLOCK_HEIGHT;
lightmap_rectchange[i].w = 0; lightmap_rectchange[i].w = 0;
lightmap_rectchange[i].h = 0; lightmap_rectchange[i].h = 0;
GL_Bind(lightmap_textures + i); glBindTexture (GL_TEXTURE_2D, lightmap_textures + i);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes, BLOCK_WIDTH, glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes, BLOCK_WIDTH,

View file

@ -301,13 +301,13 @@ void EmitBothSkyLayers (msurface_t *fa)
{ {
GL_DisableMultitexture(); GL_DisableMultitexture();
GL_Bind (solidskytexture); glBindTexture (GL_TEXTURE_2D, solidskytexture);
speedscale = realtime*8; speedscale = realtime*8;
speedscale -= (int)speedscale & ~127 ; speedscale -= (int)speedscale & ~127 ;
EmitSkyPolys (fa); EmitSkyPolys (fa);
GL_Bind (alphaskytexture); glBindTexture (GL_TEXTURE_2D, alphaskytexture);
speedscale = realtime*16; speedscale = realtime*16;
speedscale -= (int)speedscale & ~127 ; speedscale -= (int)speedscale & ~127 ;
@ -332,18 +332,18 @@ void EmitBothSkyLayers (msurface_t *fa)
================================================================= =================================================================
*/ */
//byte *pcx_rgb; byte *pcx_rgb;
/* /*
============ ============
LoadPCX LoadPCX
============ ============
*/ */
byte *LoadPCX (FILE *f) void LoadPCX (FILE *f)
{ {
pcx_t *pcx, pcxbuf; pcx_t *pcx, pcxbuf;
byte palette[768]; byte palette[768];
byte *pix, *pcx_rgb; byte *pix;
int x, y; int x, y;
int dataByte, runLength; int dataByte, runLength;
int count; int count;
@ -363,7 +363,7 @@ byte *LoadPCX (FILE *f)
|| pcx->ymax >= 256) || pcx->ymax >= 256)
{ {
Con_Printf ("Bad pcx file\n"); Con_Printf ("Bad pcx file\n");
return NULL; return;
} }
// seek to palette // seek to palette
@ -401,8 +401,6 @@ byte *LoadPCX (FILE *f)
} }
} }
} }
return pcx_rgb;
} }
/* /*
@ -423,7 +421,7 @@ typedef struct _TargaHeader {
TargaHeader targa_header; TargaHeader targa_header;
//byte *targa_rgba; byte *targa_rgba;
int fgetLittleShort (FILE *f) int fgetLittleShort (FILE *f)
{ {
@ -453,13 +451,12 @@ int fgetLittleLong (FILE *f)
LoadTGA LoadTGA
============= =============
*/ */
byte *LoadTGA (FILE *fin) void LoadTGA (FILE *fin)
{ {
int columns, rows, numPixels; int columns, rows, numPixels;
byte *pixbuf; byte *pixbuf;
int row, column; int row, column;
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0; unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
byte *targa_rgba;
targa_header.id_length = fgetc(fin); targa_header.id_length = fgetc(fin);
targa_header.colormap_type = fgetc(fin); targa_header.colormap_type = fgetc(fin);
@ -600,7 +597,6 @@ byte *LoadTGA (FILE *fin)
} }
fclose(fin); fclose(fin);
return targa_rgba;
} }
/* /*
@ -614,7 +610,6 @@ void R_LoadSkys (char * skyname)
int i; int i;
FILE *f; FILE *f;
char name[64]; char name[64];
byte *data;
if (stricmp (skyname, "none") == 0) if (stricmp (skyname, "none") == 0)
{ {
@ -625,7 +620,7 @@ void R_LoadSkys (char * skyname)
skyloaded = true; skyloaded = true;
for (i=0 ; i<6 ; i++) for (i=0 ; i<6 ; i++)
{ {
GL_Bind (SKY_TEX + i); glBindTexture (GL_TEXTURE_2D, SKY_TEX + i);
snprintf (name, sizeof(name),"env/%s%s.tga", skyname, suf[i]); snprintf (name, sizeof(name),"env/%s%s.tga", skyname, suf[i]);
COM_FOpenFile (name, &f); COM_FOpenFile (name, &f);
if (!f) if (!f)
@ -634,13 +629,13 @@ void R_LoadSkys (char * skyname)
skyloaded = false; skyloaded = false;
continue; continue;
} }
data = LoadTGA (f); LoadTGA (f);
// LoadPCX (f); // LoadPCX (f);
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, targa_rgba);
// glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, pcx_rgb); // glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, pcx_rgb);
free (data); free (targa_rgba);
// free (pcx_rgb); // free (pcx_rgb);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -875,7 +870,7 @@ void R_DrawSkyChain (msurface_t *s)
if (allowskybox && skyloaded) if (allowskybox && skyloaded)
{ {
c_sky = 0; c_sky = 0;
GL_Bind(solidskytexture); glBindTexture (GL_TEXTURE_2D, solidskytexture);
// calculate vertex values for sky box // calculate vertex values for sky box
@ -897,14 +892,14 @@ void R_DrawSkyChain (msurface_t *s)
GL_DisableMultitexture(); GL_DisableMultitexture();
// used when gl_texsort is on // used when gl_texsort is on
GL_Bind(solidskytexture); glBindTexture (GL_TEXTURE_2D, solidskytexture);
speedscale = realtime*8; speedscale = realtime*8;
speedscale -= (int)speedscale & ~127 ; speedscale -= (int)speedscale & ~127 ;
for (fa=s ; fa ; fa=fa->texturechain) for (fa=s ; fa ; fa=fa->texturechain)
EmitSkyPolys (fa); EmitSkyPolys (fa);
GL_Bind (alphaskytexture); glBindTexture (GL_TEXTURE_2D, alphaskytexture);
speedscale = realtime*16; speedscale = realtime*16;
speedscale -= (int)speedscale & ~127 ; speedscale -= (int)speedscale & ~127 ;
@ -987,7 +982,7 @@ void R_DrawSkyBox (void)
|| skymins[1][i] >= skymaxs[1][i]) || skymins[1][i] >= skymaxs[1][i])
continue; continue;
GL_Bind (SKY_TEX+skytexorder[i]); glBindTexture (GL_TEXTURE_2D, SKY_TEX+skytexorder[i]);
glBegin (GL_QUADS); glBegin (GL_QUADS);
MakeSkyVec (skymins[0][i], skymins[1][i], i); MakeSkyVec (skymins[0][i], skymins[1][i], i);
MakeSkyVec (skymins[0][i], skymaxs[1][i], i); MakeSkyVec (skymins[0][i], skymaxs[1][i], i);
@ -1001,14 +996,14 @@ void R_DrawSkyBox (void)
//=============================================================== //===============================================================
/* /*
=============
R_InitSky R_InitSky
A sky texture is 256*128, with the right side being a masked overlay A sky texture is 256*128, with the right side being a masked overlay
==============
*/ */
void void R_InitSky (texture_t *mt)
R_InitSky (texture_t *mt)
{ {
int i, j, p; int i, j, p;
byte *src; byte *src;
unsigned trans[128*128]; unsigned trans[128*128];
@ -1022,8 +1017,9 @@ R_InitSky (texture_t *mt)
// a fringe on the top level // a fringe on the top level
r = g = b = 0; r = g = b = 0;
for (i=0 ; i<128 ; i++) { for (i=0 ; i<128 ; i++)
for (j=0 ; j<128 ; j++) { for (j=0 ; j<128 ; j++)
{
p = src[i*256 + j + 128]; p = src[i*256 + j + 128];
rgba = &d_8to24table[p]; rgba = &d_8to24table[p];
trans[(i*128) + j] = *rgba; trans[(i*128) + j] = *rgba;
@ -1031,71 +1027,36 @@ R_InitSky (texture_t *mt)
g += ((byte *)rgba)[1]; g += ((byte *)rgba)[1];
b += ((byte *)rgba)[2]; b += ((byte *)rgba)[2];
} }
}
((byte *)&transpix)[0] = r/(128*128); ((byte *)&transpix)[0] = r/(128*128);
((byte *)&transpix)[1] = g/(128*128); ((byte *)&transpix)[1] = g/(128*128);
((byte *)&transpix)[2] = b/(128*128); ((byte *)&transpix)[2] = b/(128*128);
((byte *)&transpix)[3] = 0; ((byte *)&transpix)[3] = 0;
if (!solidskytexture) if (!solidskytexture)
solidskytexture = texture_extension_number++; solidskytexture = texture_extension_number++;
GL_Bind (solidskytexture); glBindTexture (GL_TEXTURE_2D, solidskytexture );
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans); 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_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_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++) { for (i=0 ; i<128 ; i++)
for (j=0 ; j<128 ; j++)
{
p = src[i*256 + j]; p = src[i*256 + j];
if (p == 0) if (p == 0)
trans[(i*128) + j] = transpix; trans[(i*128) + j] = transpix;
else else
trans[(i*128) + j] = d_8to24table[p]; trans[(i*128) + j] = d_8to24table[p];
} }
}
if (!alphaskytexture) if (!alphaskytexture)
alphaskytexture = texture_extension_number++; alphaskytexture = texture_extension_number++;
GL_Bind(alphaskytexture); glBindTexture (GL_TEXTURE_2D, alphaskytexture);
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans); 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_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} }
/*
=============
R_InitSky_32
A sky texture is 256*128, with the right side being a masked overlay
==============
*/
void R_InitSky_32 (byte *src)
{
int i, j;
unsigned trans[128*128];
for (i = 0;i < 128;i++)
for (j = 0;j < 128;j++)
trans[(i*128) + j] = src[i*256+j+128];
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);
for (i = 0;i < 128;i++)
for (j = 0;j < 128;j++)
trans[(i*128) + j] = src[i*256+j];
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);
}