From 7bca4cf8af31eeaee230bbd575b0efa03ee6021d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 2 Dec 2006 10:07:08 +0000 Subject: [PATCH] clean up the draw interface a bit --- include/QF/draw.h | 19 ++--- include/gl_draw.h | 36 +++++++++ libs/video/renderer/gl/gl_draw.c | 71 +---------------- libs/video/renderer/gl/gl_rmain.c | 1 + libs/video/renderer/gl/gl_screen.c | 1 + libs/video/renderer/sw/draw.c | 77 ------------------- libs/video/renderer/sw32/draw.c | 118 +---------------------------- 7 files changed, 45 insertions(+), 278 deletions(-) create mode 100644 include/gl_draw.h diff --git a/include/QF/draw.h b/include/QF/draw.h index e05d52027..0e7a63978 100644 --- a/include/QF/draw.h +++ b/include/QF/draw.h @@ -32,34 +32,25 @@ #include "QF/wad.h" extern byte *draw_chars; -extern qpic_t *draw_disc; // also used on sbar void Draw_Init (void); void Draw_InitText (void); -void Draw_Init_Cvars (void); 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_Crosshair (void); 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_Fill (int x, int y, int w, int h, int c); void Draw_FadeScreen (void); void Draw_String (int x, int y, const char *str); void Draw_nString (int x, int y, const char *str, int count); 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 GL_Set2D (void); -void GL_DrawReset (void); -void GL_FlushText (void); +qpic_t *Draw_PicFromWad (const char *name); +qpic_t *Draw_CachePic (const char *path, qboolean alpha); +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); #endif // _DRAW_H diff --git a/include/gl_draw.h b/include/gl_draw.h new file mode 100644 index 000000000..2358130e6 --- /dev/null +++ b/include/gl_draw.h @@ -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 diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index 0f0f43ce9..029d00a5d 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -62,6 +62,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/GL/types.h" #include "compat.h" +#include "gl_draw.h" #include "r_cvar.h" #include "r_shared.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); } -/* - 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 @@ -850,28 +803,6 @@ Draw_FadeScreen (void) 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 diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index 6305c034f..1a577c5ad 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -62,6 +62,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/GL/qf_vid.h" #include "compat.h" +#include "gl_draw.h" #include "r_cvar.h" #include "r_dynamic.h" #include "r_local.h" diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index b8ee843ea..4aa5a580f 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -57,6 +57,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/GL/qf_vid.h" #include "compat.h" +#include "gl_draw.h" #include "r_cvar.h" #include "r_dynamic.h" #include "r_local.h" diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index 8fb224264..93d5e7610 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -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 Draw_ConsoleBackground (int lines, byte alpha) { @@ -703,29 +652,3 @@ Draw_FadeScreen (void) S_ExtraUpdate (); 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); -} diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index 3987b35cc..1f7f43681 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -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 Draw_ConsoleBackground (int lines, byte alpha) { @@ -752,7 +662,7 @@ Draw_ConsoleBackground (int lines, byte alpha) break; default: - Sys_Error("Draw_TransPicTranslate: unsupported r_pixbytes %i", + Sys_Error("Draw_ConsoleBackground: unsupported r_pixbytes %i", r_pixbytes); } @@ -1209,29 +1119,3 @@ Draw_FadeScreen (void) S_ExtraUpdate (); 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); -}