half-alpha character rendering for software

changed background to not blink
added BX_COLOREDTEXT extension (although the FTE extension conflicts)
fix to console clearing which should hopefully speed things up a little bit


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1886 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-01-21 03:10:16 +00:00
parent 4807ec631b
commit 8f550d6d1f
7 changed files with 206 additions and 184 deletions

View file

@ -23,22 +23,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// This is the standard RGBI palette used in CGA text mode // This is the standard RGBI palette used in CGA text mode
consolecolours_t consolecolours[MAXCONCOLOURS] = { consolecolours_t consolecolours[MAXCONCOLOURS] = {
{ 0, 0, 0, 0, 0, 0 }, // black {0, 0, 0 }, // black
{ 0, 0, 170, 0, 0, 0.67}, // blue {0, 0, 0.67}, // blue
{ 0, 170, 0, 0, 0.67, 0 }, // green {0, 0.67, 0 }, // green
{ 0, 170, 170, 0, 0.67, 0.67}, // cyan {0, 0.67, 0.67}, // cyan
{170, 0, 0, 0.67, 0, 0 }, // red {0.67, 0, 0 }, // red
{170, 0, 170, 0.67, 0, 0.67}, // magenta {0.67, 0, 0.67}, // magenta
{170, 85, 0, 0.67, 0.33, 0 }, // brown {0.67, 0.33, 0 }, // brown
{170, 170, 170, 0.67, 0.67, 0.67}, // light gray {0.67, 0.67, 0.67}, // light gray
{ 85, 85, 85, 0.33, 0.33, 0.33}, // dark gray {0.33, 0.33, 0.33}, // dark gray
{ 85, 85, 255, 0.33, 0.33, 1 }, // light blue {0.33, 0.33, 1 }, // light blue
{ 85, 255, 85, 0.33, 1, 0.33}, // light green {0.33, 1, 0.33}, // light green
{ 85, 255, 255, 0.33, 1, 1 }, // light cyan {0.33, 1, 1 }, // light cyan
{255, 85, 85, 1, 0.33, 0.33}, // light red {1, 0.33, 0.33}, // light red
{255, 85, 255, 1, 0.33, 1 }, // light magenta {1, 0.33, 1 }, // light magenta
{255, 255, 85, 1, 1, 0.33}, // yellow {1, 1, 0.33}, // yellow
{255, 255, 255, 1, 1, 1 } // white {1, 1, 1 } // white
}; };
// This is for remapping the Q3 color codes to character masks, including ^9 // This is for remapping the Q3 color codes to character masks, including ^9
@ -405,7 +405,7 @@ void Con_Clear_f (void)
//wide chars, not standard ascii //wide chars, not standard ascii
for (i = 0; i < sizeof(con_main.text)/sizeof(conchar_t); i++) for (i = 0; i < sizeof(con_main.text)/sizeof(conchar_t); i++)
{ {
con_main.text[i] = ' '; con_main.text[i] = CON_DEFAULTCHAR;
// Q_memset (con_main.text, ' ', sizeof(con_main.text)); // Q_memset (con_main.text, ' ', sizeof(con_main.text));
} }
} }
@ -472,7 +472,7 @@ void Con_ResizeCon (console_t *con)
con->linewidth = width; con->linewidth = width;
con->totallines = CON_TEXTSIZE / con->linewidth; con->totallines = CON_TEXTSIZE / con->linewidth;
for (i = 0; i < CON_TEXTSIZE; i++) for (i = 0; i < CON_TEXTSIZE; i++)
con->text[i] = ' '; con->text[i] = CON_DEFAULTCHAR;
// Q_memset (con->text, ' ', sizeof(con->text)); // Q_memset (con->text, ' ', sizeof(con->text));
} }
else else
@ -493,7 +493,7 @@ void Con_ResizeCon (console_t *con)
Q_memcpy (tbuf, con->text, sizeof(con->text)); Q_memcpy (tbuf, con->text, sizeof(con->text));
for (i = 0; i < sizeof(con->text)/sizeof(conchar_t); i++) for (i = 0; i < sizeof(con->text)/sizeof(conchar_t); i++)
con->text[i] = ' '; con->text[i] = CON_DEFAULTCHAR;
// Q_memset (con->text, ' ', sizeof(con->text)); // Q_memset (con->text, ' ', sizeof(con->text));
for (i=0 ; i<numlines ; i++) for (i=0 ; i<numlines ; i++)
@ -584,7 +584,7 @@ void Con_Linefeed (console_t *con)
min = (con->current%con->totallines)*con->linewidth; min = (con->current%con->totallines)*con->linewidth;
max = min + con->linewidth; max = min + con->linewidth;
for (i = min; i < max; i++) for (i = min; i < max; i++)
con->text[i] = ' '; con->text[i] = CON_DEFAULTCHAR;
// Q_memset (&con->text[(con->current%con_totallines)*con_linewidth] // Q_memset (&con->text[(con->current%con_totallines)*con_linewidth]
// , ' ', con_linewidth*sizeof(unsigned short)); // , ' ', con_linewidth*sizeof(unsigned short));

View file

@ -25,7 +25,6 @@ typedef unsigned int conchar_t;
#define MAXCONCOLOURS 16 #define MAXCONCOLOURS 16
typedef struct { typedef struct {
int ir, ig, ib;
float fr, fg, fb; float fr, fg, fb;
} consolecolours_t; } consolecolours_t;
@ -51,6 +50,8 @@ extern conchar_t q3codemasks[MAXQ3COLOURS];
#define CON_Q3MASK 0x0F100000 #define CON_Q3MASK 0x0F100000
#define CON_WHITEMASK 0x0F000000 // must be constant. things assume this #define CON_WHITEMASK 0x0F000000 // must be constant. things assume this
#define CON_DEFAULTCHAR (CON_WHITEMASK | 32)
// RGBI standard colors // RGBI standard colors
#define COLOR_BLACK 0 #define COLOR_BLACK 0
#define COLOR_DARKBLUE 1 #define COLOR_DARKBLUE 1

View file

@ -1288,13 +1288,6 @@ void GLDraw_ColouredCharacter (int x, int y, unsigned int num)
{ {
unsigned int col; unsigned int col;
if (num & CON_BLINKTEXT)
{
if (!cl_noblink.value)
if ((int)(realtime*3) & 1)
return;
}
// draw background // draw background
if (num & CON_NONCLEARBG) if (num & CON_NONCLEARBG)
{ {
@ -1302,6 +1295,13 @@ void GLDraw_ColouredCharacter (int x, int y, unsigned int num)
GLDraw_FillRGB(x, y, 8, 8, consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb); GLDraw_FillRGB(x, y, 8, 8, consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb);
} }
if (num & CON_BLINKTEXT)
{
if (!cl_noblink.value)
if ((int)(realtime*3) & 1)
return;
}
// render character with foreground color // render character with foreground color
col = (num & CON_FGMASK) >> CON_FGSHIFT; col = (num & CON_FGMASK) >> CON_FGSHIFT;
qglColor4f(consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb, (num & CON_HALFALPHA)?0.5:1); qglColor4f(consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb, (num & CON_HALFALPHA)?0.5:1);

View file

@ -6244,6 +6244,7 @@ typedef struct lh_extension_s {
lh_extension_t QSG_Extensions[] = { lh_extension_t QSG_Extensions[] = {
{"BX_COLOREDTEXT"},
{"DP_CON_SET"}, {"DP_CON_SET"},
#ifndef SERVERONLY #ifndef SERVERONLY
{"DP_CON_SETA"}, //because the server doesn't write configs. {"DP_CON_SETA"}, //because the server doesn't write configs.

View file

@ -19,6 +19,9 @@ int swzpal[TRANS_LEVELS][256];
palremap_t *RebuildMenuTint(void); palremap_t *RebuildMenuTint(void);
palremap_t *mtpalremap; palremap_t *mtpalremap;
// IB remap
palremap_t *ib_remap;
extern cvar_t r_menutint; extern cvar_t r_menutint;
int mtmodified; int mtmodified;
@ -42,6 +45,7 @@ void D_ShutdownTrans(void)
mtpalremap = NULL; mtpalremap = NULL;
mtmodified = 0; mtmodified = 0;
ib_remap = NULL;
} }
void D_InitTrans(void) void D_InitTrans(void)
@ -54,6 +58,7 @@ void D_InitTrans(void)
srctable = swzpal[0]; srctable = swzpal[0];
dsttable = swzpal[TRANS_MAX]; dsttable = swzpal[TRANS_MAX];
mtpalremap = RebuildMenuTint(); mtpalremap = RebuildMenuTint();
ib_remap = D_IdentityRemap();
} }
// TODO: INLINE THESE FUNCTIONS // TODO: INLINE THESE FUNCTIONS
@ -86,7 +91,7 @@ void Set_TransLevelI(int level)
} }
*/ */
void D_SetTransLevel(float level, blendmode_t blend) //MUST be between 0 and 1 void D_SetTransLevel(float level, blendmode_t blend)
{ {
int ilvl; int ilvl;

View file

@ -64,6 +64,12 @@ int swmenu_numcachepics;
qbyte sw_crosshaircolor; qbyte sw_crosshaircolor;
// current rendering blend for sw
extern palremap_t *ib_remap;
int ib_index;
int ib_ri, ib_gi, ib_bi, ib_ai;
qboolean ib_colorblend, ib_alphablend;
/* /*
================ ================
Draw_CachePic Draw_CachePic
@ -670,15 +676,16 @@ void SWDraw_Character (int x, int y, unsigned int num)
#define draw(p) drawpal(host_basepal[p*3]>>3,host_basepal[p*3+1]>>3,host_basepal[p*3+2]>>3) #define draw(p) drawpal(host_basepal[p*3]>>3,host_basepal[p*3+1]>>3,host_basepal[p*3+2]>>3)
*/ */
#define draw(x) pr->pal[x] #define draw(x) ib_remap->pal[x]
#define tdraw(x, y) Trans(x, ib_remap->pal[y])
void SWDraw_ColouredCharacter (int x, int y, unsigned int num) void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
{ {
qbyte *source; qbyte *source;
int drawline; int drawline;
int row, col; int row, col;
extern cvar_t cl_noblink; extern cvar_t cl_noblink;
unsigned int colour, bgcolour; unsigned int colour;
qboolean drawbg = false; qboolean alpha;
if (y <= -8) if (y <= -8)
return; // totally off screen return; // totally off screen
@ -687,10 +694,18 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
return; return;
colour = (num & CON_FGMASK) >> CON_FGSHIFT; colour = (num & CON_FGMASK) >> CON_FGSHIFT;
bgcolour = (num & CON_BGMASK) >> CON_BGSHIFT; alpha = !!(num & CON_HALFALPHA);
if (num & CON_NONCLEARBG) if (num & CON_NONCLEARBG)
drawbg = true; {
unsigned int bgcolour;
bgcolour = (num & CON_BGMASK) >> CON_BGSHIFT;
SWDraw_FillRGB(x, (y < 0) ? 0 : y, 8, (y < 0) ? 8 + y : 8,
consolecolours[bgcolour].fr,
consolecolours[bgcolour].fg,
consolecolours[bgcolour].fb);
}
if (num & CON_BLINKTEXT) if (num & CON_BLINKTEXT)
{ {
@ -699,12 +714,17 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
return; return;
} }
if (colour == COLOR_WHITE && !drawbg) if (colour == COLOR_WHITE && !alpha)
{ {
Draw_Character(x, y, num); Draw_Character(x, y, num);
return; return;
} }
SWDraw_ImageColours(consolecolours[colour].fr,
consolecolours[colour].fg,
consolecolours[colour].fb,
alpha ? 0.5 : 1);
num &= 255; num &= 255;
row = num>>4; row = num>>4;
col = num&15; col = num&15;
@ -721,31 +741,29 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
if (r_pixbytes == 1) if (r_pixbytes == 1)
{ {
palremap_t *pr;
qbyte *dest; qbyte *dest;
dest = vid.conbuffer + y*vid.conrowbytes + x; dest = vid.conbuffer + y*vid.conrowbytes + x;
pr = D_GetPaletteRemap(consolecolours[colour].ir, if (alpha)
consolecolours[colour].ig,
consolecolours[colour].ib,
false, true, TOP_DEFAULT, BOTTOM_DEFAULT);
if (drawbg)
{ {
int bgidx = GetPalette(consolecolours[bgcolour].ir,
consolecolours[bgcolour].ig,
consolecolours[bgcolour].ib);
while (drawline--) while (drawline--)
{ {
dest[0] = source[0] ? draw(source[0]) : bgidx; if (source[0])
dest[1] = source[1] ? draw(source[1]) : bgidx; dest[0] = tdraw(dest[0], source[0]);
dest[2] = source[2] ? draw(source[2]) : bgidx; if (source[1])
dest[3] = source[3] ? draw(source[3]) : bgidx; dest[1] = tdraw(dest[1], source[1]);
dest[4] = source[4] ? draw(source[4]) : bgidx; if (source[2])
dest[5] = source[5] ? draw(source[5]) : bgidx; dest[2] = tdraw(dest[2], source[2]);
dest[6] = source[6] ? draw(source[6]) : bgidx; if (source[3])
dest[7] = source[7] ? draw(source[7]) : bgidx; dest[3] = tdraw(dest[3], source[3]);
if (source[4])
dest[4] = tdraw(dest[4], source[4]);
if (source[5])
dest[5] = tdraw(dest[5], source[5]);
if (source[6])
dest[6] = tdraw(dest[6], source[6]);
if (source[7])
dest[7] = tdraw(dest[7], source[7]);
source += 128; source += 128;
dest += vid.conrowbytes; dest += vid.conrowbytes;
} }
@ -774,38 +792,27 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
dest += vid.conrowbytes; dest += vid.conrowbytes;
} }
} }
D_DereferenceRemap(pr);
} }
else if (r_pixbytes == 2) else if (r_pixbytes == 2)
{ {
unsigned short *dest16; unsigned short *dest16;
unsigned char *pal = (unsigned char *)d_8to32table; unsigned char *pal = (unsigned char *)d_8to32table;
int i; int i;
int rm, gm, bm;
dest16 = (unsigned short *)vid.conbuffer + y*vid.conrowbytes + x; dest16 = (unsigned short *)vid.conbuffer + y*vid.conrowbytes + x;
rm = consolecolours[colour].ir>>3; if (alpha)
gm = consolecolours[colour].ig>>3;
bm = consolecolours[colour].ib>>3;
if (drawbg)
{ {
int bgidx16 = (consolecolours[bgcolour].ir>>3) |
(consolecolours[bgcolour].ig>>3)<<5 |
(consolecolours[bgcolour].ib>>3)<<10;
while (drawline--) while (drawline--)
{ {
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
if (source[i]) if (source[i])
dest16[i] = (((16+pal[source[i]*4+0]*bm)>>8)<<10)+ {
(((16+pal[source[i]*4+1]*gm)>>8)<<5)+ dest16[i] = ((((128+pal[source[i]*4+0]*ib_ri)>>12)<<10) + ((dest16[i]&0x7B00)>>1)) |
((16+pal[source[i]*4+2]*rm)>>8); ((((128+pal[source[i]*4+1]*ib_gi)>>12)<<5) + ((dest16[i]&0x03D0)>>1)) |
else ((128+pal[source[i]*4+2]*ib_bi)>>12) + ((dest16[i]&0x001E)>>1);
dest16[i] = bgidx16; }
} }
source += 128; source += 128;
dest16 += vid.conrowbytes; dest16 += vid.conrowbytes;
@ -818,9 +825,9 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
if (source[i]) if (source[i])
dest16[i] = (((16+pal[source[i]*4+0]*bm)>>8)<<10)+ dest16[i] = (((128+pal[source[i]*4+0]*ib_ri)>>11)<<10)|
(((16+pal[source[i]*4+1]*gm)>>8)<<5)+ (((128+pal[source[i]*4+1]*ib_gi)>>11)<<5)|
((16+pal[source[i]*4+2]*rm)>>8); ((128+pal[source[i]*4+2]*ib_bi)>>11);
} }
source += 128; source += 128;
dest16 += vid.conrowbytes; dest16 += vid.conrowbytes;
@ -834,7 +841,7 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
unsigned char *pal = (unsigned char *)d_8to32table; unsigned char *pal = (unsigned char *)d_8to32table;
dest = vid.conbuffer + (y*vid.conrowbytes + x)*r_pixbytes; dest = vid.conbuffer + (y*vid.conrowbytes + x)*r_pixbytes;
if (drawbg) if (alpha)
{ {
while (drawline--) while (drawline--)
{ {
@ -842,15 +849,9 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
{ {
if (source[i]) if (source[i])
{ {
dest[0+i*4] = (128+pal[source[i]*4+0]*consolecolours[colour].ib)>>8; dest[0+i*4] = ((128+pal[source[i]*4+0]*ib_bi)>>9) + (dest[0+i*4]>>1);
dest[1+i*4] = (128+pal[source[i]*4+1]*consolecolours[colour].ig)>>8; dest[1+i*4] = ((128+pal[source[i]*4+1]*ib_gi)>>9) + (dest[1+i*4]>>1);
dest[2+i*4] = (128+pal[source[i]*4+2]*consolecolours[colour].ir)>>8; dest[2+i*4] = ((128+pal[source[i]*4+2]*ib_ri)>>9) + (dest[2+i*4]>>1);
}
else
{
dest[0+i*4] = consolecolours[bgcolour].ib;
dest[1+i*4] = consolecolours[bgcolour].ig;
dest[2+i*4] = consolecolours[bgcolour].ir;
} }
} }
source += 128; source += 128;
@ -865,9 +866,9 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
{ {
if (source[i]) if (source[i])
{ {
dest[0+i*4] = (128+pal[source[i]*4+0]*consolecolours[colour].ib)>>8; dest[0+i*4] = (128+pal[source[i]*4+0]*ib_bi)>>8;
dest[1+i*4] = (128+pal[source[i]*4+1]*consolecolours[colour].ig)>>8; dest[1+i*4] = (128+pal[source[i]*4+1]*ib_gi)>>8;
dest[2+i*4] = (128+pal[source[i]*4+2]*consolecolours[colour].ir)>>8; dest[2+i*4] = (128+pal[source[i]*4+2]*ib_ri)>>8;
} }
} }
source += 128; source += 128;
@ -877,6 +878,7 @@ void SWDraw_ColouredCharacter (int x, int y, unsigned int num)
} }
} }
#undef draw #undef draw
#undef tdraw
/* /*
================ ================
@ -1822,16 +1824,46 @@ void SWDraw_SubImage8(
} }
} }
static qboolean SWDraw_Image_Blend;
static int SWDraw_Image_Red=1, SWDraw_Image_Green=1, SWDraw_Image_Blue=1, SWDraw_Image_Alpha=1;
void SWDraw_ImageColours (float r, float g, float b, float a) //like glcolour4f void SWDraw_ImageColours (float r, float g, float b, float a) //like glcolour4f
{ {
SWDraw_Image_Red=r*255; int ri, gi, bi, ai;
SWDraw_Image_Green=g*255;
SWDraw_Image_Blue=b*255;
SWDraw_Image_Alpha=a*255;
SWDraw_Image_Blend = r<1 || b<1 || g<1 || a<1; if (r_pixbytes == 1)
D_SetTransLevel(a, BM_BLEND); // 8bpp doesn't maintain blending correctly
ri = 255*r;
gi = 255*g;
bi = 255*b;
ai = 255*a;
if (ri == ib_ri && gi == ib_gi && bi == ib_bi && ai == ib_ai)
{
// nothing changed
return;
}
ib_colorblend = (ri == 255 && gi == 255 && bi == 255) ? false : true;
ib_alphablend = (ai == 255) ? false : true;
ib_ri = ri;
ib_gi = gi;
ib_bi = bi;
ib_ai = ai;
switch (r_pixbytes)
{
case 1:
D_DereferenceRemap(ib_remap);
ib_remap = D_GetPaletteRemap(ri, gi, bi, false, true, TOP_DEFAULT, BOTTOM_DEFAULT);
ib_index = GetPalette(ri, gi, bi);
return;
case 2:
ib_index = ((ri << 3) >> 10) | ((gi << 3) >> 5) | (bi << 3);
return;
case 4:
ib_index = (ri << 16) | (gi << 8) | bi;
return;
}
} }
void SWDraw_Image (float xp, float yp, float wp, float hp, float s1, float t1, float s2, float t2, mpic_t *pic) void SWDraw_Image (float xp, float yp, float wp, float hp, float s1, float t1, float s2, float t2, mpic_t *pic)
@ -1920,11 +1952,11 @@ void SWDraw_Image (float xp, float yp, float wp, float hp, float s1, float t1, f
} }
else else
{ {
if (SWDraw_Image_Blend) //blend it on if (ib_colorblend || ib_alphablend) //blend it on
{ {
SWDraw_SubImageBlend32(xp, yp, wp, hp, s1, t1, s2, t2, SWDraw_SubImageBlend32(xp, yp, wp, hp, s1, t1, s2, t2,
pic->width, pic->height, pic->data, pic->width, pic->height, pic->data,
SWDraw_Image_Red, SWDraw_Image_Green, SWDraw_Image_Blue, SWDraw_Image_Alpha); ib_ri, ib_gi, ib_bi, ib_ai);
} }
else //block colour (fast) else //block colour (fast)
@ -2397,10 +2429,41 @@ Draw_Fill
Fills a box of pixels with a single color Fills a box of pixels with a single color
============= =============
*/ */
void SWDraw_Fill (int x, int y, int w, int h, int c) void SWDraw_Fill32 (int x, int y, int w, int h, unsigned int c)
{
int u, v;
unsigned int *p32dest;
p32dest = (unsigned int*)vid.buffer + y*vid.rowbytes + x;
for (v=0 ; v<h ; v++, p32dest += vid.rowbytes)
for (u=0 ; u<w ; u++)
p32dest[u] = c;
}
void SWDraw_Fill16 (int x, int y, int w, int h, unsigned short c)
{
int u, v;
unsigned short *p16dest;
p16dest = (unsigned short*)vid.buffer + y*vid.rowbytes + x;
for (v=0 ; v<h ; v++, p16dest += vid.rowbytes)
for (u=0 ; u<w ; u++)
p16dest[u] = c;
}
void SWDraw_Fill8 (int x, int y, int w, int h, unsigned char c)
{ {
int u, v; int u, v;
qbyte *dest;
dest = vid.buffer + y*vid.rowbytes + x;
for (v=0 ; v<h ; v++, dest += vid.rowbytes)
for (u=0 ; u<w ; u++)
dest[u] = c;
}
void SWDraw_Fill (int x, int y, int w, int h, int c)
{
if (x < 0 || x + w > vid.width || if (x < 0 || x + w > vid.width ||
y < 0 || y + h > vid.height) { y < 0 || y + h > vid.height) {
Con_Printf("Bad Draw_Fill(%d, %d, %d, %d, %c)\n", Con_Printf("Bad Draw_Fill(%d, %d, %d, %d, %c)\n",
@ -2408,31 +2471,47 @@ void SWDraw_Fill (int x, int y, int w, int h, int c)
return; return;
} }
if (r_pixbytes == 1) switch (r_pixbytes)
{ {
qbyte *dest; case 1:
dest = vid.buffer + y*vid.rowbytes + x; SWDraw_Fill8(x, y, w, h, (unsigned char)c);
for (v=0 ; v<h ; v++, dest += vid.rowbytes) break;
for (u=0 ; u<w ; u++) case 2:
dest[u] = c; SWDraw_Fill16(x, y, w, h, d_8to16table[c]);
break;
case 4:
SWDraw_Fill32(x, y, w, h, d_8to32table[c]);
break;
} }
else if (r_pixbytes == 4)
{
unsigned int *p32dest;
p32dest = (unsigned int*)vid.buffer + y*vid.rowbytes + x;
for (v=0 ; v<h ; v++, p32dest += vid.rowbytes)
for (u=0 ; u<w ; u++)
p32dest[u] = d_8to32table[c];
} }
else if (r_pixbytes == 2)
{
unsigned short *p16dest;
p16dest = (unsigned short*)vid.buffer + y*vid.rowbytes + x; void SWDraw_FillRGB (int x, int y, int w, int h, float r, float g, float b)
for (v=0 ; v<h ; v++, p16dest += vid.rowbytes) {
for (u=0 ; u<w ; u++) unsigned int c;
p16dest[u] = d_8to16table[c];
if (x < 0 || x + w > vid.width ||
y < 0 || y + h > vid.height) {
Con_Printf("Bad Draw_FillRGB(%d, %d, %d, %d)\n",
x, y, w, h);
return;
}
switch (r_pixbytes)
{
case 1:
c = GetPalette(r*255, g*255, b*255);
SWDraw_Fill8(x, y, w, h, (unsigned char)c);
break;
case 2:
c = ((int)(r*31) << 10) | ((int)(g*31) << 5) | (int)(b*31);
SWDraw_Fill16(x, y, w, h, (unsigned short)c);
break;
case 4:
c = ((int)(r*255)<<16) | ((int)(g*255)<<8) | (int)(b*255);
SWDraw_Fill32(x, y, w, h, c);
break;
} }
} }
//============================================================================= //=============================================================================
@ -2506,71 +2585,6 @@ void SWDraw_FadeScreen (void)
VID_LockBuffer (); VID_LockBuffer ();
} }
#if 0
void SWDraw_Box(int x1, int y1, int x2, int y2, int paletteindex, float alpha)
{
int x;
int y;
int w;
int h;
qbyte *dest;
unsigned int *puidest;
unsigned uc;
int u, v;
D_SetTransLevel(alpha, BM_MERGE);
if (alpha < TRANS_LOWER_CAP)
return;
if (x1 < x2)
{
x = x1;
w = x2-x1;
}
else
{
x = x2;
w = x1-x2;
}
if (y1 < y2)
{
y = y1;
h = y2-y1;
}
else
{
y = y2;
h = y1-y2;
}
if (x < 0 || x + w > vid.width ||
y < 0 || y + h > vid.height) {
Con_Printf("Bad SWDraw_Box(%d, %d, %d, %d, %i)\n",
x, y, w, h, paletteindex);
return;
}
if (r_pixbytes == 1)
{
dest = vid.buffer + y*vid.rowbytes + x;
for (v=0 ; v<h ; v++, dest += vid.rowbytes)
for (u=0 ; u<w ; u++)
dest[u] = Trans(dest[u], paletteindex);
}
else if (r_pixbytes == 4)
{
uc = d_8to32table[paletteindex];
puidest = (unsigned int *)vid.buffer + y * (vid.rowbytes) + x;
for (v=0 ; v<h ; v++, puidest += vid.rowbytes)
for (u=0 ; u<w ; u++)
puidest[u] = uc;
}
}
#endif
//============================================================================= //=============================================================================

View file

@ -39,6 +39,7 @@ void SWDraw_BeginDisc (void);
void SWDraw_EndDisc (void); void SWDraw_EndDisc (void);
void SWDraw_TileClear (int x, int y, int w, int h); void SWDraw_TileClear (int x, int y, int w, int h);
void SWDraw_Fill (int x, int y, int w, int h, int c); void SWDraw_Fill (int x, int y, int w, int h, int c);
void SWDraw_FillRGB (int x, int y, int w, int h, float r, float g, float b);
void SWDraw_FadeScreen (void); void SWDraw_FadeScreen (void);
void SWDraw_String (int x, int y, const qbyte *str); void SWDraw_String (int x, int y, const qbyte *str);
void SWDraw_Alt_String (int x, int y, const qbyte *str); void SWDraw_Alt_String (int x, int y, const qbyte *str);