- int i;
- qpic_t *cb;
- byte *dest;
- int x, y;
- char ver[40];
- glpic_t *gl;
- int start;
-
- Cvar_RegisterVariable (&qsg_version);
- Cvar_RegisterVariable (&gl_max_size);
- Cvar_RegisterVariable (&gl_picmip);
- Cvar_RegisterVariable (&gl_conalpha);
- Cvar_RegisterVariable (&gl_lerpimages);
-
- // 3dfx can only handle 256 wide textures
- if (!Q_strncasecmp ((char *)gl_renderer, "3dfx",4) ||
- strstr((char *)gl_renderer, "Glide"))
- Cvar_Set ("gl_max_size", "256");
-
- Cmd_AddCommand ("gl_texturemode", &Draw_TextureMode_f);
-
- Cmd_AddCommand ("loadsky", &LoadSky_f);
-
- // load the console background and the charset
- // by hand, because we need to write the version
- // string into the background before turning
- // it into a texture
- draw_chars = W_GetLumpName ("conchars");
- for (i=0 ; i<256*64 ; i++)
- if (draw_chars[i] == 0)
- draw_chars[i] = 255; // proper transparent color
-
- // now turn them into textures
- char_texture = GL_LoadTexture ("charset", 128, 128, draw_chars, false, true, 1);
-
- start = Hunk_LowMark();
-
- cb = (qpic_t *)COM_LoadTempFile ("gfx/conback.lmp", false);
- if (!cb)
- Sys_Error ("Couldn't load gfx/conback.lmp");
- SwapPic (cb);
-
- // hack the version number directly into the pic
-#ifdef NEHAHRA
-#if defined(__linux__)
- sprintf (ver, "(DPNehahra %.2f, Linux %2.2f, gl %.2f) %.2f", (float) DP_VERSION, (float)LINUX_VERSION, (float)GLQUAKE_VERSION, (float)VERSION);
-#else
- sprintf (ver, "(DPNehahra %.2f, gl %.2f) %.2f", (float) DP_VERSION, (float)GLQUAKE_VERSION, (float)VERSION);
-#endif
-#else
-#if defined(__linux__)
- sprintf (ver, "(DarkPlaces %.2f, Linux %2.2f, gl %.2f) %.2f", (float) DP_VERSION, (float)LINUX_VERSION, (float)GLQUAKE_VERSION, (float)VERSION);
-#else
- sprintf (ver, "(DarkPlaces %.2f, gl %.2f) %.2f", (float) DP_VERSION, (float)GLQUAKE_VERSION, (float)VERSION);
-#endif
-#endif
- dest = cb->data + 320*186 + 320 - 11 - 8*strlen(ver);
- y = strlen(ver);
- for (x=0 ; x<y ; x++)
- Draw_CharToConback (ver[x], dest+(x<<3));
-
- gl = (glpic_t *)conback->data;
- gl->texnum = GL_LoadTexture ("conback", cb->width, cb->height, cb->data, false, false, 1);
- 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++;
-
- // save slots for scraps
- scrap_texnum = texture_extension_number;
- texture_extension_number += MAX_SCRAPS;
-
- //
- // get the other pics we need
- //
- draw_disc = Draw_PicFromWad ("disc");
-
- rmain_registercvars();
-}
-
-
-/*
-================
-Draw_Character
-
-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)
-{
- int row, col;
- float frow, fcol, size;
-
- if (num == 32)
- return; // space
-
- num &= 255;
-
- if (y <= -8)
- return; // totally off screen
-
- row = num>>4;
- col = num&15;
-
- frow = row*0.0625;
- fcol = col*0.0625;
- size = 0.0625;
-
- glBindTexture(GL_TEXTURE_2D, char_texture);
- // LordHavoc: NEAREST mode on text if not scaling up
- if ((int) vid.width < glwidth)
- {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- }
-
- glColor3f(1,1,1);
- glBegin (GL_QUADS);
- glTexCoord2f (fcol, frow);
- glVertex2f (x, y);
- glTexCoord2f (fcol + size, frow);
- glVertex2f (x+8, y);
- glTexCoord2f (fcol + size, frow + size);
- glVertex2f (x+8, y+8);
- glTexCoord2f (fcol, frow + size);
- glVertex2f (x, y+8);
- glEnd ();
-
- // LordHavoc: revert to LINEAR mode
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-}