2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
draw.h
|
|
|
|
|
|
|
|
Video buffer handling definitions and prototypes
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2020-02-24 03:21:20 +00:00
|
|
|
#ifndef __QF_draw_h
|
|
|
|
#define __QF_draw_h
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-07-26 02:34:17 +00:00
|
|
|
/** \defgroup video Video Sub-sytem */
|
2006-12-03 06:25:57 +00:00
|
|
|
|
2006-12-05 11:40:00 +00:00
|
|
|
/** \defgroup video_renderer Renderer Sub-system
|
|
|
|
\ingroup video
|
|
|
|
*/
|
2006-12-03 06:25:57 +00:00
|
|
|
|
2006-12-05 11:40:00 +00:00
|
|
|
/** \defgroup video_renderer_draw Generic draw functions
|
|
|
|
\ingroup video_renderer
|
|
|
|
*/
|
2020-02-11 06:20:49 +00:00
|
|
|
///@{
|
2006-12-03 06:25:57 +00:00
|
|
|
|
2001-04-15 08:04:15 +00:00
|
|
|
#include "QF/wad.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-09-15 05:24:33 +00:00
|
|
|
/** Buffer for drawing text using quake conchars or the default 8x8 font.
|
|
|
|
|
|
|
|
Characters are stored with the first character in the upper left, scanning
|
|
|
|
horizontally to the right.
|
|
|
|
*/
|
|
|
|
typedef struct draw_charbuffer_s {
|
|
|
|
int width; ///< width in character cells
|
|
|
|
int height; ///< height in character cells
|
|
|
|
char *chars; ///< width * height characters
|
2022-09-15 15:58:25 +00:00
|
|
|
int cursx; ///< horizontal cursor position
|
|
|
|
int cursy; ///< vertical cursor position
|
2022-09-15 05:24:33 +00:00
|
|
|
} draw_charbuffer_t;
|
|
|
|
|
|
|
|
draw_charbuffer_t *Draw_CreateBuffer (int width, int height);
|
|
|
|
void Draw_DestroyBuffer (draw_charbuffer_t *buffer);
|
|
|
|
void Draw_ClearBuffer (draw_charbuffer_t *buffer);
|
|
|
|
void Draw_ScrollBuffer (draw_charbuffer_t *buffer, int lines);
|
|
|
|
void Draw_CharBuffer (int x, int y, draw_charbuffer_t *buffer);
|
2022-09-20 01:27:24 +00:00
|
|
|
int Draw_PrintBuffer (draw_charbuffer_t *buffer, const char *str);
|
2022-09-15 05:24:33 +00:00
|
|
|
|
2022-11-13 13:23:56 +00:00
|
|
|
void Draw_SetScale (int scale);
|
|
|
|
int Draw_MaxScale (void) __attribute__((pure));
|
|
|
|
|
2002-06-13 05:24:52 +00:00
|
|
|
extern byte *draw_chars;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2006-12-03 06:25:57 +00:00
|
|
|
/** Initialize the draw stuff.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
void Draw_Init (void);
|
2006-12-03 06:25:57 +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.
|
|
|
|
\param x horizontal location of the top left corner of the character.
|
|
|
|
\param y vertical location of the top left corner of the character.
|
2006-12-05 11:40:00 +00:00
|
|
|
\param ch 8 bit character to draw.
|
2006-12-03 06:25:57 +00:00
|
|
|
\note The character drawn is from the quake character set, which is
|
|
|
|
(by default) standard ascii for 0x20-0x7e (white). 0xa0-0xfe is
|
|
|
|
also standard ascii (brown). 0x01-0x1f and 0x80-0x9f are
|
|
|
|
various drawing characters, and 0x7f is a backwards arrow.
|
|
|
|
*/
|
2012-02-14 08:28:09 +00:00
|
|
|
void Draw_Character (int x, int y, unsigned ch);
|
2006-12-03 06:25:57 +00:00
|
|
|
|
|
|
|
/** Draws a character string to the screen.
|
|
|
|
No line wrapping is performed.
|
|
|
|
\param x horizontal location of the top left corner of the character.
|
|
|
|
\param y vertical location of the top left corner of the character.
|
|
|
|
\param str 8 bit character string to draw.
|
|
|
|
\note See Draw_Character() for character set description.
|
|
|
|
String is normal nul terminated C string.
|
|
|
|
*/
|
|
|
|
void Draw_String (int x, int y, const char *str);
|
|
|
|
|
|
|
|
/** Draws a character sub-string to the screen.
|
|
|
|
No line wrapping is performed.
|
|
|
|
\param x horizontal location of the top left corner of the character.
|
|
|
|
\param y vertical location of the top left corner of the character.
|
|
|
|
\param str 8 bit character string to draw.
|
|
|
|
\param count Maximum characters of the string to draw.
|
|
|
|
\note See Draw_Character() for character set description.
|
|
|
|
Draws up to \p count characters, or stops at the first nul
|
|
|
|
character.
|
|
|
|
*/
|
|
|
|
void Draw_nString (int x, int y, const char *str, int count);
|
|
|
|
|
|
|
|
/** Draws a character string to the screen.
|
|
|
|
No line wrapping is performed.
|
|
|
|
\param x horizontal location of the top left corner of the character.
|
|
|
|
\param y vertical location of the top left corner of the character.
|
|
|
|
\param str 8 bit character string to draw.
|
|
|
|
\note See Draw_Character() for character set description.
|
|
|
|
String is normal nul terminated C string.
|
|
|
|
Characters of the string are forced to have their high bit set
|
|
|
|
(ie, they will be in the range 0x80-0xff).
|
|
|
|
*/
|
|
|
|
void Draw_AltString (int x, int y, const char *str);
|
|
|
|
|
|
|
|
/** Draw the console background with various optional effects.
|
|
|
|
\param lines Vertical size in pixels of the console.
|
|
|
|
\param alpha Console transparency level (255 = opaque).
|
|
|
|
\note \p alpha is effective only in the OpenGL renderer. Effectively
|
|
|
|
255 (opaque) for the software renderer.
|
|
|
|
|
|
|
|
\c gl_conspin causes the background to spin.
|
|
|
|
|
|
|
|
\c gl_constretch causes the background to stretch rather than slide.
|
|
|
|
*/
|
2003-07-25 22:21:47 +00:00
|
|
|
void Draw_ConsoleBackground (int lines, byte alpha);
|
2006-12-03 06:25:57 +00:00
|
|
|
|
|
|
|
/** Draw a crosshair at the center of the screen.
|
|
|
|
\c crosshair specifies which crosshair (1 = '+', 2 = large 'x' shape,
|
|
|
|
3 = fancy '+' shape)
|
|
|
|
\c cl_crossx and \c cl_crossy offset the crosshair from the center of the
|
|
|
|
screen.
|
|
|
|
*/
|
2001-12-09 14:05:30 +00:00
|
|
|
void Draw_Crosshair (void);
|
2006-12-03 06:25:57 +00:00
|
|
|
|
|
|
|
/** Draw the specified crosshair on the screen.
|
|
|
|
\param ch crosshair to draw
|
|
|
|
\param x horizontal position of the center of the crosshair.
|
|
|
|
\param y vertical position of the center of the crosshair.
|
|
|
|
|
|
|
|
See Draw_Crosshair() for description of crosshair values.
|
|
|
|
*/
|
2004-02-13 23:16:33 +00:00
|
|
|
void Draw_CrosshairAt (int ch, int x, int y);
|
2006-12-03 06:25:57 +00:00
|
|
|
|
|
|
|
/** Clear a rectangle with a tiled background.
|
|
|
|
\param x horizontal position of the upper left corner of the rectangle
|
|
|
|
\param y horizontal position of the upper left corner of the rectangle
|
|
|
|
\param w width of the rectangle
|
|
|
|
\param h height of the rectangle
|
|
|
|
|
|
|
|
The background used is the "backtile" WAD lump.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
void Draw_TileClear (int x, int y, int w, int h);
|
2006-12-03 06:25:57 +00:00
|
|
|
|
|
|
|
/** Clear a rectangle with a solid color.
|
|
|
|
\param x horizontal position of the upper left corner of the rectangle
|
|
|
|
\param y horizontal position of the upper left corner of the rectangle
|
|
|
|
\param w width of the rectangle
|
|
|
|
\param h height of the rectangle
|
|
|
|
\param c 8 bit color index.
|
|
|
|
|
|
|
|
The color comes from the quake palette.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
void Draw_Fill (int x, int y, int w, int h, int c);
|
2006-12-03 06:25:57 +00:00
|
|
|
|
2022-05-28 09:14:26 +00:00
|
|
|
/** Clear a line with a solid color.
|
|
|
|
\param x0 horizontal position of the line start point
|
|
|
|
\param y0 horizontal position of the line start point
|
|
|
|
\param x1 horizontal position of the line end point
|
|
|
|
\param y1 horizontal position of the line end point
|
|
|
|
\param c 8 bit color index.
|
|
|
|
|
|
|
|
The color comes from the quake palette.
|
|
|
|
*/
|
|
|
|
void Draw_Line (int x0, int y0, int x1, int y1, int c);
|
|
|
|
|
2006-12-03 06:25:57 +00:00
|
|
|
/** Draw a text box on the screen
|
|
|
|
\param x horizontal location of the upper left corner of the box
|
|
|
|
\param y vertical location of the upper left corner of the box
|
|
|
|
\param width horizontal size in character cells of the region
|
2006-12-05 11:40:00 +00:00
|
|
|
\param lines vertical size in character cells of the region
|
2006-12-03 06:25:57 +00:00
|
|
|
\param alpha transparency of the box
|
|
|
|
*/
|
|
|
|
void Draw_TextBox (int x, int y, int width, int lines, byte alpha);
|
|
|
|
|
|
|
|
/** Darken the screen.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
void Draw_FadeScreen (void);
|
2012-01-28 11:45:14 +00:00
|
|
|
|
|
|
|
/** Shift the screen colors.
|
|
|
|
*/
|
|
|
|
void Draw_BlendScreen (quat_t color);
|
2020-02-11 06:20:49 +00:00
|
|
|
///@}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2006-12-05 11:40:00 +00:00
|
|
|
/** \defgroup video_renderer_draw_qpic QPic functions
|
|
|
|
\ingroup video_renderer_draw
|
|
|
|
*/
|
2020-02-11 06:20:49 +00:00
|
|
|
///@{
|
2006-12-03 06:25:57 +00:00
|
|
|
/** Load a qpic from the filesystem.
|
|
|
|
\param path path of the file within the quake filesystem
|
|
|
|
\param alpha transparency level of the pic.
|
|
|
|
\return pointer qpic data.
|
|
|
|
\note Up to MAX_CACHED_PICS qpics can be loaded at a time this way
|
|
|
|
*/
|
2006-12-02 10:07:08 +00:00
|
|
|
qpic_t *Draw_CachePic (const char *path, qboolean alpha);
|
2012-02-01 07:55:35 +00:00
|
|
|
|
|
|
|
/** Remove a qpic from the qpic cache.
|
|
|
|
|
|
|
|
This affects only those qpics that were loaded via Draw_CachePic.
|
|
|
|
|
|
|
|
\param path path of the file within the quake filesystem
|
|
|
|
*/
|
|
|
|
void Draw_UncachePic (const char *path);
|
2012-02-01 08:46:15 +00:00
|
|
|
|
|
|
|
/** Create a qpic from raw data.
|
|
|
|
|
|
|
|
\param width The width of the pic.
|
|
|
|
\param height The height of the pic.
|
|
|
|
\param data The raw data bytes. The system palette will be used for
|
|
|
|
colors.
|
|
|
|
\return pointer qpic data.
|
|
|
|
*/
|
|
|
|
qpic_t *Draw_MakePic (int width, int height, const byte *data);
|
|
|
|
|
|
|
|
/** Destroy a qpic created by Draw_MakePic.
|
|
|
|
|
|
|
|
\param pic The qpic to destory.
|
|
|
|
*/
|
|
|
|
void Draw_DestroyPic (qpic_t *pic);
|
2006-12-03 06:25:57 +00:00
|
|
|
|
|
|
|
/** Load a qpic from gfx.wad.
|
|
|
|
\param name name of the was lump to load
|
|
|
|
\return pointer qpic data.
|
|
|
|
*/
|
|
|
|
qpic_t *Draw_PicFromWad (const char *name);
|
|
|
|
|
|
|
|
/** Draw a qpic to the screen
|
|
|
|
\param x horizontal location of the upper left corner of the qpic
|
|
|
|
\param y vertical location of the upper left corner of the qpic
|
|
|
|
\param pic qpic to draw
|
|
|
|
*/
|
2006-12-02 10:07:08 +00:00
|
|
|
void Draw_Pic (int x, int y, qpic_t *pic);
|
2006-12-03 06:25:57 +00:00
|
|
|
|
2012-02-06 10:32:30 +00:00
|
|
|
/** Draw a qpic to the screen
|
|
|
|
\param x horizontal location of the upper left corner of the qpic
|
|
|
|
\param y vertical location of the upper left corner of the qpic
|
|
|
|
\param pic qpic to draw
|
|
|
|
*/
|
|
|
|
void Draw_Picf (float x, float y, qpic_t *pic);
|
|
|
|
|
2006-12-03 06:25:57 +00:00
|
|
|
/** Draw a sub-region of a qpic to the screan
|
|
|
|
\param x horizontal screen location of the upper left corner of the
|
|
|
|
sub-region
|
|
|
|
\param y vertical screen location of the upper left corner of the
|
|
|
|
sub-region
|
|
|
|
\param pic qpic to draw
|
|
|
|
\param srcx horizontal qpic location of the upper left corner of the
|
|
|
|
sub-region
|
|
|
|
\param srcy vertical qpic location of the upper left corner of the
|
|
|
|
sub-region
|
|
|
|
\param width horizontal size of the sub-region to be drawn
|
2006-12-05 11:40:00 +00:00
|
|
|
\param height vertical size of the sub-region to be drawn
|
2006-12-03 06:25:57 +00:00
|
|
|
*/
|
2006-12-02 10:07:08 +00:00
|
|
|
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
|
2022-08-31 10:23:30 +00:00
|
|
|
|
2022-12-07 06:11:08 +00:00
|
|
|
struct font_s;
|
|
|
|
int Draw_AddFont (struct font_s *font);
|
2022-12-10 09:55:08 +00:00
|
|
|
void Draw_Glyph (int x, int y, int fontid, int glyphid, int c);
|
2022-08-31 10:23:30 +00:00
|
|
|
|
2020-02-11 06:20:49 +00:00
|
|
|
///@}
|
2006-12-03 06:25:57 +00:00
|
|
|
|
2020-02-24 03:21:20 +00:00
|
|
|
#endif//__QF_draw_h
|