mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-07 00:11:39 +00:00
clean up the draw interface a bit
This commit is contained in:
parent
eeca330af2
commit
7bca4cf8af
7 changed files with 45 additions and 278 deletions
|
@ -32,34 +32,25 @@
|
||||||
#include "QF/wad.h"
|
#include "QF/wad.h"
|
||||||
|
|
||||||
extern byte *draw_chars;
|
extern byte *draw_chars;
|
||||||
extern qpic_t *draw_disc; // also used on sbar
|
|
||||||
|
|
||||||
void Draw_Init (void);
|
void Draw_Init (void);
|
||||||
void Draw_InitText (void);
|
void Draw_InitText (void);
|
||||||
void Draw_Init_Cvars (void);
|
|
||||||
void Draw_Character (int x, int y, unsigned int num);
|
void Draw_Character (int x, int y, unsigned int num);
|
||||||
void Draw_Pic (int x, int y, qpic_t *pic);
|
|
||||||
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
|
|
||||||
void Draw_TextBox (int x, int y, int width, int lines, byte alpha);
|
|
||||||
void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation);
|
|
||||||
void Draw_ConsoleBackground (int lines, byte alpha);
|
void Draw_ConsoleBackground (int lines, byte alpha);
|
||||||
void Draw_Crosshair (void);
|
void Draw_Crosshair (void);
|
||||||
void Draw_CrosshairAt (int ch, int x, int y);
|
void Draw_CrosshairAt (int ch, int x, int y);
|
||||||
void Draw_BeginDisc (void);
|
|
||||||
void Draw_EndDisc (void);
|
|
||||||
void Draw_TileClear (int x, int y, int w, int h);
|
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_Fill (int x, int y, int w, int h, int c);
|
||||||
void Draw_FadeScreen (void);
|
void Draw_FadeScreen (void);
|
||||||
void Draw_String (int x, int y, const char *str);
|
void Draw_String (int x, int y, const char *str);
|
||||||
void Draw_nString (int x, int y, const char *str, int count);
|
void Draw_nString (int x, int y, const char *str, int count);
|
||||||
void Draw_AltString (int x, int y, const char *str);
|
void Draw_AltString (int x, int y, const char *str);
|
||||||
qpic_t *Draw_PicFromWad (const char *name);
|
|
||||||
qpic_t *Draw_CachePic (const char *path, qboolean alpha);
|
|
||||||
|
|
||||||
void Draw_ClearCache (void);
|
void Draw_ClearCache (void);
|
||||||
|
qpic_t *Draw_PicFromWad (const char *name);
|
||||||
void GL_Set2D (void);
|
qpic_t *Draw_CachePic (const char *path, qboolean alpha);
|
||||||
void GL_DrawReset (void);
|
void Draw_Pic (int x, int y, qpic_t *pic);
|
||||||
void GL_FlushText (void);
|
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
|
||||||
|
void Draw_TextBox (int x, int y, int width, int lines, byte alpha);
|
||||||
|
|
||||||
#endif // _DRAW_H
|
#endif // _DRAW_H
|
||||||
|
|
36
include/gl_draw.h
Normal file
36
include/gl_draw.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
gl_draw.h
|
||||||
|
|
||||||
|
gl specific draw function
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
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:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id: draw.h 10910 2004-05-07 03:54:35Z taniwha $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __gl_draw_h
|
||||||
|
#define __gl_draw_h
|
||||||
|
|
||||||
|
void GL_Set2D (void);
|
||||||
|
void GL_DrawReset (void);
|
||||||
|
void GL_FlushText (void);
|
||||||
|
|
||||||
|
#endif//__gl_draw_h
|
|
@ -62,6 +62,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
#include "QF/GL/types.h"
|
#include "QF/GL/types.h"
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "gl_draw.h"
|
||||||
#include "r_cvar.h"
|
#include "r_cvar.h"
|
||||||
#include "r_shared.h"
|
#include "r_shared.h"
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
|
@ -660,54 +661,6 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
||||||
qfglColor3ubv (color_white);
|
qfglColor3ubv (color_white);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Draw_TransPicTranslate
|
|
||||||
|
|
||||||
Only used for the player color selection menu
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation)
|
|
||||||
{
|
|
||||||
byte *src;
|
|
||||||
int c, p, u, v;
|
|
||||||
unsigned int trans[64 * 64], *dest;
|
|
||||||
|
|
||||||
qfglBindTexture (GL_TEXTURE_2D, translate_texture);
|
|
||||||
|
|
||||||
c = pic->width * pic->height;
|
|
||||||
|
|
||||||
dest = trans;
|
|
||||||
for (v = 0; v < 64; v++, dest += 64) {
|
|
||||||
src = &menuplyr_pixels[((v * pic->height) >> 6) * pic->width];
|
|
||||||
for (u = 0; u < 64; u++) {
|
|
||||||
p = src[(u * pic->width) >> 6];
|
|
||||||
if (p == 255)
|
|
||||||
dest[u] = p;
|
|
||||||
else
|
|
||||||
dest[u] = d_8to24table[translation[p]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qfglTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 64, 64, 0, GL_RGBA,
|
|
||||||
GL_UNSIGNED_BYTE, trans);
|
|
||||||
|
|
||||||
qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
|
|
||||||
qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
|
|
||||||
|
|
||||||
qfglColor3ubv (color_0_8);
|
|
||||||
qfglBegin (GL_QUADS);
|
|
||||||
qfglTexCoord2f (0, 0);
|
|
||||||
qfglVertex2f (x, y);
|
|
||||||
qfglTexCoord2f (1, 0);
|
|
||||||
qfglVertex2f (x + pic->width, y);
|
|
||||||
qfglTexCoord2f (1, 1);
|
|
||||||
qfglVertex2f (x + pic->width, y + pic->height);
|
|
||||||
qfglTexCoord2f (0, 1);
|
|
||||||
qfglVertex2f (x, y + pic->height);
|
|
||||||
qfglEnd ();
|
|
||||||
qfglColor3ubv (color_white);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Draw_ConsoleBackground
|
Draw_ConsoleBackground
|
||||||
|
|
||||||
|
@ -850,28 +803,6 @@ Draw_FadeScreen (void)
|
||||||
Sbar_Changed ();
|
Sbar_Changed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Draw_BeginDisc
|
|
||||||
|
|
||||||
Draws the little blue disc in the corner of the screen.
|
|
||||||
Call before beginning any disc IO.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Draw_BeginDisc (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Draw_EndDisc
|
|
||||||
|
|
||||||
Erases the disc icon.
|
|
||||||
Call after completing any disc IO
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Draw_EndDisc (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GL_Set2D
|
GL_Set2D
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
#include "QF/GL/qf_vid.h"
|
#include "QF/GL/qf_vid.h"
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "gl_draw.h"
|
||||||
#include "r_cvar.h"
|
#include "r_cvar.h"
|
||||||
#include "r_dynamic.h"
|
#include "r_dynamic.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
|
|
|
@ -57,6 +57,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
#include "QF/GL/qf_vid.h"
|
#include "QF/GL/qf_vid.h"
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "gl_draw.h"
|
||||||
#include "r_cvar.h"
|
#include "r_cvar.h"
|
||||||
#include "r_dynamic.h"
|
#include "r_dynamic.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
|
|
|
@ -464,57 +464,6 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation)
|
|
||||||
{
|
|
||||||
byte *dest, *source, tbyte;
|
|
||||||
int v, u;
|
|
||||||
|
|
||||||
if (x < 0 || (unsigned int) (x + pic->width) > vid.width || y < 0 ||
|
|
||||||
(unsigned int) (y + pic->height) > vid.height) {
|
|
||||||
Sys_Error ("Draw_TransPic: bad coordinates");
|
|
||||||
}
|
|
||||||
|
|
||||||
source = pic->data;
|
|
||||||
|
|
||||||
dest = vid.buffer + y * vid.rowbytes + x;
|
|
||||||
|
|
||||||
if (pic->width & 7) { // general
|
|
||||||
for (v = 0; v < pic->height; v++) {
|
|
||||||
for (u = 0; u < pic->width; u++)
|
|
||||||
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u] = translation[tbyte];
|
|
||||||
|
|
||||||
dest += vid.rowbytes;
|
|
||||||
source += pic->width;
|
|
||||||
}
|
|
||||||
} else { // unwound
|
|
||||||
for (v = 0; v < pic->height; v++) {
|
|
||||||
for (u = 0; u < pic->width; u += 8) {
|
|
||||||
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 1]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 1] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 2]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 2] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 3]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 3] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 4]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 4] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 5]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 5] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 6]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 6] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 7]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 7] = translation[tbyte];
|
|
||||||
}
|
|
||||||
dest += vid.rowbytes;
|
|
||||||
source += pic->width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Draw_ConsoleBackground (int lines, byte alpha)
|
Draw_ConsoleBackground (int lines, byte alpha)
|
||||||
{
|
{
|
||||||
|
@ -703,29 +652,3 @@ Draw_FadeScreen (void)
|
||||||
S_ExtraUpdate ();
|
S_ExtraUpdate ();
|
||||||
VID_LockBuffer ();
|
VID_LockBuffer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Draw_BeginDisc
|
|
||||||
|
|
||||||
Draws the little blue disc in the corner of the screen.
|
|
||||||
Call before beginning any disc IO.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Draw_BeginDisc (void)
|
|
||||||
{
|
|
||||||
D_BeginDirectRect (vid.width - 24, 0, draw_disc->data, 24, 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Draw_EndDisc
|
|
||||||
|
|
||||||
Erases the disc icon.
|
|
||||||
Call after completing any disc IO
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Draw_EndDisc (void)
|
|
||||||
{
|
|
||||||
D_EndDirectRect (vid.width - 24, 0, 24, 24);
|
|
||||||
}
|
|
||||||
|
|
|
@ -581,96 +581,6 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation)
|
|
||||||
{
|
|
||||||
byte *source, tbyte;
|
|
||||||
int v, u;
|
|
||||||
|
|
||||||
if (x < 0 || (unsigned int) (x + pic->width) > vid.width || y < 0 ||
|
|
||||||
(unsigned int) (y + pic->height) > vid.height) {
|
|
||||||
Sys_Error ("Draw_TransPic: bad coordinates");
|
|
||||||
}
|
|
||||||
|
|
||||||
source = pic->data;
|
|
||||||
|
|
||||||
switch(r_pixbytes) {
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
byte *dest = (byte *) vid.buffer + y * vid.rowbytes + x;
|
|
||||||
|
|
||||||
if (pic->width & 7) { // general
|
|
||||||
for (v = 0; v < pic->height; v++) {
|
|
||||||
for (u = 0; u < pic->width; u++)
|
|
||||||
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u] = translation[tbyte];
|
|
||||||
|
|
||||||
dest += vid.rowbytes;
|
|
||||||
source += pic->width;
|
|
||||||
}
|
|
||||||
} else { // unwound
|
|
||||||
for (v = 0; v < pic->height; v++) {
|
|
||||||
for (u = 0; u < pic->width; u += 8) {
|
|
||||||
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 1]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 1] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 2]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 2] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 3]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 3] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 4]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 4] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 5]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 5] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 6]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 6] = translation[tbyte];
|
|
||||||
if ((tbyte = source[u + 7]) != TRANSPARENT_COLOR)
|
|
||||||
dest[u + 7] = translation[tbyte];
|
|
||||||
}
|
|
||||||
dest += vid.rowbytes;
|
|
||||||
source += pic->width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
unsigned short *dest = (unsigned short *) vid.buffer + y *
|
|
||||||
(vid.rowbytes >> 1) + x;
|
|
||||||
for (v = 0; v < pic->height; v++) {
|
|
||||||
for (u = 0; u < pic->width; u++) {
|
|
||||||
tbyte = source[u];
|
|
||||||
if (tbyte != TRANSPARENT_COLOR)
|
|
||||||
dest[u] = d_8to16table[translation[tbyte]];
|
|
||||||
}
|
|
||||||
dest += vid.rowbytes >> 1;
|
|
||||||
source += pic->width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
{
|
|
||||||
unsigned int *dest = (unsigned int *) vid.buffer + y *
|
|
||||||
(vid.rowbytes >> 2) + x;
|
|
||||||
for (v = 0; v < pic->height; v++) {
|
|
||||||
for (u = 0; u < pic->width; u++) {
|
|
||||||
tbyte = source[u];
|
|
||||||
if (tbyte != TRANSPARENT_COLOR)
|
|
||||||
dest[u] = d_8to24table[translation[tbyte]];
|
|
||||||
}
|
|
||||||
dest += vid.rowbytes >> 1;
|
|
||||||
source += pic->width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Sys_Error("Draw_TransPicTranslate: unsupported r_pixbytes %i",
|
|
||||||
r_pixbytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Draw_ConsoleBackground (int lines, byte alpha)
|
Draw_ConsoleBackground (int lines, byte alpha)
|
||||||
{
|
{
|
||||||
|
@ -752,7 +662,7 @@ Draw_ConsoleBackground (int lines, byte alpha)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Sys_Error("Draw_TransPicTranslate: unsupported r_pixbytes %i",
|
Sys_Error("Draw_ConsoleBackground: unsupported r_pixbytes %i",
|
||||||
r_pixbytes);
|
r_pixbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1209,29 +1119,3 @@ Draw_FadeScreen (void)
|
||||||
S_ExtraUpdate ();
|
S_ExtraUpdate ();
|
||||||
VID_LockBuffer ();
|
VID_LockBuffer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Draw_BeginDisc
|
|
||||||
|
|
||||||
Draws the little blue disc in the corner of the screen.
|
|
||||||
Call before beginning any disc IO.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Draw_BeginDisc (void)
|
|
||||||
{
|
|
||||||
D_BeginDirectRect (vid.width - 24, 0, draw_disc->data, 24, 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Draw_EndDisc
|
|
||||||
|
|
||||||
Erases the disc icon.
|
|
||||||
Call after completing any disc IO
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Draw_EndDisc (void)
|
|
||||||
{
|
|
||||||
D_EndDirectRect (vid.width - 24, 0, 24, 24);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue