1 /* 2 draw.h 3 4 Video buffer handling definitions and prototypes 5 6 Copyright (C) 1996-1997 Id Software, Inc. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 17 See the GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to: 21 22 Free Software Foundation, Inc. 23 59 Temple Place - Suite 330 24 Boston, MA 02111-1307, USA 25 26 */ 27 28 #ifndef _DRAW_H 29 #define _DRAW_H 30 31 /** \defgroup video Video Sub-sytem */ 32 33 /** \defgroup video_renderer Renderer Sub-system 34 \ingroup video 35 */ 36 37 /** \defgroup video_renderer_draw Generic draw functions 38 \ingroup video_renderer 39 */ 40 //@{ 41 42 #include "QF/wad.h" 43 44 extern byte *draw_chars; 45 46 /** Initialize the draw stuff. 47 */ 48 void Draw_Init (void); 49 50 /** Draws one 8*8 graphics character with 0 being transparent. 51 It can be clipped to the top of the screen to allow the console to be 52 smoothly scrolled off. 53 \param x horizontal location of the top left corner of the character. 54 \param y vertical location of the top left corner of the character. 55 \param ch 8 bit character to draw. 56 \note The character drawn is from the quake character set, which is 57 (by default) standard ascii for 0x20-0x7e (white). 0xa0-0xfe is 58 also standard ascii (brown). 0x01-0x1f and 0x80-0x9f are 59 various drawing characters, and 0x7f is a backwards arrow. 60 */ 61 void Draw_Character (int x, int y, unsigned ch); 62 63 /** Draws a character string to the screen. 64 No line wrapping is performed. 65 \param x horizontal location of the top left corner of the character. 66 \param y vertical location of the top left corner of the character. 67 \param str 8 bit character string to draw. 68 \note See Draw_Character() for character set description. 69 String is normal nul terminated C string. 70 */ 71 void Draw_String (int x, int y, const char *str); 72 73 /** Draws a character sub-string to the screen. 74 No line wrapping is performed. 75 \param x horizontal location of the top left corner of the character. 76 \param y vertical location of the top left corner of the character. 77 \param str 8 bit character string to draw. 78 \param count Maximum characters of the string to draw. 79 \note See Draw_Character() for character set description. 80 Draws up to \p count characters, or stops at the first nul 81 character. 82 */ 83 void Draw_nString (int x, int y, const char *str, int count); 84 85 /** Draws a character string to the screen. 86 No line wrapping is performed. 87 \param x horizontal location of the top left corner of the character. 88 \param y vertical location of the top left corner of the character. 89 \param str 8 bit character string to draw. 90 \note See Draw_Character() for character set description. 91 String is normal nul terminated C string. 92 Characters of the string are forced to have their high bit set 93 (ie, they will be in the range 0x80-0xff). 94 */ 95 void Draw_AltString (int x, int y, const char *str); 96 97 /** Draw the console background with various optional effects. 98 \param lines Vertical size in pixels of the console. 99 \param alpha Console transparency level (255 = opaque). 100 \note \p alpha is effective only in the OpenGL renderer. Effectively 101 255 (opaque) for the software renderer. 102 103 \c gl_conspin causes the background to spin. 104 105 \c gl_constretch causes the background to stretch rather than slide. 106 */ 107 void Draw_ConsoleBackground (int lines, byte alpha); 108 109 /** Draw a crosshair at the center of the screen. 110 \c crosshair specifies which crosshair (1 = '+', 2 = large 'x' shape, 111 3 = fancy '+' shape) 112 \c cl_crossx and \c cl_crossy offset the crosshair from the center of the 113 screen. 114 */ 115 void Draw_Crosshair (void); 116 117 /** Draw the specified crosshair on the screen. 118 \param ch crosshair to draw 119 \param x horizontal position of the center of the crosshair. 120 \param y vertical position of the center of the crosshair. 121 122 See Draw_Crosshair() for description of crosshair values. 123 */ 124 void Draw_CrosshairAt (int ch, int x, int y); 125 126 /** Clear a rectangle with a tiled background. 127 \param x horizontal position of the upper left corner of the rectangle 128 \param y horizontal position of the upper left corner of the rectangle 129 \param w width of the rectangle 130 \param h height of the rectangle 131 132 The background used is the "backtile" WAD lump. 133 */ 134 void Draw_TileClear (int x, int y, int w, int h); 135 136 /** Clear a rectangle with a solid color. 137 \param x horizontal position of the upper left corner of the rectangle 138 \param y horizontal position of the upper left corner of the rectangle 139 \param w width of the rectangle 140 \param h height of the rectangle 141 \param c 8 bit color index. 142 143 The color comes from the quake palette. 144 */ 145 void Draw_Fill (int x, int y, int w, int h, int c); 146 147 /** Draw a text box on the screen 148 \param x horizontal location of the upper left corner of the box 149 \param y vertical location of the upper left corner of the box 150 \param width horizontal size in character cells of the region 151 \param lines vertical size in character cells of the region 152 \param alpha transparency of the box 153 */ 154 void Draw_TextBox (int x, int y, int width, int lines, byte alpha); 155 156 /** Darken the screen. 157 */ 158 void Draw_FadeScreen (void); 159 160 /** Shift the screen colors. 161 */ 162 void Draw_BlendScreen (quat_t color); 163 //@} 164 165 /** \defgroup video_renderer_draw_qpic QPic functions 166 \ingroup video_renderer_draw 167 */ 168 //@{ 169 /** Load a qpic from the filesystem. 170 \param path path of the file within the quake filesystem 171 \param alpha transparency level of the pic. 172 \return pointer qpic data. 173 \note Up to MAX_CACHED_PICS qpics can be loaded at a time this way 174 */ 175 qpic_t *Draw_CachePic (const char *path, qboolean alpha); 176 177 /** Remove a qpic from the qpic cache. 178 179 This affects only those qpics that were loaded via Draw_CachePic. 180 181 \param path path of the file within the quake filesystem 182 */ 183 void Draw_UncachePic (const char *path); 184 185 /** Create a qpic from raw data. 186 187 \param width The width of the pic. 188 \param height The height of the pic. 189 \param data The raw data bytes. The system palette will be used for 190 colors. 191 \return pointer qpic data. 192 */ 193 qpic_t *Draw_MakePic (int width, int height, const byte *data); 194 195 /** Destroy a qpic created by Draw_MakePic. 196 197 \param pic The qpic to destory. 198 */ 199 void Draw_DestroyPic (qpic_t *pic); 200 201 /** Load a qpic from gfx.wad. 202 \param name name of the was lump to load 203 \return pointer qpic data. 204 */ 205 qpic_t *Draw_PicFromWad (const char *name); 206 207 /** Draw a qpic to the screen 208 \param x horizontal location of the upper left corner of the qpic 209 \param y vertical location of the upper left corner of the qpic 210 \param pic qpic to draw 211 */ 212 void Draw_Pic (int x, int y, qpic_t *pic); 213 214 /** Draw a qpic to the screen 215 \param x horizontal location of the upper left corner of the qpic 216 \param y vertical location of the upper left corner of the qpic 217 \param pic qpic to draw 218 */ 219 void Draw_Picf (float x, float y, qpic_t *pic); 220 221 /** Draw a sub-region of a qpic to the screan 222 \param x horizontal screen location of the upper left corner of the 223 sub-region 224 \param y vertical screen location of the upper left corner of the 225 sub-region 226 \param pic qpic to draw 227 \param srcx horizontal qpic location of the upper left corner of the 228 sub-region 229 \param srcy vertical qpic location of the upper left corner of the 230 sub-region 231 \param width horizontal size of the sub-region to be drawn 232 \param height vertical size of the sub-region to be drawn 233 */ 234 void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height); 235 //@} 236 237 #endif // _DRAW_H 238