2009-03-05 09:07:55 +00:00
|
|
|
/*
|
2010-10-20 08:49:28 +00:00
|
|
|
* Copyright (C) 1997-2001 Id Software, Inc.
|
|
|
|
*
|
2010-10-21 07:29:20 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
2010-10-20 08:49:28 +00:00
|
|
|
*
|
2010-10-21 07:29:20 +00:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-10-20 08:49:28 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-10-21 07:29:20 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
2010-10-20 08:49:28 +00:00
|
|
|
*
|
2010-10-21 07:29:20 +00:00
|
|
|
* =======================================================================
|
|
|
|
*
|
|
|
|
* Drawing of all images that are not textures
|
|
|
|
*
|
|
|
|
* =======================================================================
|
2012-04-29 13:57:33 +00:00
|
|
|
*/
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2009-03-05 11:03:08 +00:00
|
|
|
#include "header/local.h"
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
image_t *draw_chars;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
extern qboolean scrap_dirty;
|
2012-07-21 12:09:45 +00:00
|
|
|
void Scrap_Upload(void);
|
|
|
|
|
|
|
|
extern unsigned r_rawpalette[256];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2015-11-24 13:16:18 +00:00
|
|
|
static cvar_t *gl_nolerp_list;
|
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_InitLocal(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2015-11-24 13:19:16 +00:00
|
|
|
/* don't bilerp characters and crosshairs */
|
|
|
|
gl_nolerp_list = Cvar_Get("gl_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", 0);
|
2015-11-24 13:16:18 +00:00
|
|
|
|
|
|
|
/* load console characters */
|
2012-07-21 12:09:45 +00:00
|
|
|
draw_chars = R_FindImage("pics/conchars.pcx", it_pic);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-10-20 08:49:28 +00:00
|
|
|
* 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
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_Char(int x, int y, int num)
|
2014-04-25 19:24:26 +00:00
|
|
|
{
|
|
|
|
Draw_CharScaled(x, y, num, 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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_CharScaled(int x, int y, int num, float scale)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-20 08:49:28 +00:00
|
|
|
int row, col;
|
2014-04-25 19:24:26 +00:00
|
|
|
float frow, fcol, size, scaledSize;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
num &= 255;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if ((num & 127) == 32)
|
2010-10-20 08:49:28 +00:00
|
|
|
{
|
|
|
|
return; /* space */
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (y <= -8)
|
2010-10-20 08:49:28 +00:00
|
|
|
{
|
|
|
|
return; /* totally off screen */
|
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
row = num >> 4;
|
|
|
|
col = num & 15;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
frow = row * 0.0625;
|
|
|
|
fcol = col * 0.0625;
|
2009-03-05 09:07:55 +00:00
|
|
|
size = 0.0625;
|
|
|
|
|
2014-04-25 19:24:26 +00:00
|
|
|
scaledSize = 8*scale;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Bind(draw_chars->texnum);
|
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
GLfloat vtx[] = {
|
|
|
|
x, y,
|
|
|
|
x + scaledSize, y,
|
|
|
|
x + scaledSize, y + scaledSize,
|
|
|
|
x, y + scaledSize
|
|
|
|
};
|
|
|
|
|
|
|
|
GLfloat tex[] = {
|
|
|
|
fcol, frow,
|
|
|
|
fcol + size, frow,
|
|
|
|
fcol + size, frow + size,
|
|
|
|
fcol, frow + size
|
|
|
|
};
|
|
|
|
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, vtx );
|
|
|
|
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
image_t *
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_FindPic(char *name)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
image_t *gl;
|
2012-07-21 12:09:45 +00:00
|
|
|
char fullname[MAX_QPATH];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if ((name[0] != '/') && (name[0] != '\\'))
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
Com_sprintf(fullname, sizeof(fullname), "pics/%s.pcx", name);
|
|
|
|
gl = R_FindImage(fullname, it_pic);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
2010-10-20 08:49:28 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
gl = R_FindImage(name + 1, it_pic);
|
2010-10-20 08:49:28 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
return gl;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_GetPicSize(int *w, int *h, char *pic)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
image_t *gl;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
gl = Draw_FindPic(pic);
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!gl)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
*w = *h = -1;
|
|
|
|
return;
|
|
|
|
}
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2009-03-05 09:07:55 +00:00
|
|
|
*w = gl->width;
|
|
|
|
*h = gl->height;
|
|
|
|
}
|
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_StretchPic(int x, int y, int w, int h, char *pic)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
image_t *gl;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
gl = Draw_FindPic(pic);
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!gl)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "Can't find pic: %s\n", pic);
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (scrap_dirty)
|
2010-10-20 08:49:28 +00:00
|
|
|
{
|
|
|
|
Scrap_Upload();
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Bind(gl->texnum);
|
2014-06-14 08:07:33 +00:00
|
|
|
|
|
|
|
GLfloat vtx[] = {
|
|
|
|
x, y,
|
|
|
|
x + w, y,
|
|
|
|
x + w, y + h,
|
|
|
|
x, y + h
|
|
|
|
};
|
|
|
|
|
|
|
|
GLfloat tex[] = {
|
|
|
|
gl->sl, gl->tl,
|
|
|
|
gl->sh, gl->tl,
|
|
|
|
gl->sh, gl->th,
|
|
|
|
gl->sl, gl->th
|
|
|
|
};
|
|
|
|
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, vtx );
|
|
|
|
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
2010-10-20 08:49:28 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_Pic(int x, int y, char *pic)
|
2014-04-25 19:24:26 +00:00
|
|
|
{
|
|
|
|
Draw_PicScaled(x, y, pic, 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Draw_PicScaled(int x, int y, char *pic, float factor)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
image_t *gl;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
gl = Draw_FindPic(pic);
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!gl)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "Can't find pic: %s\n", pic);
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (scrap_dirty)
|
2010-10-20 08:49:28 +00:00
|
|
|
{
|
|
|
|
Scrap_Upload();
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Bind(gl->texnum);
|
2014-06-14 08:07:33 +00:00
|
|
|
|
|
|
|
GLfloat vtx[] = {
|
|
|
|
x, y,
|
|
|
|
x + gl->width * factor, y,
|
|
|
|
x + gl->width * factor, y + gl->height * factor,
|
|
|
|
x, y + gl->height * factor
|
|
|
|
};
|
|
|
|
|
|
|
|
GLfloat tex[] = {
|
|
|
|
gl->sl, gl->tl,
|
|
|
|
gl->sh, gl->tl,
|
|
|
|
gl->sh, gl->th,
|
|
|
|
gl->sl, gl->th
|
|
|
|
};
|
|
|
|
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, vtx );
|
|
|
|
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-04-29 13:57:33 +00:00
|
|
|
* This repeats a 64*64 tile graphic to fill
|
2010-10-20 08:49:28 +00:00
|
|
|
* the screen around a sized down
|
|
|
|
* refresh window.
|
|
|
|
*/
|
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_TileClear(int x, int y, int w, int h, char *pic)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-20 08:49:28 +00:00
|
|
|
image_t *image;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
image = Draw_FindPic(pic);
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!image)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "Can't find pic: %s\n", pic);
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Bind(image->texnum);
|
2014-06-14 08:07:33 +00:00
|
|
|
|
|
|
|
GLfloat vtx[] = {
|
|
|
|
x, y,
|
|
|
|
x + w, y,
|
|
|
|
x + w, y + h,
|
|
|
|
x, y + h
|
|
|
|
};
|
|
|
|
|
|
|
|
GLfloat tex[] = {
|
|
|
|
x / 64.0, y / 64.0,
|
|
|
|
( x + w ) / 64.0, y / 64.0,
|
|
|
|
( x + w ) / 64.0, ( y + h ) / 64.0,
|
|
|
|
x / 64.0, ( y + h ) / 64.0
|
|
|
|
};
|
|
|
|
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, vtx );
|
|
|
|
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
2010-10-20 08:49:28 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
/*
|
2010-10-20 08:49:28 +00:00
|
|
|
* Fills a box of pixels with a single color
|
|
|
|
*/
|
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_Fill(int x, int y, int w, int h, int c)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
2010-10-20 08:49:28 +00:00
|
|
|
unsigned c;
|
2012-07-21 12:09:45 +00:00
|
|
|
byte v[4];
|
2009-03-05 09:07:55 +00:00
|
|
|
} color;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if ((unsigned)c > 255)
|
2010-10-20 08:49:28 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Error(ERR_FATAL, "Draw_Fill: bad color");
|
2010-10-20 08:49:28 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_TEXTURE_2D);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
color.c = d_8to24table[c];
|
2014-06-14 08:07:33 +00:00
|
|
|
glColor4f(color.v [ 0 ] / 255.0, color.v [ 1 ] / 255.0,
|
|
|
|
color.v [ 2 ] / 255.0, 1);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
GLfloat vtx[] = {
|
|
|
|
x, y,
|
|
|
|
x + w, y,
|
|
|
|
x + w, y + h,
|
|
|
|
x, y + h
|
|
|
|
};
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, vtx );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
|
|
|
glColor4f( 1, 1, 1, 1 );
|
2013-07-27 06:44:07 +00:00
|
|
|
glEnable(GL_TEXTURE_2D);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_FadeScreen(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
glColor4f(0, 0, 0, 0.8);
|
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
GLfloat vtx[] = {
|
|
|
|
0, 0,
|
|
|
|
vid.width, 0,
|
|
|
|
vid.width, vid.height,
|
|
|
|
0, vid.height
|
|
|
|
};
|
|
|
|
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, vtx );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
2013-07-27 06:44:07 +00:00
|
|
|
|
|
|
|
glColor4f(1, 1, 1, 1);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
glDisable(GL_BLEND);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 08:49:28 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
unsigned image32[256 * 256];
|
|
|
|
unsigned char image8[256 * 256];
|
2010-10-20 08:49:28 +00:00
|
|
|
int i, j, trows;
|
|
|
|
byte *source;
|
|
|
|
int frac, fracstep;
|
|
|
|
float hscale;
|
|
|
|
int row;
|
|
|
|
float t;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Bind(0);
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (rows <= 256)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
hscale = 1;
|
|
|
|
trows = rows;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-20 08:49:28 +00:00
|
|
|
hscale = rows / 256.0;
|
2009-03-05 09:07:55 +00:00
|
|
|
trows = 256;
|
|
|
|
}
|
2010-10-20 08:49:28 +00:00
|
|
|
|
|
|
|
t = rows * hscale / 256 - 1.0 / 512.0;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!qglColorTableEXT)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
unsigned *dest;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < trows; i++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
row = (int)(i * hscale);
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (row > rows)
|
2010-10-20 08:49:28 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
break;
|
2010-10-20 08:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source = data + cols * row;
|
2012-07-21 12:09:45 +00:00
|
|
|
dest = &image32[i * 256];
|
2010-10-20 08:49:28 +00:00
|
|
|
fracstep = cols * 0x10000 / 256;
|
2009-03-05 09:07:55 +00:00
|
|
|
frac = fracstep >> 1;
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (j = 0; j < 256; j++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
dest[j] = r_rawpalette[source[frac >> 16]];
|
2009-03-05 09:07:55 +00:00
|
|
|
frac += fracstep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, gl_tex_solid_format,
|
2012-07-21 12:09:45 +00:00
|
|
|
256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
|
|
|
image32);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned char *dest;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < trows; i++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
row = (int)(i * hscale);
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (row > rows)
|
2010-10-20 08:49:28 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
break;
|
2010-10-20 08:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source = data + cols * row;
|
2012-07-21 12:09:45 +00:00
|
|
|
dest = &image8[i * 256];
|
2010-10-20 08:49:28 +00:00
|
|
|
fracstep = cols * 0x10000 / 256;
|
2009-03-05 09:07:55 +00:00
|
|
|
frac = fracstep >> 1;
|
2010-10-20 08:49:28 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (j = 0; j < 256; j++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
dest[j] = source[frac >> 16];
|
2009-03-05 09:07:55 +00:00
|
|
|
frac += fracstep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256,
|
|
|
|
0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, image8);
|
2010-10-20 08:49:28 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
GLfloat vtx[] = {
|
|
|
|
x, y,
|
|
|
|
x + w, y,
|
|
|
|
x + w, y + h,
|
|
|
|
x, y + h
|
|
|
|
};
|
|
|
|
|
|
|
|
GLfloat tex[] = {
|
|
|
|
1.0 / 512.0, 1.0 / 512.0,
|
|
|
|
511.0 / 512.0, 1.0 / 512.0,
|
|
|
|
511.0 / 512.0, t,
|
|
|
|
1.0 / 512.0, t
|
|
|
|
};
|
|
|
|
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, vtx );
|
|
|
|
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 09:12:38 +00:00
|
|
|
int
|
2012-07-21 12:09:45 +00:00
|
|
|
Draw_GetPalette(void)
|
2010-10-22 09:12:38 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int r, g, b;
|
|
|
|
unsigned v;
|
2012-07-21 12:09:45 +00:00
|
|
|
byte *pic, *pal;
|
2010-10-22 09:12:38 +00:00
|
|
|
int width, height;
|
|
|
|
|
|
|
|
/* get the palette */
|
2012-07-21 12:09:45 +00:00
|
|
|
LoadPCX("pics/colormap.pcx", &pic, &pal, &width, &height);
|
2010-10-22 09:12:38 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!pal)
|
2010-10-22 09:12:38 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Error(ERR_FATAL, "Couldn't load pics/colormap.pcx");
|
2010-10-22 09:12:38 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < 256; i++)
|
2010-10-22 09:12:38 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
r = pal[i * 3 + 0];
|
|
|
|
g = pal[i * 3 + 1];
|
|
|
|
b = pal[i * 3 + 2];
|
2010-10-22 09:12:38 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
v = (255 << 24) + (r << 0) + (g << 8) + (b << 16);
|
|
|
|
d_8to24table[i] = LittleLong(v);
|
2010-10-22 09:12:38 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
d_8to24table[255] &= LittleLong(0xffffff); /* 255 is transparent */
|
2010-10-22 09:12:38 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
free(pic);
|
|
|
|
free(pal);
|
2010-10-22 09:12:38 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
return 0;
|
2010-10-22 09:12:38 +00:00
|
|
|
}
|
2012-07-21 12:09:45 +00:00
|
|
|
|