diff --git a/include/draw.h b/include/draw.h index 2d38927..31c69ea 100644 --- a/include/draw.h +++ b/include/draw.h @@ -34,7 +34,7 @@ extern qpic_t *draw_disc; // also used on sbar void Draw_Init (void); -void Draw_Character (int x, int y, int num); +void Draw_Character8 (int x, int y, int num); void Draw_DebugChar (char num); void Draw_Pic (int x, int y, qpic_t *pic); void Draw_TransPic (int x, int y, qpic_t *pic); @@ -45,7 +45,7 @@ void Draw_EndDisc (void); void Draw_TileClear (int x, int y, int w, int h); void Draw_Fill (int x, int y, int w, int h, int c); void Draw_FadeScreen (void); -void Draw_String (int x, int y, char *str); +void Draw_String8 (int x, int y, char *str); qpic_t *Draw_PicFromWad (char *name); qpic_t *Draw_CachePic (char *path); diff --git a/include/glquake.h b/include/glquake.h index 25f485f..17b2265 100644 --- a/include/glquake.h +++ b/include/glquake.h @@ -70,12 +70,12 @@ extern TEXSUBIMAGEPTR TexSubImage2DFunc; extern int texture_extension_number; extern int texture_mode; +extern int gl_mtex_enum; extern float gldepthmin, gldepthmax; -void GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap, qboolean alpha); void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean alpha); -int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha); +int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel); int GL_FindTexture (char *identifier); typedef struct diff --git a/include/r_local.h b/include/r_local.h index 72694be..18ae897 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -321,7 +321,6 @@ void R_PrintTimes (void); void R_PrintDSpeeds (void); void R_AnimateLight (void); int R_LightPoint (vec3_t p); -void R_SetupFrame (void); void R_cshift_f (void); void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1); void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip); diff --git a/source/console.c b/source/console.c index 4c2026d..a0a79f0 100644 --- a/source/console.c +++ b/source/console.c @@ -524,7 +524,7 @@ void Con_DrawInput (void) y = con_vislines-16; for (i=0 ; i -#include +#include +#ifdef HAVE_STRINGS_H +#include +#endif -#include "host.h" -#include "glquake.h" -#include "sbar.h" +#include "compat.h" +#include "bspfile.h" // needed by: glquake.h #include "vid.h" -#include "quakefs.h" -#include "wad.h" #include "sys.h" +#include "mathlib.h" // needed by: protocol.h, render.h, client.h, + // modelgen.h, glmodel.h +#include "wad.h" +#include "draw.h" +#include "cvar.h" +#include "net.h" // needed by: client.h +#include "protocol.h" // needed by: client.h +#include "cmd.h" +#include "sbar.h" +#include "render.h" // needed by: client.h, model.h, glquake.h +#include "client.h" // need cls in this file +#include "model.h" // needed by: glquake.h #include "console.h" +#include "glquake.h" -#define GL_COLOR_INDEX8_EXT 0x80E5 +static int GL_LoadPicTexture (qpic_t *pic); +extern byte *host_basepal; extern unsigned char d_15to8table[65536]; +extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor; +extern qboolean lighthalf; -cvar_t *gl_nobind; -cvar_t *gl_max_size; -cvar_t *gl_picmip; +cvar_t *gl_nobind; +cvar_t *gl_max_size; +cvar_t *gl_picmip; -int GL_LoadPicTexture (qpic_t *pic); +cvar_t *gl_constretch; +cvar_t *gl_conalpha; +cvar_t *gl_conspin; +cvar_t *cl_verstring; +cvar_t *gl_lightmode; // LordHavoc: lighting mode +cvar_t *brightness; // LordHavoc: brightness multiplier +cvar_t *contrast; // LordHavoc: contrast scaler byte *draw_chars; // 8*8 graphic characters qpic_t *draw_disc; qpic_t *draw_backtile; -int translate_texture; -int char_texture; +static int ltexcrctable[256]; // cache mismatch checking --KB + + +static int translate_texture; +static int char_texture; +static int cs_texture; // crosshair texturea + +static byte cs_data[64] = { + 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; + typedef struct { int texnum; + int bytesperpixel; float sl, tl, sh, th; } glpic_t; -byte conback_buffer[sizeof(qpic_t) + sizeof(glpic_t)]; -qpic_t *conback = (qpic_t *)&conback_buffer; - int gl_lightmap_format = 4; int gl_solid_format = 3; int gl_alpha_format = 4; -int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; -int gl_filter_max = GL_LINEAR; +static int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; +static int gl_filter_max = GL_LINEAR; -int texels; - typedef struct { int texnum; char identifier[64]; int width, height; + int bytesperpixel; qboolean mipmap; + int crc; // not really a standard CRC, but it works } gltexture_t; #define MAX_GLTEXTURES 1024 -gltexture_t gltextures[MAX_GLTEXTURES]; -int numgltextures; - - -void GL_Bind (int texnum) -{ - if (gl_nobind->value) - texnum = char_texture; - if (currenttexture == texnum) - return; - currenttexture = texnum; -#ifdef _WIN32 - bindTexFunc (GL_TEXTURE_2D, texnum); -#else - glBindTexture(GL_TEXTURE_2D, texnum); -#endif -} - +static gltexture_t gltextures[MAX_GLTEXTURES]; +static int numgltextures = 0; /* ============================================================================= @@ -114,42 +134,45 @@ void GL_Bind (int texnum) Allocate all the little status bar obejcts into a single texture to crutch up stupid hardware / drivers + Note, this is a kluge, which may slow down sane cards.. + As such its all contained in ifdefs.. + ============================================================================= */ -#define MAX_SCRAPS 2 +#undef gl_draw_scraps + +#ifdef gl_draw_scraps + +#define MAX_SCRAPS 1 #define BLOCK_WIDTH 256 #define BLOCK_HEIGHT 256 -int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH]; -byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH*BLOCK_HEIGHT*4]; -qboolean scrap_dirty; -int scrap_texnum; +static int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH]; +static byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH*BLOCK_HEIGHT*4]; +static qboolean scrap_dirty; +static int scrap_texnum; // returns a texture number and the position inside it -int Scrap_AllocBlock (int w, int h, int *x, int *y) +static int Scrap_AllocBlock (int w, int h, int *x, int *y) { int i, j; int best, best2; int texnum; - for (texnum=0 ; texnum= best) break; if (scrap_allocated[texnum][i+j] > best2) best2 = scrap_allocated[texnum][i+j]; } - if (j == w) - { // this is a valid spot + if (j == w) { // this is a valid spot *x = i; *y = best = best2; } @@ -161,45 +184,39 @@ int Scrap_AllocBlock (int w, int h, int *x, int *y) for (i=0 ; idata; +#ifdef gl_draw_scraps // load little ones into the scrap - if (p->width < 64 && p->height < 64) - { + if (p->width < 64 && p->height < 64) { int x, y; int i, j, k; int texnum; texnum = Scrap_AllocBlock (p->width, p->height, &x, &y); - scrap_dirty = true; k = 0; for (i=0 ; iheight ; i++) for (j=0 ; jwidth ; j++, k++) @@ -228,11 +244,9 @@ qpic_t *Draw_PicFromWad (char *name) gl->sh = (x+p->width-0.01)/(float)BLOCK_WIDTH; gl->tl = (y+0.01)/(float)BLOCK_WIDTH; gl->th = (y+p->height-0.01)/(float)BLOCK_WIDTH; - - pic_count++; - pic_texels += p->width*p->height; } else +#endif { gl->texnum = GL_LoadPicTexture (p); gl->sl = 0; @@ -240,9 +254,19 @@ qpic_t *Draw_PicFromWad (char *name) gl->tl = 0; gl->th = 1; } + return p; } +void +Draw_ClearCache (void) +{ + cachepic_t *pic; + int i; + + for (pic=cachepics, i=0 ; idirty = true; +} /* ================ @@ -256,74 +280,64 @@ qpic_t *Draw_CachePic (char *path) qpic_t *dat; glpic_t *gl; - for (pic=menu_cachepics, i=0 ; iname)) + // First, check and see if its cached.. + for (pic=cachepics, i=0 ; iname)) && !pic->dirty) return &pic->pic; - if (menu_numcachepics == MAX_CACHED_PICS) + // Its not cached, lets make sure we have space in the cache.. + if (numcachepics == MAX_CACHED_PICS) Sys_Error ("menu_numcachepics == MAX_CACHED_PICS"); - menu_numcachepics++; - strcpy (pic->name, path); -// -// load the pic from disk -// + // Load the picture.. dat = (qpic_t *)COM_LoadTempFile (path); if (!dat) Sys_Error ("Draw_CachePic: failed to load %s", path); + + // Adjust for endian.. SwapPic (dat); - // HACK HACK HACK --- we need to keep the bytes for - // the translatable player picture just for the menu - // configuration dialog - if (!strcmp (path, "gfx/menuplyr.lmp")) - memcpy (menuplyr_pixels, dat->data, dat->width*dat->height); + // Ok, the image is here, lets load it up into the cache.. + // First the image name.. + strncpy (pic->name, path, sizeof(pic->name)); + + // Now the width and height. pic->pic.width = dat->width; pic->pic.height = dat->height; + // Now feed it to the GL stuff and get a texture number.. gl = (glpic_t *)pic->pic.data; gl->texnum = GL_LoadPicTexture (dat); - gl->sl = 0; - gl->sh = 1; - gl->tl = 0; - gl->th = 1; + // Alignment stuff.. + gl->sl = 0; gl->sh = 1; gl->tl = 0; gl->th = 1; + + // Now lets mark this cache entry as used.. + pic->dirty = false; + numcachepics++; + + // FIXME: + // A really ugly kluge, keep a specific image in memory + // for the menu system. + // + // Some days I really dislike legacy support.. + + if (!strcmp (path, "gfx/menuplyr.lmp")) + memcpy (menuplyr_pixels, dat->data, dat->width*dat->height); + + // And now we are done, return what was asked for.. return &pic->pic; } -void Draw_CharToConback (int num, byte *dest) -{ - int row, col; - byte *source; - int drawline; - int x; - - row = num>>4; - col = num&15; - source = draw_chars + (row<<10) + (col<<3); - - drawline = 8; - - while (drawline--) - { - for (x=0 ; x<8 ; x++) - if (source[x] != 255) - dest[x] = 0x60 + source[x]; - source += 128; - dest += 320; - } - -} - typedef struct { char *name; int minimize, maximize; } glmode_t; -glmode_t modes[] = { +static glmode_t modes[] = { {"GL_NEAREST", GL_NEAREST, GL_NEAREST}, {"GL_LINEAR", GL_LINEAR, GL_LINEAR}, {"GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, @@ -337,7 +351,7 @@ glmode_t modes[] = { Draw_TextureMode_f =============== */ -void Draw_TextureMode_f (void) +static void Draw_TextureMode_f (void) { int i; gltexture_t *glt; @@ -356,7 +370,7 @@ void Draw_TextureMode_f (void) for (i=0 ; i< 6 ; i++) { - if (!strcasecmp (modes[i].name, Cmd_Argv(1) ) ) + if (!stricmp (modes[i].name, Cmd_Argv(1) ) ) break; } if (i == 6) @@ -373,13 +387,15 @@ void Draw_TextureMode_f (void) { if (glt->mipmap) { - GL_Bind (glt->texnum); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + glBindTexture (GL_TEXTURE_2D, glt->texnum); + glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); + glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); } } } +extern void glrmain_init(); +extern void glrsurf_init(); /* =============== Draw_Init @@ -388,24 +404,41 @@ Draw_Init void Draw_Init (void) { int i; - qpic_t *cb; - byte *dest; - int x, y; - char ver[40]; - glpic_t *gl; - int start; - byte *ncdata; - struct utsname utsname; + // LordHavoc: lighting mode + gl_lightmode = Cvar_Get("gl_lightmode", "1", CVAR_ARCHIVE, + "Lighting mode (0 = GLQuake style, 1 = new style)"); + brightness = Cvar_Get("brightness", "1", CVAR_ARCHIVE, + "Brightness"); + contrast = Cvar_Get("contrast", "1", CVAR_ARCHIVE, + "contrast"); + gl_nobind = Cvar_Get("gl_nobind", "0", CVAR_NONE, + "whether or not to inhibit texture binding"); + gl_max_size = Cvar_Get("gl_max_size", "1024", CVAR_NONE, + "None"); // CVAR_FIXME - set a description + gl_picmip = Cvar_Get("gl_picmip", "0", CVAR_NONE, + "None"); // CVAR_FIXME - set a description - gl_nobind = Cvar_Get("gl_nobind", "0", CVAR_NONE, "None"); - gl_max_size = Cvar_Get("gl_max_size", "1024", CVAR_NONE, "None"); - gl_picmip = Cvar_Get("gl_picmip", "0", CVAR_NONE, "None"); + // Console effects --KB + gl_constretch = Cvar_Get ("gl_constretch", "0", CVAR_ARCHIVE, + "whether slide the console or stretch it"); + gl_conalpha = Cvar_Get ("gl_conalpha", "0.6", CVAR_ARCHIVE, + "alpha value for the console background"); + gl_conspin = Cvar_Get ("gl_conspin", "0", CVAR_ARCHIVE, + "speed at which the console spins"); + + cl_verstring = Cvar_Get("cl_verstring", PROGRAM " " VERSION, CVAR_NONE, + "client version string"); // 3dfx can only handle 256 wide textures if (!strncasecmp ((char *)gl_renderer, "3dfx",4) || - strstr((char *)gl_renderer, "Glide")) - Cvar_Set(gl_max_size, "256"); + !strncasecmp ((char *)gl_renderer, "Mesa",4)) + Cvar_Set (gl_max_size, "256"); + + // LordHavoc: 3DFX's dithering has terrible artifacting when using lightmode 1 + if (!strncasecmp ((char *)gl_renderer, "3dfx",4)) + Cvar_Set (gl_lightmode, "0"); + lighthalf = gl_lightmode->value != 0; // to avoid re-rendering all lightmaps on first frame Cmd_AddCommand ("gl_texturemode", &Draw_TextureMode_f); @@ -419,100 +452,46 @@ void Draw_Init (void) draw_chars[i] = 255; // proper transparent color // now turn them into textures - char_texture = GL_LoadTexture ("charset", 128, 128, draw_chars, false, true); - - start = Hunk_LowMark(); - - cb = (qpic_t *)COM_LoadTempFile ("gfx/conback.lmp"); - if (!cb) - Sys_Error ("Couldn't load gfx/conback.lmp"); - SwapPic (cb); - - // hack the version number directly into the pic - uname(&utsname); - sprintf (ver, "(%s %s, gl %x) %s", utsname.sysname, utsname.release, GL_VERSION, VERSION); - dest = cb->data + 320*186 + 320 - 11 - 8*strlen(ver); - - y = strlen(ver); - for (x=0 ; xwidth = vid.conwidth; - conback->height = vid.conheight; - - // scale console to vid size - dest = ncdata = Hunk_AllocName(vid.conwidth * vid.conheight, "conback"); - - for (y=0 ; ydata + cb->width * (y*cb->height/vid.conheight); - if (vid.conwidth == cb->width) - memcpy (dest, src, vid.conwidth); - else - { - f = 0; - fstep = cb->width*0x10000/vid.conwidth; - for (x=0 ; x>16]; - f += fstep; - dest[x+1] = src[f>>16]; - f += fstep; - dest[x+2] = src[f>>16]; - f += fstep; - dest[x+3] = src[f>>16]; - f += fstep; - } - } - } -#else - conback->width = cb->width; - conback->height = cb->height; - ncdata = cb->data; -#endif +// char_texture = GL_LoadTexture ("charset", 128, 128, draw_chars, false, true, 1); // 1999-12-27 Conwidth/height charset fix by TcT +// Draw_CrosshairAdjust(); + cs_texture = GL_LoadTexture ("crosshair", 8, 8, cs_data, false, true, 1); + char_texture = GL_LoadTexture ("charset", 128, 128, draw_chars, false, true, 1); // 1999-12-27 Conwidth/height charset fix by TcT glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - gl = (glpic_t *)conback->data; - gl->texnum = GL_LoadTexture ("conback", conback->width, conback->height, ncdata, false, false); - gl->sl = 0; - gl->sh = 1; - gl->tl = 0; - gl->th = 1; - conback->width = vid.width; - conback->height = vid.height; - - // free loaded console - Hunk_FreeToLowMark(start); - // save a texture slot for translated picture translate_texture = texture_extension_number++; +#ifdef gl_draw_scraps // save slots for scraps scrap_texnum = texture_extension_number; texture_extension_number += MAX_SCRAPS; +#endif // // get the other pics we need // draw_disc = Draw_PicFromWad ("disc"); draw_backtile = Draw_PicFromWad ("backtile"); + + // LordHavoc: call init code for other GL renderer modules; + //XXXglrmain_init(); + //XXXglrsurf_init(); } /* ================ -Draw_Character +Draw_Character8 Draws one 8*8 graphics character with 0 being transparent. It can be clipped to the top of the screen to allow the console to be smoothly scrolled off. ================ */ -void Draw_Character (int x, int y, int num) +void Draw_Character8 (int x, int y, int num) { int row, col; float frow, fcol, size; @@ -532,8 +511,12 @@ void Draw_Character (int x, int y, int num) fcol = col*0.0625; size = 0.0625; - GL_Bind (char_texture); + glBindTexture (GL_TEXTURE_2D, char_texture); + if (lighthalf) + glColor3f(0.5,0.5,0.5); + else + glColor3f(1,1,1); glBegin (GL_QUADS); glTexCoord2f (fcol, frow); glVertex2f (x, y); @@ -548,14 +531,14 @@ void Draw_Character (int x, int y, int num) /* ================ -Draw_String +Draw_String8 ================ */ -void Draw_String (int x, int y, char *str) +void Draw_String8 (int x, int y, char *str) { while (*str) { - Draw_Character (x, y, *str); + Draw_Character8 (x, y, *str); str++; x += 8; } @@ -563,51 +546,53 @@ void Draw_String (int x, int y, char *str) /* ================ -Draw_DebugChar - -Draws a single character directly to the upper right corner of the screen. -This is for debugging lockups by drawing different chars in different parts -of the code. +Draw_AltString8 ================ */ -void Draw_DebugChar (char num) +void Draw_AltString8 (int x, int y, char *str) { + while (*str) + { + Draw_Character8 (x, y, (*str) | 0x80); + str++; + x += 8; + } } -/* -============= -Draw_AlphaPic -============= -*/ -void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha) +void Draw_Crosshair(void) { - glpic_t *gl; + int x, y; + extern vrect_t scr_vrect; + unsigned char *pColor; - if (scrap_dirty) - Scrap_Upload (); - gl = (glpic_t *)pic->data; - glDisable(GL_ALPHA_TEST); - glEnable (GL_BLEND); -// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -// glCullFace(GL_FRONT); - glColor4f (1,1,1,alpha); - GL_Bind (gl->texnum); - glBegin (GL_QUADS); - glTexCoord2f (gl->sl, gl->tl); - glVertex2f (x, y); - glTexCoord2f (gl->sh, gl->tl); - glVertex2f (x+pic->width, y); - glTexCoord2f (gl->sh, gl->th); - glVertex2f (x+pic->width, y+pic->height); - glTexCoord2f (gl->sl, gl->th); - glVertex2f (x, y+pic->height); - glEnd (); - glColor4f (1,1,1,1); - glEnable(GL_ALPHA_TEST); - glDisable (GL_BLEND); + if (crosshair->value == 2) + { + x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx->value; + y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy->value; + + pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value]; + if (lighthalf) + glColor4ub((byte) ((int) pColor[0] >> 1),(byte) ((int) pColor[1] >> 1), (byte) ((int) pColor[2] >> 1), pColor[3]); + else + glColor4ubv(pColor); + glBindTexture (GL_TEXTURE_2D, cs_texture); + + glBegin (GL_QUADS); + glTexCoord2f (0, 0); + glVertex2f (x - 4, y - 4); + glTexCoord2f (1, 0); + glVertex2f (x+12, y-4); + glTexCoord2f (1, 1); + glVertex2f (x+12, y+12); + glTexCoord2f (0, 1); + glVertex2f (x - 4, y+12); + glEnd (); + } + else if (crosshair->value) + Draw_Character8 (scr_vrect.x + scr_vrect.width/2-4 + cl_crossx->value, + scr_vrect.y + scr_vrect.height/2-4 + cl_crossy->value, '+'); } - /* ============= Draw_Pic @@ -617,11 +602,16 @@ void Draw_Pic (int x, int y, qpic_t *pic) { glpic_t *gl; +#ifdef gl_draw_scraps if (scrap_dirty) Scrap_Upload (); +#endif gl = (glpic_t *)pic->data; - glColor4f (1,1,1,1); - GL_Bind (gl->texnum); + if (lighthalf) + glColor3f(0.4,0.4,0.4); + else + glColor3f(0.8,0.8,0.8); + glBindTexture (GL_TEXTURE_2D, gl->texnum); glBegin (GL_QUADS); glTexCoord2f (gl->sl, gl->tl); glVertex2f (x, y); @@ -634,6 +624,43 @@ void Draw_Pic (int x, int y, qpic_t *pic) glEnd (); } +void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height) +{ + glpic_t *gl; + float newsl, newtl, newsh, newth; + float oldglwidth, oldglheight; + +#ifdef gl_draw_scraps + if (scrap_dirty) + Scrap_Upload (); +#endif + gl = (glpic_t *)pic->data; + + oldglwidth = gl->sh - gl->sl; + oldglheight = gl->th - gl->tl; + + newsl = gl->sl + (srcx*oldglwidth)/pic->width; + newsh = newsl + (width*oldglwidth)/pic->width; + + newtl = gl->tl + (srcy*oldglheight)/pic->height; + newth = newtl + (height*oldglheight)/pic->height; + + if (lighthalf) + glColor3f(0.4,0.4,0.4); + else + glColor3f(0.8,0.8,0.8); + glBindTexture (GL_TEXTURE_2D, gl->texnum); + glBegin (GL_QUADS); + glTexCoord2f (newsl, newtl); + glVertex2f (x, y); + glTexCoord2f (newsh, newtl); + glVertex2f (x+width, y); + glTexCoord2f (newsh, newth); + glVertex2f (x+width, y+height); + glTexCoord2f (newsl, newth); + glVertex2f (x, y+height); + glEnd (); +} /* ============= @@ -642,6 +669,7 @@ Draw_TransPic */ void Draw_TransPic (int x, int y, qpic_t *pic) { + if (x < 0 || (unsigned)(x + pic->width) > vid.width || y < 0 || (unsigned)(y + pic->height) > vid.height) { @@ -666,7 +694,7 @@ void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation) byte *src; int p; - GL_Bind (translate_texture); + glBindTexture (GL_TEXTURE_2D, translate_texture); c = pic->width * pic->height; @@ -689,7 +717,10 @@ void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glColor3f (1,1,1); + if (lighthalf) + glColor3f(0.4,0.4,0.4); + else + glColor3f(0.8,0.8,0.8); glBegin (GL_QUADS); glTexCoord2f (0, 0); glVertex2f (x, y); @@ -704,19 +735,91 @@ void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation) /* -================ -Draw_ConsoleBackground + Draw_ConsoleBackground -================ + Draws console background (obviously!) Completely rewritten to use + several simple yet very cool GL effects. --KB */ -void Draw_ConsoleBackground (int lines) +void +Draw_ConsoleBackground ( int lines ) { - int y = (vid.height * 3) >> 2; + int y; + qpic_t *conback; + glpic_t *gl; + float ofs; + float alpha; - if (lines > y) - Draw_Pic(0, lines - vid.height, conback); + // This can be a CachePic now, just like in software + conback = Draw_CachePic ("gfx/conback.lmp"); + gl = (glpic_t *)conback->data; + + // spin the console? - effect described in a QER tutorial + if (gl_conspin->value) + { + static float xangle = 0; + static float xfactor = .3f; + static float xstep = .005f; + + glPushMatrix (); + glMatrixMode (GL_TEXTURE); + glPushMatrix (); + glLoadIdentity (); + xangle += gl_conspin->value; + xfactor += xstep; + if (xfactor > 8 || xfactor < .3f) + xstep = -xstep; + glRotatef (xangle, 0, 0, 1); + glScalef (xfactor, xfactor, xfactor); + } + + // slide console up/down or stretch it? + if (gl_constretch->value) + ofs = 0; else - Draw_AlphaPic (0, lines - vid.height, conback, (float)(1.2 * lines)/y); + ofs = (vid.conheight - lines)/(float)vid.conheight; + + y = vid.height >> 1; + if (lines > y) + { + alpha = 1.0; + } else { + // set up to draw alpha console + alpha = (float)(gl_conalpha->value * lines)/y; + } + + if (lighthalf) + glColor4f(0.4,0.4,0.4,alpha); + else + glColor4f(0.8,0.8,0.8,alpha); + + // draw the console texture + glBindTexture (GL_TEXTURE_2D, gl->texnum); + glBegin (GL_QUADS); + glTexCoord2f (gl->sl, gl->tl + ofs); + glVertex2f (0, 0); + glTexCoord2f (gl->sh, gl->tl + ofs); + glVertex2f (vid.conwidth, 0); + glTexCoord2f (gl->sh, gl->th); + glVertex2f (vid.conwidth, lines); + glTexCoord2f (gl->sl, gl->th); + glVertex2f (0, lines); + glEnd (); + + // turn off alpha blending + if (alpha < 1.0) + { + if (lighthalf) + glColor3f(0.4,0.4,0.4); + else + glColor3f(0.8,0.8,0.8); + } + + if (gl_conspin->value) + { + glPopMatrix (); + glMatrixMode (GL_MODELVIEW); + glPopMatrix (); + } } @@ -730,8 +833,11 @@ refresh window. */ void Draw_TileClear (int x, int y, int w, int h) { - glColor3f (1,1,1); - GL_Bind (*(int *)draw_backtile->data); + if (lighthalf) + glColor3f(0.4,0.4,0.4); + else + glColor3f(0.8,0.8,0.8); + glBindTexture (GL_TEXTURE_2D, *(int *)draw_backtile->data); glBegin (GL_QUADS); glTexCoord2f (x/64.0, y/64.0); glVertex2f (x, y); @@ -755,9 +861,10 @@ Fills a box of pixels with a single color void Draw_Fill (int x, int y, int w, int h, int c) { glDisable (GL_TEXTURE_2D); - glColor3f (host_basepal[c*3]/255.0, - host_basepal[c*3+1]/255.0, - host_basepal[c*3+2]/255.0); + if (lighthalf) + glColor3f (host_basepal[c*3]/510.0, host_basepal[c*3+1]/510.0, host_basepal[c*3+2]/510.0); + else + glColor3f (host_basepal[c*3]/255.0, host_basepal[c*3+1]/255.0, host_basepal[c*3+2]/255.0); glBegin (GL_QUADS); @@ -767,7 +874,10 @@ void Draw_Fill (int x, int y, int w, int h, int c) glVertex2f (x, y+h); glEnd (); - glColor3f (1,1,1); + if (lighthalf) + glColor3f(0.5,0.5,0.5); + else + glColor3f(1,1,1); glEnable (GL_TEXTURE_2D); } //============================================================================= @@ -780,9 +890,8 @@ Draw_FadeScreen */ void Draw_FadeScreen (void) { - glEnable (GL_BLEND); glDisable (GL_TEXTURE_2D); - glColor4f (0, 0, 0, 0.8); + glColor4f (0, 0, 0, 0.7); glBegin (GL_QUADS); glVertex2f (0,0); @@ -791,9 +900,11 @@ void Draw_FadeScreen (void) glVertex2f (0, vid.height); glEnd (); - glColor4f (1,1,1,1); + if (lighthalf) + glColor3f(0.5,0.5,0.5); + else + glColor3f(1,1,1); glEnable (GL_TEXTURE_2D); - glDisable (GL_BLEND); Sbar_Changed(); } @@ -810,11 +921,6 @@ Call before beginning any disc IO. */ void Draw_BeginDisc (void) { - if (!draw_disc) - return; - glDrawBuffer (GL_FRONT); - Draw_Pic (vid.width - 24, 0, draw_disc); - glDrawBuffer (GL_BACK); } @@ -848,42 +954,27 @@ void GL_Set2D (void) glMatrixMode(GL_MODELVIEW); glLoadIdentity (); + glEnable (GL_BLEND); glDisable (GL_DEPTH_TEST); glDisable (GL_CULL_FACE); - glDisable (GL_BLEND); - glEnable (GL_ALPHA_TEST); -// glDisable (GL_ALPHA_TEST); - glColor4f (1,1,1,1); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + if (lighthalf) + glColor3f(0.5,0.5,0.5); + else + glColor3f(1,1,1); } //==================================================================== -/* -================ -GL_FindTexture -================ -*/ -int GL_FindTexture (char *identifier) -{ - int i; - gltexture_t *glt; - - for (i=0, glt=gltextures ; iidentifier)) - return gltextures[i].texnum; - } - - return -1; -} - /* ================ GL_ResampleTexture ================ */ -void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight) +static void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight) { int i, j; unsigned *inrow; @@ -913,7 +1004,7 @@ void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, GL_Resample8BitTexture -- JACK ================ */ -void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out, int outwidth, int outheight) +static void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out, int outwidth, int outheight) { int i, j; unsigned char *inrow; @@ -938,7 +1029,6 @@ void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsig } } - /* ================ GL_MipMap @@ -946,7 +1036,7 @@ GL_MipMap Operates in place, quartering the size of the texture ================ */ -void GL_MipMap (byte *in, int width, int height) +static void GL_MipMap (byte *in, int width, int height) { int i, j; byte *out; @@ -973,23 +1063,22 @@ GL_MipMap8Bit Mipping for 8 bit textures ================ */ -void GL_MipMap8Bit (byte *in, int width, int height) +static void GL_MipMap8Bit (byte *in, int width, int height) { int i, j; + byte *out; unsigned short r,g,b; - byte *out, *at1, *at2, *at3, *at4; + byte *at1, *at2, *at3, *at4; -// width <<=2; height >>= 1; out = in; for (i=0 ; i>=5; g = (at1[1]+at2[1]+at3[1]+at4[1]); g>>=5; @@ -997,7 +1086,6 @@ void GL_MipMap8Bit (byte *in, int width, int height) out[0] = d_15to8table[(r<<0) + (g<<5) + (b<<10)]; } - } } /* @@ -1005,7 +1093,7 @@ void GL_MipMap8Bit (byte *in, int width, int height) GL_Upload32 =============== */ -void GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap, qboolean alpha) +static void GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap, qboolean alpha) { int samples; static unsigned scaled[1024*512]; // [512*256]; @@ -1019,10 +1107,8 @@ static unsigned scaled[1024*512]; // [512*256]; scaled_width >>= (int)gl_picmip->value; scaled_height >>= (int)gl_picmip->value; - if (scaled_width > gl_max_size->value) - scaled_width = gl_max_size->value; - if (scaled_height > gl_max_size->value) - scaled_height = gl_max_size->value; + scaled_width = min(scaled_width, gl_max_size->value); + scaled_height = min(scaled_height, gl_max_size->value); if (scaled_width * scaled_height > sizeof(scaled)/4) Sys_Error ("GL_LoadTexture: too big"); @@ -1041,7 +1127,6 @@ static unsigned scaled[1024*512]; // [512*256]; glTexImage2D (GL_TEXTURE_2D, 0, samples, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled); } #else -texels += scaled_width * scaled_height; if (scaled_width == width && scaled_height == height) { @@ -1121,23 +1206,24 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole scaled_width >>= (int)gl_picmip->value; scaled_height >>= (int)gl_picmip->value; - if (scaled_width > gl_max_size->value) - scaled_width = gl_max_size->value; - if (scaled_height > gl_max_size->value) - scaled_height = gl_max_size->value; + scaled_width = min(scaled_width, gl_max_size->value); + scaled_height = min(scaled_height, gl_max_size->value); if (scaled_width * scaled_height > sizeof(scaled)) Sys_Error ("GL_LoadTexture: too big"); samples = 1; // alpha ? gl_alpha_format : gl_solid_format; - texels += scaled_width * scaled_height; - if (scaled_width == width && scaled_height == height) { if (!mipmap) { +/* FIXME - what if this extension isn't available? */ +#ifdef HAVE_GL_COLOR_INDEX8_EXT glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX , GL_UNSIGNED_BYTE, data); +#else + /* FIXME - should warn that this isn't available */ +#endif goto done; } memcpy (scaled, data, width*height); @@ -1145,7 +1231,12 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole else GL_Resample8BitTexture (data, width, height, scaled, scaled_width, scaled_height); +// FIXME - what if this extension isn't available? +#ifdef HAVE_GL_COLOR_INDEX8_EXT glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled); +#else + /* FIXME - should warn that this isn't available */ +#endif if (mipmap) { int miplevel; @@ -1161,12 +1252,16 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole if (scaled_height < 1) scaled_height = 1; miplevel++; +/* FIXME - what if this extension isn't available? */ +#ifdef HAVE_GL_COLOR_INDEX8_EXT glTexImage2D (GL_TEXTURE_2D, miplevel, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled); +#else + /* FIXME - should warn that this isn't available */ +#endif } } done: ; - if (mipmap) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); @@ -1179,6 +1274,8 @@ done: ; } } +extern qboolean VID_Is8bit(); + /* =============== GL_Upload8 @@ -1221,10 +1318,16 @@ static unsigned trans[640*480]; // FIXME, temporary } } - if (VID_Is8bit() && !alpha && (data!=scrap_texels[0])) { - GL_Upload8_EXT (data, width, height, mipmap, alpha); - return; +#ifdef gl_draw_scraps + if (VID_Is8bit() && !alpha && (data!=scrap_texels[0])) +#else + if (VID_Is8bit() && !alpha) +#endif + { + GL_Upload8_EXT (data, width, height, mipmap, alpha); + return; } + GL_Upload32 (trans, width, height, mipmap, alpha); } @@ -1233,11 +1336,19 @@ static unsigned trans[640*480]; // FIXME, temporary GL_LoadTexture ================ */ -int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha) +int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel) { - int i; - gltexture_t *glt; + int i, s, lcrc; + gltexture_t *glt; + // LordHavoc's cache check, not a standard crc but it works --KB + lcrc = 0; + s = width*height*bytesperpixel; // size + for (i = 0; i < 256; i++) + ltexcrctable[i] = i + 1; + for (i = 0; i < s; i++) + lcrc += (ltexcrctable[data[i] & 255]++); + // see if the texture is allready present if (identifier[0]) { @@ -1245,40 +1356,63 @@ int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolea { if (!strcmp (identifier, glt->identifier)) { - if (width != glt->width || height != glt->height) - Sys_Error ("GL_LoadTexture: cache mismatch"); - return gltextures[i].texnum; + if (lcrc != glt->crc + || width != glt->width + || height != glt->height + || bytesperpixel != glt->bytesperpixel) + goto SetupTexture; + else + return gltextures[i].texnum; } } } - else { - glt = &gltextures[numgltextures]; - numgltextures++; - } - strcpy (glt->identifier, identifier); + if (numgltextures == MAX_GLTEXTURES) + Sys_Error ("numgltextures == MAX_GLTEXTURES"); + + glt = &gltextures[numgltextures]; + numgltextures++; + + strncpy (glt->identifier, identifier, sizeof(glt->identifier) - 1); + glt->identifier[sizeof(glt->identifier) - 1] = '\0'; + glt->texnum = texture_extension_number; - glt->width = width; - glt->height = height; - glt->mipmap = mipmap; - - GL_Bind(texture_extension_number ); - - GL_Upload8 (data, width, height, mipmap, alpha); - texture_extension_number++; - return texture_extension_number-1; +SetupTexture: + glt->crc = lcrc; + glt->width = width; + glt->height = height; + glt->bytesperpixel = bytesperpixel; + glt->mipmap = mipmap; + + glBindTexture (GL_TEXTURE_2D, glt->texnum); + + switch (glt->bytesperpixel) + { + case 1: + GL_Upload8 (data, width, height, mipmap, alpha); + break; + case 4: + GL_Upload32 ((unsigned *)data, width, height, mipmap, alpha); + break; + default: + Sys_Error ("SetupTexture: unknown bytesperpixel %i", + glt->bytesperpixel); + } + + return glt->texnum; } + /* ================ GL_LoadPicTexture ================ */ -int GL_LoadPicTexture (qpic_t *pic) +static int GL_LoadPicTexture (qpic_t *pic) { - return GL_LoadTexture ("", pic->width, pic->height, pic->data, false, true); + return GL_LoadTexture ("", pic->width, pic->height, pic->data, false, true, 1); } /****************************************/ @@ -1296,3 +1430,4 @@ void GL_SelectTexture (GLenum target) currenttexture = cnttextures[target-TEXTURE0_SGIS]; oldtarget = target; } + diff --git a/source/gl_model.c b/source/gl_model.c index 0d815ad..d1b3b2e 100644 --- a/source/gl_model.c +++ b/source/gl_model.c @@ -403,7 +403,7 @@ void Mod_LoadTextures (lump_t *l) else { texture_mode = GL_LINEAR_MIPMAP_NEAREST; //_LINEAR; - tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false); + tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false, 1); texture_mode = GL_LINEAR; } } @@ -1458,7 +1458,7 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype) pheader->gl_texturenum[i][2] = pheader->gl_texturenum[i][3] = GL_LoadTexture (name, pheader->skinwidth, - pheader->skinheight, (byte *)(pskintype + 1), true, false); + pheader->skinheight, (byte *)(pskintype + 1), true, false, 1); pskintype = (daliasskintype_t *)((byte *)(pskintype+1) + s); } else { // animating skin group. yuck. @@ -1480,7 +1480,7 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype) sprintf (name, "%s_%i_%i", loadmodel->name, i,j); pheader->gl_texturenum[i][j&3] = GL_LoadTexture (name, pheader->skinwidth, - pheader->skinheight, (byte *)(pskintype), true, false); + pheader->skinheight, (byte *)(pskintype), true, false, 1); pskintype = (daliasskintype_t *)((byte *)(pskintype) + s); } k = j; @@ -1696,7 +1696,7 @@ void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe, int framenum) pspriteframe->right = width + origin[0]; sprintf (name, "%s_%i", loadmodel->name, framenum); - pspriteframe->gl_texturenum = GL_LoadTexture (name, width, height, (byte *)(pinframe + 1), true, true); + pspriteframe->gl_texturenum = GL_LoadTexture (name, width, height, (byte *)(pinframe + 1), true, true, 1); return (void *)((byte *)pinframe + sizeof (dspriteframe_t) + size); } diff --git a/source/gl_part.c b/source/gl_part.c index f83c46e..31a945f 100644 --- a/source/gl_part.c +++ b/source/gl_part.c @@ -58,7 +58,7 @@ void R_DrawParticles (void) vec3_t up, right; float scale; - GL_Bind(particletexture); + glBindTexture (GL_TEXTURE_2D, particletexture); glEnable (GL_BLEND); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBegin (GL_TRIANGLES); diff --git a/source/gl_rmain.c b/source/gl_rmain.c index 1156ed9..b2955d9 100644 --- a/source/gl_rmain.c +++ b/source/gl_rmain.c @@ -240,7 +240,7 @@ void R_DrawSpriteModel (entity_t *e) GL_DisableMultitexture(); - GL_Bind(frame->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, frame->gl_texturenum); glEnable (GL_ALPHA_TEST); glBegin (GL_QUADS); @@ -552,7 +552,7 @@ void R_DrawAliasModel (entity_t *e) } 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 // seperately for the players. Heads are just uncolored. @@ -560,7 +560,7 @@ void R_DrawAliasModel (entity_t *e) { i = currententity - cl_entities; if (i >= 1 && i<=cl.maxclients /* && !strcmp (currententity->model->name, "progs/player.mdl") */) - GL_Bind(playertextures - 1 + i); + glBindTexture (GL_TEXTURE_2D, playertextures - 1 + i); } if (gl_smoothmodels->value) diff --git a/source/gl_rmisc.c b/source/gl_rmisc.c index bd5fbaa..56c26c8 100644 --- a/source/gl_rmisc.c +++ b/source/gl_rmisc.c @@ -89,7 +89,7 @@ void R_InitParticleTexture (void) // particle texture // particletexture = texture_extension_number++; - GL_Bind(particletexture); + glBindTexture (GL_TEXTURE_2D, particletexture); for (x=0 ; x<8 ; x++) { @@ -303,7 +303,7 @@ void R_TranslatePlayerSkin (int playernum) // because this happens during gameplay, do it fast // instead of sending it through gl_upload 8 - GL_Bind(playertextures + playernum); + glBindTexture (GL_TEXTURE_2D, playertextures + playernum); #if 0 byte translated[320*200]; diff --git a/source/gl_rsurf.c b/source/gl_rsurf.c index 2bc9139..6f30135 100644 --- a/source/gl_rsurf.c +++ b/source/gl_rsurf.c @@ -344,7 +344,7 @@ void R_DrawSequentialPoly (msurface_t *s) p = s->polys; t = R_TextureAnimation (s->texinfo->texture); - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); glBegin (GL_POLYGON); v = p->verts[0]; for (i=0 ; inumverts ; i++, v+= VERTEXSIZE) @@ -354,7 +354,7 @@ void R_DrawSequentialPoly (msurface_t *s) } glEnd (); - GL_Bind (lightmap_textures + s->lightmaptexturenum); + glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum); glEnable (GL_BLEND); glBegin (GL_POLYGON); v = p->verts[0]; @@ -375,7 +375,7 @@ void R_DrawSequentialPoly (msurface_t *s) // if (s->flags & SURF_DRAWTURB) { - GL_Bind (s->texinfo->texture->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, s->texinfo->texture->gl_texturenum); EmitWaterPolys (s); return; } @@ -385,7 +385,7 @@ void R_DrawSequentialPoly (msurface_t *s) // if (s->flags & SURF_DRAWSKY) { - GL_Bind (solidskytexture); + glBindTexture (GL_TEXTURE_2D, solidskytexture); speedscale = realtime*8; speedscale -= (int)speedscale; @@ -393,7 +393,7 @@ void R_DrawSequentialPoly (msurface_t *s) glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - GL_Bind (alphaskytexture); + glBindTexture (GL_TEXTURE_2D, alphaskytexture); speedscale = realtime*16; speedscale -= (int)speedscale; EmitSkyPolys (s); @@ -409,10 +409,10 @@ void R_DrawSequentialPoly (msurface_t *s) p = s->polys; t = R_TextureAnimation (s->texinfo->texture); - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); DrawGLWaterPoly (p); - GL_Bind (lightmap_textures + s->lightmaptexturenum); + glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum); glEnable (GL_BLEND); DrawGLWaterPolyLightmap (p); glDisable (GL_BLEND); @@ -448,11 +448,11 @@ void R_DrawSequentialPoly (msurface_t *s) t = R_TextureAnimation (s->texinfo->texture); // Binds world to texture env 0 GL_SelectTexture(TEXTURE0_SGIS); - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); // Binds lightmap to texenv 1 GL_EnableMultitexture(); // Same as SelectTexture (TEXTURE1) - GL_Bind (lightmap_textures + s->lightmaptexturenum); + glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum); i = s->lightmaptexturenum; if (lightmap_modified[i]) { @@ -481,7 +481,7 @@ void R_DrawSequentialPoly (msurface_t *s) p = s->polys; t = R_TextureAnimation (s->texinfo->texture); - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); glBegin (GL_POLYGON); v = p->verts[0]; for (i=0 ; inumverts ; i++, v+= VERTEXSIZE) @@ -491,7 +491,7 @@ void R_DrawSequentialPoly (msurface_t *s) } glEnd (); - GL_Bind (lightmap_textures + s->lightmaptexturenum); + glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum); glEnable (GL_BLEND); glBegin (GL_POLYGON); v = p->verts[0]; @@ -515,7 +515,7 @@ void R_DrawSequentialPoly (msurface_t *s) if (s->flags & SURF_DRAWTURB) { GL_DisableMultitexture(); - GL_Bind (s->texinfo->texture->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, s->texinfo->texture->gl_texturenum); EmitWaterPolys (s); return; } @@ -526,14 +526,14 @@ void R_DrawSequentialPoly (msurface_t *s) if (s->flags & SURF_DRAWSKY) { GL_DisableMultitexture(); - GL_Bind (solidskytexture); + glBindTexture (GL_TEXTURE_2D, solidskytexture); speedscale = realtime*8; speedscale -= (int)speedscale & ~127; EmitSkyPolys (s); glEnable (GL_BLEND); - GL_Bind (alphaskytexture); + glBindTexture (GL_TEXTURE_2D, alphaskytexture); speedscale = realtime*16; speedscale -= (int)speedscale & ~127; EmitSkyPolys (s); @@ -551,10 +551,10 @@ void R_DrawSequentialPoly (msurface_t *s) t = R_TextureAnimation (s->texinfo->texture); GL_SelectTexture(TEXTURE0_SGIS); - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); GL_EnableMultitexture(); - GL_Bind (lightmap_textures + s->lightmaptexturenum); + glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum); i = s->lightmaptexturenum; if (lightmap_modified[i]) { @@ -588,10 +588,10 @@ void R_DrawSequentialPoly (msurface_t *s) p = s->polys; t = R_TextureAnimation (s->texinfo->texture); - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); DrawGLWaterPoly (p); - GL_Bind (lightmap_textures + s->lightmaptexturenum); + glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum); glEnable (GL_BLEND); DrawGLWaterPolyLightmap (p); glDisable (GL_BLEND); @@ -712,7 +712,7 @@ void R_BlendLightmaps (void) p = lightmap_polys[i]; if (!p) continue; - GL_Bind(lightmap_textures+i); + glBindTexture (GL_TEXTURE_2D, lightmap_textures+i); if (lightmap_modified[i]) { lightmap_modified[i] = false; @@ -783,7 +783,7 @@ void R_RenderBrushPoly (msurface_t *fa) } t = R_TextureAnimation (fa->texinfo->texture); - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); if (fa->flags & SURF_DRAWTURB) { // warp texture, no lightmaps @@ -946,7 +946,7 @@ void R_DrawWaterSurfaces (void) continue; // set modulate mode explicitly - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); for ( ; s ; s=s->texturechain) R_RenderBrushPoly (s); @@ -991,7 +991,7 @@ void R_DrawWaterSurfaces (void) return; 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); } @@ -1011,7 +1011,7 @@ void R_DrawWaterSurfaces (void) // set modulate mode explicitly - GL_Bind (t->gl_texturenum); + glBindTexture (GL_TEXTURE_2D, t->gl_texturenum); for ( ; s ; s=s->texturechain) EmitWaterPolys (s); @@ -1679,7 +1679,7 @@ void GL_BuildLightmaps (void) lightmap_rectchange[i].t = BLOCK_HEIGHT; lightmap_rectchange[i].w = 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_MAG_FILTER, GL_LINEAR); glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes diff --git a/source/gl_screen.c b/source/gl_screen.c index 105fb8b..2ff8c90 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -215,7 +215,7 @@ void SCR_DrawCenterString (void) x = (vid.width - l*8)/2; for (j=0 ; jvalue) - Draw_Character (scr_vrect.x + scr_vrect.width/2, scr_vrect.y + scr_vrect.height/2, '+'); + Draw_Character8 (scr_vrect.x + scr_vrect.width/2, scr_vrect.y + scr_vrect.height/2, '+'); SCR_DrawRam (); SCR_DrawNet (); diff --git a/source/gl_warp.c b/source/gl_warp.c index 9ffab03..b79d721 100644 --- a/source/gl_warp.c +++ b/source/gl_warp.c @@ -285,14 +285,14 @@ void EmitBothSkyLayers (msurface_t *fa) { GL_DisableMultitexture(); - GL_Bind (solidskytexture); + glBindTexture (GL_TEXTURE_2D, solidskytexture); speedscale = realtime*8; speedscale -= (int)speedscale & ~127 ; EmitSkyPolys (fa); glEnable (GL_BLEND); - GL_Bind (alphaskytexture); + glBindTexture (GL_TEXTURE_2D, alphaskytexture); speedscale = realtime*16; speedscale -= (int)speedscale & ~127 ; @@ -314,7 +314,7 @@ void R_DrawSkyChain (msurface_t *s) GL_DisableMultitexture(); // used when gl_texsort is on - GL_Bind(solidskytexture); + glBindTexture (GL_TEXTURE_2D, solidskytexture); speedscale = realtime*8; speedscale -= (int)speedscale & ~127 ; @@ -322,7 +322,7 @@ void R_DrawSkyChain (msurface_t *s) EmitSkyPolys (fa); glEnable (GL_BLEND); - GL_Bind (alphaskytexture); + glBindTexture (GL_TEXTURE_2D, alphaskytexture); speedscale = realtime*16; speedscale -= (int)speedscale & ~127 ; @@ -653,7 +653,7 @@ void R_LoadSkys (void) for (i=0 ; i<6 ; i++) { - GL_Bind (SKY_TEX + i); + glBindTexture (GL_TEXTURE_2D, SKY_TEX + i); sprintf (name, "gfx/env/bkgtst%s.tga", suf[i]); COM_FOpenFile (name, &f); if (!f) @@ -907,7 +907,7 @@ void R_DrawSkyChain (msurface_t *s) glpoly_t *p; c_sky = 0; - GL_Bind(solidskytexture); + glBindTexture (GL_TEXTURE_2D, solidskytexture); // calculate vertex values for sky box @@ -1003,7 +1003,7 @@ glDisable (GL_DEPTH_TEST); || skymins[1][i] >= skymaxs[1][i]) continue; - GL_Bind (SKY_TEX+skytexorder[i]); + glBindTexture (GL_TEXTURE_2D, SKY_TEX+skytexorder[i]); #if 0 skymins[0][i] = -1; skymins[1][i] = -1; @@ -1071,7 +1071,7 @@ void R_InitSky (texture_t *mt) if (!solidskytexture) 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); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -1089,7 +1089,7 @@ void R_InitSky (texture_t *mt) if (!alphaskytexture) 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); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); diff --git a/source/menu.c b/source/menu.c index d37cdce..e8ebbc5 100644 --- a/source/menu.c +++ b/source/menu.c @@ -137,7 +137,7 @@ Draws one solid graphics character */ void M_DrawCharacter (int cx, int line, int num) { - Draw_Character ( cx + ((vid.width - 320)>>1), line, num); + Draw_Character8 ( cx + ((vid.width - 320)>>1), line, num); } void M_Print (int cx, int cy, char *str) diff --git a/source/r_main.c b/source/r_main.c index 89abe92..848bbbc 100644 --- a/source/r_main.c +++ b/source/r_main.c @@ -958,7 +958,7 @@ void R_EdgeDrawing (void) R_ScanEdges (); } - +void R_SetupFrame(void); /* ================ R_RenderView diff --git a/source/r_view.c b/source/r_view.c index 299dcbc..5cef261 100644 --- a/source/r_view.c +++ b/source/r_view.c @@ -76,6 +76,7 @@ cvar_t *v_ipitch_level; cvar_t *v_idlescale; cvar_t *crosshair; +cvar_t *crosshaircolor; cvar_t *cl_crossx; cvar_t *cl_crossy; @@ -825,6 +826,7 @@ void V_Init (void) v_idlescale = Cvar_Get("v_idlescale", "0", CVAR_NONE, "None"); crosshair = Cvar_Get("crosshair", "0", CVAR_ARCHIVE, "None"); + crosshaircolor = Cvar_Get("crosshaircolor", "79", CVAR_ARCHIVE, "None"); cl_crossx = Cvar_Get("cl_crossx", "0", CVAR_NONE, "None"); cl_crossy = Cvar_Get("cl_crossy", "0", CVAR_NONE, "None"); gl_cshiftpercent = Cvar_Get("gl_cshiftpercent", "100", CVAR_NONE, "None"); diff --git a/source/sbar.c b/source/sbar.c index c055615..af73fd8 100644 --- a/source/sbar.c +++ b/source/sbar.c @@ -306,9 +306,9 @@ Draws one solid graphics character void Sbar_DrawCharacter (int x, int y, int num) { if (cl.gametype == GAME_DEATHMATCH) - Draw_Character ( x /*+ ((vid.width - 320)>>1) */ + 4 , y + vid.height-SBAR_HEIGHT, num); + Draw_Character8 ( x /*+ ((vid.width - 320)>>1) */ + 4 , y + vid.height-SBAR_HEIGHT, num); else - Draw_Character ( x + ((vid.width - 320)>>1) + 4 , y + vid.height-SBAR_HEIGHT, num); + Draw_Character8 ( x + ((vid.width - 320)>>1) + 4 , y + vid.height-SBAR_HEIGHT, num); } /* @@ -319,9 +319,9 @@ Sbar_DrawString void Sbar_DrawString (int x, int y, char *str) { if (cl.gametype == GAME_DEATHMATCH) - Draw_String (x /*+ ((vid.width - 320)>>1)*/, y+ vid.height-SBAR_HEIGHT, str); + Draw_String8 (x /*+ ((vid.width - 320)>>1)*/, y+ vid.height-SBAR_HEIGHT, str); else - Draw_String (x + ((vid.width - 320)>>1), y+ vid.height-SBAR_HEIGHT, str); + Draw_String8 (x + ((vid.width - 320)>>1), y+ vid.height-SBAR_HEIGHT, str); } /* @@ -1144,12 +1144,12 @@ void Sbar_DeathmatchOverlay (void) f = s->frags; sprintf (num, "%3i",f); - Draw_Character ( x+8 , y, num[0]); - Draw_Character ( x+16 , y, num[1]); - Draw_Character ( x+24 , y, num[2]); + Draw_Character8 ( x+8 , y, num[0]); + Draw_Character8 ( x+16 , y, num[1]); + Draw_Character8 ( x+24 , y, num[2]); if (k == cl.viewentity - 1) - Draw_Character ( x - 8, y, 12); + Draw_Character8 ( x - 8, y, 12); #if 0 { @@ -1165,12 +1165,12 @@ void Sbar_DeathmatchOverlay (void) sprintf (num, "%3i:%i%i", minutes, tens, units); - Draw_String ( x+48 , y, num); + Draw_String8 ( x+48 , y, num); } #endif // draw name - Draw_String (x+64, y, s->name); + Draw_String8 (x+64, y, s->name); y += 10; } @@ -1243,13 +1243,13 @@ void Sbar_MiniDeathmatchOverlay (void) f = s->frags; sprintf (num, "%3i",f); - Draw_Character ( x+8 , y, num[0]); - Draw_Character ( x+16 , y, num[1]); - Draw_Character ( x+24 , y, num[2]); + Draw_Character8 ( x+8 , y, num[0]); + Draw_Character8 ( x+16 , y, num[1]); + Draw_Character8 ( x+24 , y, num[2]); if (k == cl.viewentity - 1) { - Draw_Character ( x, y, 16); - Draw_Character ( x + 32, y, 17); + Draw_Character8 ( x, y, 16); + Draw_Character8 ( x + 32, y, 17); } #if 0 @@ -1266,12 +1266,12 @@ void Sbar_MiniDeathmatchOverlay (void) sprintf (num, "%3i:%i%i", minutes, tens, units); - Draw_String ( x+48 , y, num); + Draw_String8 ( x+48 , y, num); } #endif // draw name - Draw_String (x+48, y, s->name); + Draw_String8 (x+48, y, s->name); y += 8; } diff --git a/source/screen.c b/source/screen.c index 1cff6ac..e753462 100644 --- a/source/screen.c +++ b/source/screen.c @@ -179,7 +179,7 @@ void SCR_DrawCenterString (void) x = (vid.width - l*8)/2; for (j=0 ; jvalue) - Draw_Character (scr_vrect.x + scr_vrect.width/2 + cl_crossx->value, + Draw_Character8 (scr_vrect.x + scr_vrect.width/2 + cl_crossx->value, scr_vrect.y + scr_vrect.height/2 + cl_crossy->value, '+'); }