DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
draw.h File Reference
#include <stddef.h>
#include "qtypes.h"
#include "r_textures.h"
+ Include dependency graph for draw.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dp_font_t
 
struct  dp_fonts_t
 
struct  drawqueuemesh_t
 
struct  ft2_settings_t
 

Macros

#define DRAWFLAGS_BLEND   0xFF /* this matches all blending flags */
 
#define FONT_CENTERPRINT   (&dp_fonts.f[5])
 
#define FONT_CHAT   (&dp_fonts.f[4])
 
#define FONT_CONSOLE   (&dp_fonts.f[1])
 
#define FONT_DEFAULT   (&dp_fonts.f[0])
 
#define FONT_INFOBAR   (&dp_fonts.f[6])
 
#define FONT_MENU   (&dp_fonts.f[7])
 
#define FONT_NOTIFY   (&dp_fonts.f[3])
 
#define FONT_SBAR   (&dp_fonts.f[2])
 
#define FONT_USER(i)
 
#define FONTS_EXPAND   8
 
#define MAX_FONT_CMDLINE   MAX_QPATH * (MAX_FONT_FALLBACKS + 1)
 
#define MAX_FONT_FALLBACKS   3
 
#define MAX_FONT_SIZES   16
 
#define MAX_FONTS   16
 
#define MAX_USERFONTS   (dp_fonts.maxsize - 8)
 
#define STRING_COLOR_DEFAULT   7
 
#define STRING_COLOR_DEFAULT_STR   "^7"
 
#define STRING_COLOR_RGB_TAG   "^x"
 
#define STRING_COLOR_RGB_TAG_CHAR   'x'
 
#define STRING_COLOR_TAG   '^'
 

Enumerations

enum  cachepicflags_t {
  CACHEPICFLAG_NOTPERSISTENT = 1 , CACHEPICFLAG_QUIET = 2 , CACHEPICFLAG_NOCOMPRESSION = 4 , CACHEPICFLAG_NOCLAMP = 8 ,
  CACHEPICFLAG_NEWPIC = 16 , CACHEPICFLAG_MIPMAP = 32 , CACHEPICFLAG_NEAREST = 64 , CACHEPICFLAG_LINEAR = 128 ,
  CACHEPICFLAG_FAILONMISSING = 256
}
 
enum  drawqueue_drawflag_e {
  DRAWFLAG_NORMAL , DRAWFLAG_ADDITIVE , DRAWFLAG_MODULATE , DRAWFLAG_2XMODULATE ,
  DRAWFLAG_SCREEN , DRAWFLAG_NUMFLAGS , DRAWFLAG_MASK = 0xFF , DRAWFLAG_MIPMAP = 0x100 ,
  DRAWFLAG_NOGAMMA = 0x200
}
 

Functions

cachepic_t * Draw_CachePic (const char *path)
 
cachepic_t * Draw_CachePic_Flags (const char *path, unsigned int cachepicflags)
 
void Draw_Frame (void)
 
void Draw_FreePic (const char *picname)
 
int Draw_GetPicHeight (cachepic_t *pic)
 
const char * Draw_GetPicName (cachepic_t *pic)
 
rtexture_tDraw_GetPicTexture (cachepic_t *pic)
 
int Draw_GetPicWidth (cachepic_t *pic)
 
qbool Draw_IsPicLoaded (cachepic_t *pic)
 
cachepic_t * Draw_NewPic (const char *picname, int width, int height, unsigned char *pixels, textype_t textype, int texflags)
 
void DrawQ_Fill (float x, float y, float width, float height, float red, float green, float blue, float alpha, int flags)
 
void DrawQ_Finish (void)
 
void DrawQ_FlushUI (void)
 
void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, float g, float b, float alpha, int flags)
 
void DrawQ_Pic (float x, float y, cachepic_t *pic, float width, float height, float red, float green, float blue, float alpha, int flags)
 
void DrawQ_RecalcView (void)
 
void DrawQ_ResetClipArea (void)
 
void DrawQ_RotPic (float x, float y, cachepic_t *pic, float width, float height, float org_x, float org_y, float angle, float red, float green, float blue, float alpha, int flags)
 
void DrawQ_SetClipArea (float x, float y, float width, float height)
 
void DrawQ_Start (void)
 
float DrawQ_String (float x, float y, const char *text, size_t maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt)
 
float DrawQ_String_Scale (float x, float y, const char *text, size_t maxlen, float sizex, float sizey, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt)
 
void DrawQ_SuperPic (float x, float y, cachepic_t *pic, float width, float height, float s1, float t1, float r1, float g1, float b1, float a1, float s2, float t2, float r2, float g2, float b2, float a2, float s3, float t3, float r3, float g3, float b3, float a3, float s4, float t4, float r4, float g4, float b4, float a4, int flags)
 
float DrawQ_TextWidth (const char *text, size_t maxlen, float w, float h, qbool ignorecolorcodes, const dp_font_t *fnt)
 
float DrawQ_TextWidth_UntilWidth (const char *text, size_t *maxlen, float w, float h, qbool ignorecolorcodes, const dp_font_t *fnt, float maxWidth)
 
float DrawQ_TextWidth_UntilWidth_TrackColors (const char *text, size_t *maxlen, float w, float h, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt, float maxwidth)
 
float DrawQ_TextWidth_UntilWidth_TrackColors_Scale (const char *text, size_t *maxlen, float w, float h, float sw, float sh, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt, float maxwidth)
 

Variables

dp_fonts_t dp_fonts
 
float DrawQ_Color [4]
 
rtexturepool_tdrawtexturepool
 
const vec4_t string_colors []
 color tag printing
 

Macro Definition Documentation

◆ DRAWFLAGS_BLEND

#define DRAWFLAGS_BLEND   0xFF /* this matches all blending flags */

Definition at line 84 of file draw.h.

◆ FONT_CENTERPRINT

#define FONT_CENTERPRINT   (&dp_fonts.f[5])

Definition at line 133 of file draw.h.

Referenced by GL_Draw_Init(), and SCR_DrawCenterString().

◆ FONT_CHAT

#define FONT_CHAT   (&dp_fonts.f[4])

◆ FONT_CONSOLE

#define FONT_CONSOLE   (&dp_fonts.f[1])

◆ FONT_DEFAULT

◆ FONT_INFOBAR

#define FONT_INFOBAR   (&dp_fonts.f[6])

◆ FONT_MENU

#define FONT_MENU   (&dp_fonts.f[7])

Definition at line 135 of file draw.h.

Referenced by GL_Draw_Init(), M_DrawCharacter(), M_ItemPrint(), M_Print(), M_PrintColored(), and M_PrintRed().

◆ FONT_NOTIFY

#define FONT_NOTIFY   (&dp_fonts.f[3])

Definition at line 131 of file draw.h.

Referenced by CL_DrawVideo(), Con_DrawNotifyRect(), and GL_Draw_Init().

◆ FONT_SBAR

#define FONT_SBAR   (&dp_fonts.f[2])

◆ FONT_USER

#define FONT_USER ( i)
Value:
(&dp_fonts.f[8+i])
dp_fonts_t dp_fonts
Definition gl_draw.c:50
int i
dp_font_t * f
Definition draw.h:120

Definition at line 136 of file draw.h.

Referenced by GL_Draw_Init().

◆ FONTS_EXPAND

#define FONTS_EXPAND   8

Definition at line 127 of file draw.h.

Referenced by FindFont().

◆ MAX_FONT_CMDLINE

#define MAX_FONT_CMDLINE   MAX_QPATH * (MAX_FONT_FALLBACKS + 1)

Definition at line 96 of file draw.h.

Referenced by LoadFont_f().

◆ MAX_FONT_FALLBACKS

#define MAX_FONT_FALLBACKS   3

Definition at line 95 of file draw.h.

Referenced by Font_LoadFont(), LoadFont(), LoadFont_f(), and VM_loadfont().

◆ MAX_FONT_SIZES

◆ MAX_FONTS

#define MAX_FONTS   16

Definition at line 126 of file draw.h.

Referenced by GL_Draw_Init().

◆ MAX_USERFONTS

#define MAX_USERFONTS   (dp_fonts.maxsize - 8)

Definition at line 137 of file draw.h.

Referenced by GL_Draw_Init().

◆ STRING_COLOR_DEFAULT

#define STRING_COLOR_DEFAULT   7

◆ STRING_COLOR_DEFAULT_STR

#define STRING_COLOR_DEFAULT_STR   "^7"

Definition at line 142 of file draw.h.

Referenced by SV_Name_f().

◆ STRING_COLOR_RGB_TAG

#define STRING_COLOR_RGB_TAG   "^x"

Definition at line 144 of file draw.h.

◆ STRING_COLOR_RGB_TAG_CHAR

◆ STRING_COLOR_TAG

Enumeration Type Documentation

◆ cachepicflags_t

Enumerator
CACHEPICFLAG_NOTPERSISTENT 
CACHEPICFLAG_QUIET 
CACHEPICFLAG_NOCOMPRESSION 
CACHEPICFLAG_NOCLAMP 
CACHEPICFLAG_NEWPIC 
CACHEPICFLAG_MIPMAP 
CACHEPICFLAG_NEAREST 
CACHEPICFLAG_LINEAR 
CACHEPICFLAG_FAILONMISSING 

Definition at line 34 of file draw.h.

35{
40 CACHEPICFLAG_NEWPIC = 16, // disables matching texflags check, because a pic created with Draw_NewPic should not be subject to that
42 CACHEPICFLAG_NEAREST = 64, // force nearest filtering instead of linear
43 CACHEPICFLAG_LINEAR = 128, // force linear filtering even if nearest_2d is enabled
44 CACHEPICFLAG_FAILONMISSING = 256 // return NULL if the pic has no texture
45}
@ CACHEPICFLAG_FAILONMISSING
Definition draw.h:44
@ CACHEPICFLAG_NEAREST
Definition draw.h:42
@ CACHEPICFLAG_LINEAR
Definition draw.h:43
@ CACHEPICFLAG_QUIET
Definition draw.h:37
@ CACHEPICFLAG_NEWPIC
Definition draw.h:40
@ CACHEPICFLAG_NOTPERSISTENT
Definition draw.h:36
@ CACHEPICFLAG_NOCLAMP
Definition draw.h:39
@ CACHEPICFLAG_NOCOMPRESSION
Definition draw.h:38
@ CACHEPICFLAG_MIPMAP
Definition draw.h:41

◆ drawqueue_drawflag_e

Enumerator
DRAWFLAG_NORMAL 
DRAWFLAG_ADDITIVE 
DRAWFLAG_MODULATE 
DRAWFLAG_2XMODULATE 
DRAWFLAG_SCREEN 
DRAWFLAG_NUMFLAGS 
DRAWFLAG_MASK 
DRAWFLAG_MIPMAP 
DRAWFLAG_NOGAMMA 

Definition at line 73 of file draw.h.

73 {
80DRAWFLAG_MASK = 0xFF, // ONLY R_BeginPolygon()
81DRAWFLAG_MIPMAP = 0x100, // ONLY R_BeginPolygon()
82DRAWFLAG_NOGAMMA = 0x200 // ONLY R_DrawQSuperPic()
83};
@ DRAWFLAG_ADDITIVE
Definition draw.h:75
@ DRAWFLAG_MODULATE
Definition draw.h:76
@ DRAWFLAG_2XMODULATE
Definition draw.h:77
@ DRAWFLAG_NUMFLAGS
Definition draw.h:79
@ DRAWFLAG_MASK
Definition draw.h:80
@ DRAWFLAG_MIPMAP
Definition draw.h:81
@ DRAWFLAG_NORMAL
Definition draw.h:74
@ DRAWFLAG_SCREEN
Definition draw.h:78
@ DRAWFLAG_NOGAMMA
Definition draw.h:82

Function Documentation

◆ Draw_CachePic()

◆ Draw_CachePic_Flags()

cachepic_t * Draw_CachePic_Flags ( const char * path,
unsigned int cachepicflags )

Definition at line 86 of file gl_draw.c.

87{
88 int crc, hashkey;
89 cachepic_t *pic;
90 int texflags;
91
92 texflags = TEXF_ALPHA;
93 if (!(cachepicflags & CACHEPICFLAG_NOCLAMP))
94 texflags |= TEXF_CLAMP;
95 if (cachepicflags & CACHEPICFLAG_MIPMAP)
96 texflags |= TEXF_MIPMAP;
98 texflags |= TEXF_COMPRESS;
99 if (cachepicflags & CACHEPICFLAG_LINEAR)
100 texflags |= TEXF_FORCELINEAR;
101 else if ((cachepicflags & CACHEPICFLAG_NEAREST) || r_nearest_2d.integer)
102 texflags |= TEXF_FORCENEAREST;
103
104 // check whether the picture has already been cached
105 crc = CRC_Block((unsigned char *)path, strlen(path));
106 hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
107 for (pic = cachepichash[hashkey];pic;pic = pic->chain)
108 {
109 if (!strcmp(path, pic->name))
110 {
111 // if it was created (or replaced) by Draw_NewPic, just return it
112 if (!(pic->flags & CACHEPICFLAG_NEWPIC))
113 {
114 // reload the pic if texflags changed in important ways
115 // ignore TEXF_COMPRESS when comparing, because fallback pics remove the flag, and ignore TEXF_MIPMAP because QC specifies that
116 if ((pic->texflags ^ texflags) & ~(TEXF_COMPRESS | TEXF_MIPMAP))
117 {
118 Con_DPrintf("Draw_CachePic(\"%s\"): frame %i: reloading pic due to mismatch on flags\n", path, draw_frame);
119 goto reload;
120 }
121 if (!pic->skinframe || !pic->skinframe->base)
122 {
123 if (pic->flags & CACHEPICFLAG_FAILONMISSING)
124 return NULL;
125 Con_DPrintf("Draw_CachePic(\"%s\"): frame %i: reloading pic\n", path, draw_frame);
126 goto reload;
127 }
128 if (!(cachepicflags & CACHEPICFLAG_NOTPERSISTENT))
129 pic->autoload = false; // caller is making this pic persistent
130 }
131 if (pic->skinframe)
132 R_SkinFrame_MarkUsed(pic->skinframe);
133 pic->lastusedframe = draw_frame;
134 return pic;
135 }
136 }
137
139 {
140 Con_DPrintf ("Draw_CachePic(\"%s\"): frame %i: numcachepics == MAX_CACHED_PICS\n", path, draw_frame);
141 // FIXME: support NULL in callers?
142 return cachepics; // return the first one
143 }
144 Con_DPrintf("Draw_CachePic(\"%s\"): frame %i: loading pic%s\n", path, draw_frame, (cachepicflags & CACHEPICFLAG_NOTPERSISTENT) ? " notpersist" : "");
145 pic = cachepics + (numcachepics++);
146 memset(pic, 0, sizeof(*pic));
147 dp_strlcpy (pic->name, path, sizeof(pic->name));
148 // link into list
149 pic->chain = cachepichash[hashkey];
150 cachepichash[hashkey] = pic;
151
152reload:
153 if (pic->skinframe)
154 R_SkinFrame_PurgeSkinFrame(pic->skinframe);
155
156 pic->flags = cachepicflags;
157 pic->texflags = texflags;
158 pic->autoload = (cachepicflags & CACHEPICFLAG_NOTPERSISTENT) != 0;
159 pic->lastusedframe = draw_frame;
160
161 if (pic->skinframe)
162 {
163 // reload image after it was unloaded or texflags changed significantly
164 R_SkinFrame_LoadExternal_SkinFrame(pic->skinframe, pic->name, texflags | TEXF_FORCE_RELOAD, (cachepicflags & CACHEPICFLAG_QUIET) == 0, (cachepicflags & CACHEPICFLAG_FAILONMISSING) == 0);
165 }
166 else
167 {
168 // load high quality image (this falls back to low quality too)
169 pic->skinframe = R_SkinFrame_LoadExternal(pic->name, texflags | TEXF_FORCE_RELOAD, (cachepicflags & CACHEPICFLAG_QUIET) == 0, (cachepicflags & CACHEPICFLAG_FAILONMISSING) == 0);
170 }
171
172 // get the dimensions of the image we loaded (if it was successful)
173 if (pic->skinframe && pic->skinframe->base)
174 {
175 pic->width = R_TextureWidth(pic->skinframe->base);
176 pic->height = R_TextureHeight(pic->skinframe->base);
177 }
178
179 // check for a low quality version of the pic and use its size if possible, to match the stock hud
180 Image_GetStockPicSize(pic->name, &pic->width, &pic->height);
181
182 return pic;
183}
unsigned short CRC_Block(const unsigned char *data, size_t size)
Definition com_crc16.c:75
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
static cachepic_t cachepics[MAX_CACHED_PICS]
Definition gl_draw.c:73
static cachepic_t * cachepichash[CACHEPICHASHSIZE]
Definition gl_draw.c:72
int draw_frame
Definition gl_draw.c:78
cvar_t r_nearest_2d
Definition gl_draw.c:66
static int numcachepics
Definition gl_draw.c:74
skinframe_t * R_SkinFrame_LoadExternal(const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
Definition gl_rmain.c:2314
void R_SkinFrame_PurgeSkinFrame(skinframe_t *s)
Definition gl_rmain.c:2184
skinframe_t * R_SkinFrame_LoadExternal_SkinFrame(skinframe_t *skinframe, const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
Definition gl_rmain.c:2331
void R_SkinFrame_MarkUsed(skinframe_t *skinframe)
Definition gl_rmain.c:2176
cvar_t gl_texturecompression
Definition gl_textures.c:37
int R_TextureHeight(rtexture_t *rt)
int R_TextureWidth(rtexture_t *rt)
cvar_t gl_texturecompression_2d
Definition gl_textures.c:42
qbool Image_GetStockPicSize(const char *filename, int *returnwidth, int *returnheight)
Definition image.c:1196
float strlen(string s)
#define MAX_CACHED_PICS
max number of 2D pics loaded at once
Definition qdefs.h:133
#define CACHEPICHASHSIZE
number of hash buckets for accelerating 2D pic name lookups
Definition qdefs.h:134
#define NULL
Definition qtypes.h:12
#define TEXF_ALPHA
Definition r_textures.h:9
#define TEXF_FORCELINEAR
Definition r_textures.h:19
#define TEXF_MIPMAP
Definition r_textures.h:11
#define TEXF_FORCENEAREST
Definition r_textures.h:17
#define TEXF_COMPRESS
Definition r_textures.h:23
#define TEXF_CLAMP
Definition r_textures.h:15
#define TEXF_FORCE_RELOAD
Definition r_textures.h:41
int integer
Definition cvar.h:73

References CACHEPICFLAG_FAILONMISSING, CACHEPICFLAG_LINEAR, CACHEPICFLAG_MIPMAP, CACHEPICFLAG_NEAREST, CACHEPICFLAG_NEWPIC, CACHEPICFLAG_NOCLAMP, CACHEPICFLAG_NOCOMPRESSION, CACHEPICFLAG_NOTPERSISTENT, CACHEPICFLAG_QUIET, cachepichash, CACHEPICHASHSIZE, cachepics, Con_DPrintf(), CRC_Block(), dp_strlcpy, draw_frame, gl_texturecompression, gl_texturecompression_2d, Image_GetStockPicSize(), cvar_t::integer, MAX_CACHED_PICS, NULL, numcachepics, r_nearest_2d, R_SkinFrame_LoadExternal(), R_SkinFrame_LoadExternal_SkinFrame(), R_SkinFrame_MarkUsed(), R_SkinFrame_PurgeSkinFrame(), R_TextureHeight(), R_TextureWidth(), strlen(), TEXF_ALPHA, TEXF_CLAMP, TEXF_COMPRESS, TEXF_FORCE_RELOAD, TEXF_FORCELINEAR, TEXF_FORCENEAREST, TEXF_MIPMAP, and cachepic_t::texflags.

Referenced by Con_DrawConsole(), Draw_CachePic(), LoadFont(), M_Menu_Main_f(), M_Options_ColorControl_Draw(), OpenVideo(), sbar_start(), SCR_DrawLoadingScreen(), SCR_DrawTouchscreenOverlay(), SHOWLMP_drawall(), VM_CL_ReadPicture(), VM_drawpic(), VM_drawrotpic(), VM_drawsubpic(), VM_getimagesize(), and VM_precache_pic().

◆ Draw_Frame()

void Draw_Frame ( void )

Definition at line 237 of file gl_draw.c.

238{
239 int i;
240 cachepic_t *pic;
241 static double nextpurgetime;
242 if (nextpurgetime > host.realtime)
243 return;
244 nextpurgetime = host.realtime + 0.05;
245 for (i = 0, pic = cachepics;i < numcachepics;i++, pic++)
246 {
247 if (pic->autoload && pic->skinframe && pic->skinframe->base && pic->lastusedframe < draw_frame - 3)
248 {
249 Con_DPrintf("Draw_Frame(%i): Unloading \"%s\"\n", draw_frame, pic->name);
250 R_SkinFrame_PurgeSkinFrame(pic->skinframe);
251 }
252 }
253 draw_frame++;
254}
host_static_t host
Definition host.c:41
double realtime
the accumulated mainloop time since application started (with filtering), without any slowmo or clamp...
Definition host.h:46

References cachepics, Con_DPrintf(), draw_frame, host, i, numcachepics, R_SkinFrame_PurgeSkinFrame(), and host_static_t::realtime.

Referenced by SCR_DrawScreen().

◆ Draw_FreePic()

void Draw_FreePic ( const char * picname)

Definition at line 309 of file gl_draw.c.

310{
311 int crc;
312 int hashkey;
313 cachepic_t *pic;
314 // this doesn't really free the pic, but does free its texture
315 crc = CRC_Block((unsigned char *)picname, strlen(picname));
316 hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
317 for (pic = cachepichash[hashkey];pic;pic = pic->chain)
318 {
319 if (!strcmp (picname, pic->name) && pic->skinframe)
320 {
321 Con_DPrintf("Draw_FreePic(\"%s\"): frame %i: freeing pic\n", picname, draw_frame);
322 R_SkinFrame_PurgeSkinFrame(pic->skinframe);
323 return;
324 }
325 }
326}

References cachepichash, CACHEPICHASHSIZE, Con_DPrintf(), CRC_Block(), draw_frame, R_SkinFrame_PurgeSkinFrame(), and strlen().

Referenced by UnlinkVideoTexture(), and VM_freepic().

◆ Draw_GetPicHeight()

int Draw_GetPicHeight ( cachepic_t * pic)

Definition at line 204 of file gl_draw.c.

205{
206 if (pic == NULL)
207 return 0;
208 return pic->height;
209}

References NULL.

Referenced by DrawQ_String_Scale(), Sbar_Draw(), SCR_DrawBrand(), SCR_DrawLoadingScreen(), SCR_DrawPause(), and VM_getimagesize().

◆ Draw_GetPicName()

const char * Draw_GetPicName ( cachepic_t * pic)

Definition at line 190 of file gl_draw.c.

191{
192 if (pic == NULL)
193 return "";
194 return pic->name;
195}

References NULL.

Referenced by incmap_post_process().

◆ Draw_GetPicTexture()

rtexture_t * Draw_GetPicTexture ( cachepic_t * pic)

Definition at line 224 of file gl_draw.c.

225{
226 if (pic == NULL)
227 return NULL;
228 if (pic->autoload && (!pic->skinframe || !pic->skinframe->base))
229 {
230 Con_DPrintf("Draw_GetPicTexture(\"%s\"): Loading external skin\n", pic->name);
231 pic->skinframe = R_SkinFrame_LoadExternal(pic->name, pic->texflags | TEXF_FORCE_RELOAD, false, true);
232 }
233 pic->lastusedframe = draw_frame;
234 return pic->skinframe ? pic->skinframe->base : NULL;
235}

References Con_DPrintf(), draw_frame, NULL, R_SkinFrame_LoadExternal(), and TEXF_FORCE_RELOAD.

Referenced by CL_Video_Frame(), DrawQ_Pic(), DrawQ_RotPic(), DrawQ_SuperPic(), LinkVideoTexture(), and SCR_DrawLoadingScreen().

◆ Draw_GetPicWidth()

◆ Draw_IsPicLoaded()

qbool Draw_IsPicLoaded ( cachepic_t * pic)

Definition at line 211 of file gl_draw.c.

212{
213 if (pic == NULL)
214 return false;
215 if (pic->autoload && (!pic->skinframe || !pic->skinframe->base))
216 {
217 Con_DPrintf("Draw_IsPicLoaded(\"%s\"): Loading external skin\n", pic->name);
218 pic->skinframe = R_SkinFrame_LoadExternal(pic->name, pic->texflags | TEXF_FORCE_RELOAD, false, true);
219 }
220 // skinframe will only be NULL if the pic was created with CACHEPICFLAG_FAILONMISSING and not found
221 return pic->skinframe != NULL && pic->skinframe->base != NULL;
222}

References Con_DPrintf(), NULL, R_SkinFrame_LoadExternal(), and TEXF_FORCE_RELOAD.

Referenced by Con_DrawConsole(), Font_LoadMap(), LoadFont(), M_Menu_Main_f(), Sbar_Score(), SCR_DrawTouchscreenOverlay(), VM_CL_ReadPicture(), VM_getimagesize(), and VM_precache_pic().

◆ Draw_NewPic()

cachepic_t * Draw_NewPic ( const char * picname,
int width,
int height,
unsigned char * pixels,
textype_t textype,
int texflags )

Definition at line 256 of file gl_draw.c.

257{
258 int crc, hashkey;
259 cachepic_t *pic;
260
261 crc = CRC_Block((unsigned char *)picname, strlen(picname));
262 hashkey = ((crc >> 8) ^ crc) % CACHEPICHASHSIZE;
263 for (pic = cachepichash[hashkey];pic;pic = pic->chain)
264 if (!strcmp (picname, pic->name))
265 break;
266
267 if (pic)
268 {
269 if (pic->flags & CACHEPICFLAG_NEWPIC && pic->skinframe && pic->skinframe->base && pic->width == width && pic->height == height)
270 {
271 Con_DPrintf("Draw_NewPic(\"%s\"): frame %i: updating texture\n", picname, draw_frame);
272 R_UpdateTexture(pic->skinframe->base, pixels_bgra, 0, 0, 0, width, height, 1, 0);
273 R_SkinFrame_MarkUsed(pic->skinframe);
274 pic->lastusedframe = draw_frame;
275 return pic;
276 }
277 Con_DPrintf("Draw_NewPic(\"%s\"): frame %i: reloading pic because flags/size changed\n", picname, draw_frame);
278 }
279 else
280 {
282 {
283 Con_DPrintf ("Draw_NewPic(\"%s\"): frame %i: numcachepics == MAX_CACHED_PICS\n", picname, draw_frame);
284 // FIXME: support NULL in callers?
285 return cachepics; // return the first one
286 }
287 Con_DPrintf("Draw_NewPic(\"%s\"): frame %i: creating new cachepic\n", picname, draw_frame);
288 pic = cachepics + (numcachepics++);
289 memset(pic, 0, sizeof(*pic));
290 dp_strlcpy (pic->name, picname, sizeof(pic->name));
291 // link into list
292 pic->chain = cachepichash[hashkey];
293 cachepichash[hashkey] = pic;
294 }
295
296 R_SkinFrame_PurgeSkinFrame(pic->skinframe);
297
298 pic->autoload = false;
299 pic->flags = CACHEPICFLAG_NEWPIC; // disable texflags checks in Draw_CachePic
300 pic->flags |= (texflags & TEXF_CLAMP) ? 0 : CACHEPICFLAG_NOCLAMP;
301 pic->flags |= (texflags & TEXF_FORCENEAREST) ? CACHEPICFLAG_NEAREST : 0;
302 pic->width = width;
303 pic->height = height;
304 pic->skinframe = R_SkinFrame_LoadInternalBGRA(picname, texflags | TEXF_FORCE_RELOAD, pixels_bgra, width, height, 0, 0, 0, vid.sRGB2D);
305 pic->lastusedframe = draw_frame;
306 return pic;
307}
skinframe_t * R_SkinFrame_LoadInternalBGRA(const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qbool sRGB)
Definition gl_rmain.c:2546
void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int z, int width, int height, int depth, int combine)
GLenum GLsizei width
Definition glquake.h:622
GLenum GLsizei GLsizei height
Definition glquake.h:622
qbool sRGB2D
whether 2D rendering is sRGB corrected (based on sRGBcapable2D)
Definition vid.h:75
viddef_t vid
global video state
Definition vid_shared.c:64

References CACHEPICFLAG_NEAREST, CACHEPICFLAG_NEWPIC, CACHEPICFLAG_NOCLAMP, cachepichash, CACHEPICHASHSIZE, cachepics, Con_DPrintf(), CRC_Block(), dp_strlcpy, draw_frame, height, MAX_CACHED_PICS, numcachepics, R_SkinFrame_LoadInternalBGRA(), R_SkinFrame_MarkUsed(), R_SkinFrame_PurgeSkinFrame(), R_UpdateTexture(), viddef_t::sRGB2D, strlen(), TEXF_CLAMP, TEXF_FORCE_RELOAD, TEXF_FORCENEAREST, cachepic_t::texflags, vid, and width.

Referenced by Curl_EndDownload(), LinkVideoTexture(), M_Setup_Draw(), update_pic_for_fontmap(), VideoUpdateCallback(), and VM_CL_ReadPicture().

◆ DrawQ_Fill()

void DrawQ_Fill ( float x,
float y,
float width,
float height,
float red,
float green,
float blue,
float alpha,
int flags )

Definition at line 847 of file gl_draw.c.

848{
849 DrawQ_Pic(x, y, Draw_CachePic("white"), width, height, red, green, blue, alpha, flags);
850}
float flags
float alpha
cachepic_t * Draw_CachePic(const char *path)
Definition gl_draw.c:185
void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, float red, float green, float blue, float alpha, int flags)
Definition gl_draw.c:797
GLint GLenum GLint GLint y
Definition glquake.h:651
GLint GLenum GLint x
Definition glquake.h:651
GLclampf GLclampf blue
Definition glquake.h:642
GLclampf green
Definition glquake.h:642

References alpha, blue, Draw_CachePic(), DrawQ_Pic(), flags, green, height, width, x, and y.

Referenced by CL_DrawVideo(), Con_DrawConsole(), M_Background(), M_Options_ColorControl_Draw(), M_Options_PrintCheckbox(), M_Options_PrintCommand(), M_Options_PrintSlider(), M_ServerList_Draw(), R_TimeReport_EndFrame(), Sbar_DrawFace(), Sbar_DrawFrags(), Sbar_PrintScoreboardItem(), Sbar_ShowFPS(), SCR_DrawCurlDownload(), SCR_DrawInfobarString(), SCR_DrawNetGraph_DrawGraph(), SCR_DrawQWDownload(), SCR_DrawTouchscreenOverlay(), and VM_drawfill().

◆ DrawQ_Finish()

void DrawQ_Finish ( void )

Definition at line 1456 of file gl_draw.c.

1457{
1458 DrawQ_FlushUI();
1460}
void DrawQ_FlushUI(void)
Definition gl_draw.c:1469
r_refdef_t r_refdef
Definition gl_rmain.c:57
int draw2dstage
Definition render.h:452

References r_refdef_t::draw2dstage, DrawQ_FlushUI(), and r_refdef.

Referenced by R_RenderView(), and SCR_DrawScreen().

◆ DrawQ_FlushUI()

void DrawQ_FlushUI ( void )

Definition at line 1469 of file gl_draw.c.

1470{
1471 model_t *mod = CL_Mesh_UI();
1472 if (mod->num_surfaces == 0)
1473 return;
1474
1476 {
1478 return;
1479 }
1480
1481 // this is roughly equivalent to R_Mod_Draw, so the UI can use full material feature set
1483 r_textureframe++; // used only by R_GetCurrentTexture
1484 GL_DepthMask(false);
1485
1487 R_DrawModelSurfaces(&cl_meshentities[MESH_UI].render, false, false, false, false, false, true);
1488
1490}
entity_t cl_meshentities[NUM_MESHENTITIES]
Definition cl_main.c:2513
#define CL_Mesh_UI()
Definition client.h:1372
@ MESH_UI
Definition client.h:1365
float mod(float dividend, float divisor)
void GL_DepthMask(int state)
qbool r_draw2d_force
Definition gl_draw.c:795
cvar_t r_draw2d
Definition gl_rmain.c:97
int r_textureframe
used only by R_GetCurrentTexture, incremented per view and per UI render
Definition gl_rmain.c:45
void R_DrawModelSurfaces(entity_render_t *ent, qbool skysurfaces, qbool writedepth, qbool depthonly, qbool debug, qbool prepass, qbool ui)
Definition gl_rmain.c:9970
void Mod_Mesh_Reset(model_t *mod)
void Mod_Mesh_Finalize(model_t *mod)
r_refdef_view_t view
Definition render.h:406
float colorscale
global RGB color multiplier for rendering
Definition render.h:302

References CL_Mesh_UI, cl_meshentities, r_refdef_view_t::colorscale, GL_DepthMask(), cvar_t::integer, MESH_UI, mod(), Mod_Mesh_Finalize(), Mod_Mesh_Reset(), r_draw2d, r_draw2d_force, R_DrawModelSurfaces(), r_refdef, r_textureframe, and r_refdef_t::view.

Referenced by DrawQ_Finish(), DrawQ_RecalcView(), DrawQ_ResetClipArea(), and DrawQ_SetClipArea().

◆ DrawQ_Line()

void DrawQ_Line ( float width,
float x1,
float y1,
float x2,
float y2,
float r,
float g,
float b,
float alpha,
int flags )

Definition at line 1402 of file gl_draw.c.

1403{
1404 model_t *mod = CL_Mesh_UI();
1405 msurface_t *surf;
1406 int e0, e1, e2, e3;
1407 float offsetx, offsety;
1408 // width is measured in real pixels
1409 if (fabs(x2 - x1) > fabs(y2 - y1))
1410 {
1411 offsetx = 0;
1412 offsety = 0.5f * width * vid_conheight.value / vid.mode.height;
1413 }
1414 else
1415 {
1416 offsetx = 0.5f * width * vid_conwidth.value / vid.mode.width;
1417 offsety = 0;
1418 }
1420 e0 = Mod_Mesh_IndexForVertex(mod, surf, x1 - offsetx, y1 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r, g, b, alpha);
1421 e1 = Mod_Mesh_IndexForVertex(mod, surf, x2 - offsetx, y2 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r, g, b, alpha);
1422 e2 = Mod_Mesh_IndexForVertex(mod, surf, x2 + offsetx, y2 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r, g, b, alpha);
1423 e3 = Mod_Mesh_IndexForVertex(mod, surf, x1 + offsetx, y1 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r, g, b, alpha);
1424 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
1425 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
1426}
cvar_t vid_conheight
Definition cl_screen.c:57
cvar_t vid_conwidth
Definition cl_screen.c:56
float fabs(float f)
#define MATERIALFLAG_VERTEXCOLOR
#define MATERIALFLAG_ALPHA
Definition model_brush.h:79
#define MATERIALFLAG_BLENDED
#define MATERIALFLAG_ALPHAGEN_VERTEX
#define MATERIALFLAG_WALL
Definition model_brush.h:89
#define MATERIALFLAG_NOSHADOW
msurface_t * Mod_Mesh_AddSurface(model_t *mod, texture_t *tex, qbool batchwithprevioussurface)
int Mod_Mesh_IndexForVertex(model_t *mod, msurface_t *surf, float x, float y, float z, float nx, float ny, float nz, float s, float t, float u, float v, float r, float g, float b, float a)
texture_t * Mod_Mesh_GetTexture(model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int defaultmaterialflags)
void Mod_Mesh_AddTriangle(model_t *mod, msurface_t *surf, int e0, int e1, int e2)
dp_FragColor r
dp_FragColor g
vec3 y2
vec3 x2
dp_FragColor b
vec3 x1
float value
Definition cvar.h:74
describes the textures to use on a range of triangles in the model, and mins/maxs (AABB) for culling.
int width
Definition vid.h:60
int height
Definition vid.h:61
viddef_mode_t mode
currently active video mode
Definition vid.h:73

References alpha, b, CL_Mesh_UI, fabs(), g, viddef_mode_t::height, MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_BLENDED, MATERIALFLAG_NOSHADOW, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_WALL, mod(), Mod_Mesh_AddSurface(), Mod_Mesh_AddTriangle(), Mod_Mesh_GetTexture(), Mod_Mesh_IndexForVertex(), viddef_t::mode, r, cvar_t::value, vid, vid_conheight, vid_conwidth, viddef_mode_t::width, width, x1, x2, and y2.

Referenced by R_TimeReport_EndFrame(), SCR_DrawNetGraph_DrawGraph(), and VM_drawline().

◆ DrawQ_Pic()

void DrawQ_Pic ( float x,
float y,
cachepic_t * pic,
float width,
float height,
float red,
float green,
float blue,
float alpha,
int flags )

Definition at line 797 of file gl_draw.c.

798{
800 msurface_t *surf;
801 int e0, e1, e2, e3;
802 if (!pic)
803 pic = Draw_CachePic("white");
804 // make sure pic is loaded - we don't use the texture here, Mod_Mesh_GetTexture looks up the skinframe by name
806 if (width == 0)
807 width = pic->width;
808 if (height == 0)
809 height = pic->height;
811 e0 = Mod_Mesh_IndexForVertex(mod, surf, x , y , 0, 0, 0, -1, 0, 0, 0, 0, red, green, blue, alpha);
812 e1 = Mod_Mesh_IndexForVertex(mod, surf, x + width, y , 0, 0, 0, -1, 1, 0, 0, 0, red, green, blue, alpha);
813 e2 = Mod_Mesh_IndexForVertex(mod, surf, x + width, y + height, 0, 0, 0, -1, 1, 1, 0, 0, red, green, blue, alpha);
814 e3 = Mod_Mesh_IndexForVertex(mod, surf, x , y + height, 0, 0, 0, -1, 0, 1, 0, 0, red, green, blue, alpha);
815 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
816 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
817}
rtexture_t * Draw_GetPicTexture(cachepic_t *pic)
Definition gl_draw.c:224

References alpha, blue, CL_Mesh_UI, Draw_CachePic(), Draw_GetPicTexture(), flags, green, height, MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_BLENDED, MATERIALFLAG_NOSHADOW, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_WALL, mod(), Mod_Mesh_AddSurface(), Mod_Mesh_AddTriangle(), Mod_Mesh_GetTexture(), Mod_Mesh_IndexForVertex(), width, x, and y.

Referenced by DrawQ_Fill(), M_Draw(), M_DrawPic(), M_ModList_Draw(), R_Shadow_EditLights_DrawSelectedLightProperties(), Sbar_DeathmatchOverlay(), Sbar_Draw(), Sbar_DrawAlphaPic(), Sbar_DrawPic(), Sbar_DrawStretchPic(), Sbar_DrawWeapon(), Sbar_DrawXNum(), Sbar_FinaleOverlay(), Sbar_IntermissionOverlay(), Sbar_Score(), SCR_DrawBrand(), SCR_DrawNet(), SCR_DrawPause(), SCR_DrawTouchscreenOverlay(), SCR_DrawTurtle(), SHOWLMP_drawall(), and VM_drawpic().

◆ DrawQ_RecalcView()

void DrawQ_RecalcView ( void )

Definition at line 1462 of file gl_draw.c.

1463{
1464 DrawQ_FlushUI();
1466 r_refdef.draw2dstage = -1; // next draw call will set viewport etc. again
1467}

References r_refdef_t::draw2dstage, DrawQ_FlushUI(), and r_refdef.

Referenced by VM_CL_R_SetView().

◆ DrawQ_ResetClipArea()

void DrawQ_ResetClipArea ( void )

Definition at line 1450 of file gl_draw.c.

1451{
1452 DrawQ_FlushUI();
1453 GL_ScissorTest(false);
1454}
void GL_ScissorTest(int state)

References DrawQ_FlushUI(), and GL_ScissorTest().

Referenced by VM_drawresetcliparea().

◆ DrawQ_RotPic()

void DrawQ_RotPic ( float x,
float y,
cachepic_t * pic,
float width,
float height,
float org_x,
float org_y,
float angle,
float red,
float green,
float blue,
float alpha,
int flags )

Definition at line 819 of file gl_draw.c.

820{
821 float af = DEG2RAD(-angle); // forward
822 float ar = DEG2RAD(-angle + 90); // right
823 float sinaf = sin(af);
824 float cosaf = cos(af);
825 float sinar = sin(ar);
826 float cosar = cos(ar);
828 msurface_t *surf;
829 int e0, e1, e2, e3;
830 if (!pic)
831 pic = Draw_CachePic("white");
832 // make sure pic is loaded - we don't use the texture here, Mod_Mesh_GetTexture looks up the skinframe by name
834 if (width == 0)
835 width = pic->width;
836 if (height == 0)
837 height = pic->height;
839 e0 = Mod_Mesh_IndexForVertex(mod, surf, x - cosaf * org_x - cosar * org_y , y - sinaf * org_x - sinar * org_y , 0, 0, 0, -1, 0, 0, 0, 0, red, green, blue, alpha);
840 e1 = Mod_Mesh_IndexForVertex(mod, surf, x + cosaf * (width - org_x) - cosar * org_y , y + sinaf * (width - org_x) - sinar * org_y , 0, 0, 0, -1, 1, 0, 0, 0, red, green, blue, alpha);
841 e2 = Mod_Mesh_IndexForVertex(mod, surf, x + cosaf * (width - org_x) + cosar * (height - org_y), y + sinaf * (width - org_x) + sinar * (height - org_y), 0, 0, 0, -1, 1, 1, 0, 0, red, green, blue, alpha);
842 e3 = Mod_Mesh_IndexForVertex(mod, surf, x - cosaf * org_x + cosar * (height - org_y), y - sinaf * org_x + sinar * (height - org_y), 0, 0, 0, -1, 0, 1, 0, 0, red, green, blue, alpha);
843 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
844 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
845}
#define DEG2RAD(a)
Definition mathlib.h:65
float cos(float f)
float sin(float f)

References alpha, blue, CL_Mesh_UI, cos(), DEG2RAD, Draw_CachePic(), Draw_GetPicTexture(), flags, green, height, MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_BLENDED, MATERIALFLAG_NOSHADOW, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_WALL, mod(), Mod_Mesh_AddSurface(), Mod_Mesh_AddTriangle(), Mod_Mesh_GetTexture(), Mod_Mesh_IndexForVertex(), sin(), width, x, and y.

Referenced by VM_drawrotpic().

◆ DrawQ_SetClipArea()

void DrawQ_SetClipArea ( float x,
float y,
float width,
float height )

Definition at line 1428 of file gl_draw.c.

1429{
1430 int ix, iy, iw, ih;
1431 DrawQ_FlushUI();
1432
1433 // We have to convert the con coords into real coords
1434 // OGL uses bottom to top (origin is in bottom left)
1435 ix = (int)(0.5 + x * ((float)r_refdef.view.width / vid_conwidth.integer)) + r_refdef.view.x;
1436 iy = (int)(0.5 + y * ((float)r_refdef.view.height / vid_conheight.integer)) + r_refdef.view.y;
1437 iw = (int)(0.5 + width * ((float)r_refdef.view.width / vid_conwidth.integer));
1438 ih = (int)(0.5 + height * ((float)r_refdef.view.height / vid_conheight.integer));
1439 switch(vid.renderpath)
1440 {
1441 case RENDERPATH_GL32:
1442 case RENDERPATH_GLES2:
1443 GL_Scissor(ix, vid.mode.height - iy - ih, iw, ih);
1444 break;
1445 }
1446
1447 GL_ScissorTest(true);
1448}
static int(ZEXPORT *qz_inflate)(z_stream *strm
void GL_Scissor(int x, int y, int width, int height)
renderpath_t renderpath
Definition vid.h:80
@ RENDERPATH_GLES2
Definition vid.h:38
@ RENDERPATH_GL32
Definition vid.h:37

References DrawQ_FlushUI(), GL_Scissor(), GL_ScissorTest(), height, r_refdef_view_t::height, viddef_mode_t::height, int(), cvar_t::integer, viddef_t::mode, r_refdef, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, vid, vid_conheight, vid_conwidth, r_refdef_t::view, r_refdef_view_t::width, width, r_refdef_view_t::x, x, r_refdef_view_t::y, and y.

Referenced by VM_drawsetcliparea().

◆ DrawQ_Start()

void DrawQ_Start ( void )

Definition at line 789 of file gl_draw.c.

790{
793}
void R_ResetViewRendering2D_Common(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight, float x2, float y2)
Definition gl_rmain.c:4439

References r_refdef_t::draw2dstage, viddef_mode_t::height, cvar_t::integer, viddef_t::mode, NULL, r_refdef, R_ResetViewRendering2D_Common(), vid, vid_conheight, vid_conwidth, and viddef_mode_t::width.

Referenced by R_RenderView(), and SCR_DrawScreen().

◆ DrawQ_String()

float DrawQ_String ( float x,
float y,
const char * text,
size_t maxlen,
float scalex,
float scaley,
float basered,
float basegreen,
float baseblue,
float basealpha,
int flags,
int * outcolor,
qbool ignorecolorcodes,
const dp_font_t * fnt )

Definition at line 1320 of file gl_draw.c.

1321{
1322 return DrawQ_String_Scale(startx, starty, text, maxlen, w, h, 1, 1, basered, basegreen, baseblue, basealpha, flags, outcolor, ignorecolorcodes, fnt);
1323}
float DrawQ_String_Scale(float startx, float starty, const char *text, size_t maxlen, float w, float h, float sw, float sh, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt)
Definition gl_draw.c:1085
GLubyte GLubyte GLubyte GLubyte w
Definition glquake.h:782

References DrawQ_String_Scale(), flags, and w.

Referenced by CL_DrawVideo_DisplaySubtitleLine(), Con_DisplayLineFunc(), Con_DrawConsole(), Con_DrawInput(), M_DrawCharacter(), M_ItemPrint(), M_Print(), M_PrintColored(), M_PrintRed(), R_Shadow_EditLights_DrawSelectedLightProperties(), R_TimeReport_EndFrame(), Sbar_DeathmatchOverlay(), Sbar_DrawCharacter(), Sbar_DrawString(), Sbar_DrawWeapon(), Sbar_PrintScoreboardItem(), Sbar_ShowFPS(), SCR_DrawCenterString(), SCR_DrawCurlDownload(), SCR_DrawInfobarString(), SCR_DrawLoadingStack_r(), SCR_DrawNetGraph_DrawGraph(), SCR_DrawQWDownload(), and SCR_DrawTouchscreenOverlay().

◆ DrawQ_String_Scale()

float DrawQ_String_Scale ( float x,
float y,
const char * text,
size_t maxlen,
float sizex,
float sizey,
float scalex,
float scaley,
float basered,
float basegreen,
float baseblue,
float basealpha,
int flags,
int * outcolor,
qbool ignorecolorcodes,
const dp_font_t * fnt )

Definition at line 1085 of file gl_draw.c.

1086{
1087 int shadow, colorindex = STRING_COLOR_DEFAULT;
1088 size_t i;
1089 float x = startx, y, s, t, u, v, thisw;
1090 Uchar ch, mapch, nextch;
1091 Uchar prevch = 0; // used for kerning
1092 int map_index = 0;
1093 ft2_font_map_t *map = NULL; // the currently used map
1094 ft2_font_map_t *fontmap = NULL; // the font map for the size
1095 float ftbase_y;
1096 const char *text_start = text;
1097 float kx, ky;
1098 ft2_font_t *ft2 = fnt->ft2;
1099 qbool snap = true;
1100 float pix_x, pix_y;
1101 size_t bytes_left;
1102 float dw, dh;
1103 const float *width_of;
1104 model_t *mod = CL_Mesh_UI();
1105 msurface_t *surf = NULL;
1106 int e0, e1, e2, e3;
1107 int tw, th;
1108 tw = Draw_GetPicWidth(fnt->pic);
1109 th = Draw_GetPicHeight(fnt->pic);
1110
1111 if (!h) h = w;
1112 if (!h) {
1113 h = w = 1;
1114 snap = false;
1115 }
1116
1117 starty -= (fnt->settings.scale - 1) * h * 0.5 - fnt->settings.voffset*h; // center & offset
1118 w *= fnt->settings.scale;
1119 h *= fnt->settings.scale;
1120
1121 if (ft2 != NULL)
1122 {
1123 if (snap)
1124 map_index = Font_IndexForSize(ft2, h, &w, &h);
1125 else
1126 map_index = Font_IndexForSize(ft2, h, NULL, NULL);
1127 fontmap = Font_MapForIndex(ft2, map_index);
1128 }
1129
1130 dw = w * sw;
1131 dh = h * sh;
1132
1133 // draw the font at its baseline when using freetype
1134 //ftbase_x = 0;
1135 ftbase_y = dh * (4.5/6.0);
1136
1137 if (maxlen < 1)
1138 maxlen = 1<<30;
1139
1141 return startx + DrawQ_TextWidth_UntilWidth_TrackColors_Scale(text, &maxlen, w, h, sw, sh, NULL, ignorecolorcodes, fnt, 1000000000);
1142
1143 //ftbase_x = snap_to_pixel_x(ftbase_x);
1144 if(snap)
1145 {
1146 startx = snap_to_pixel_x(startx, 0.4);
1147 starty = snap_to_pixel_y(starty, 0.4);
1148 ftbase_y = snap_to_pixel_y(ftbase_y, 0.3);
1149 }
1150
1151 pix_x = vid.mode.width / vid_conwidth.value;
1152 pix_y = vid.mode.height / vid_conheight.value;
1153
1154 if (fontmap)
1155 width_of = fnt->width_of_ft2[map_index];
1156 else
1157 width_of = fnt->width_of;
1158
1159 for (shadow = r_textshadow.value != 0 && basealpha > 0;shadow >= 0;shadow--)
1160 {
1161 prevch = 0;
1162 text = text_start;
1163
1164 if (!outcolor || *outcolor == -1)
1165 colorindex = STRING_COLOR_DEFAULT;
1166 else
1167 colorindex = *outcolor;
1168
1169 DrawQ_GetTextColor(DrawQ_Color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
1170
1171 x = startx;
1172 y = starty;
1173 /*
1174 if (shadow)
1175 {
1176 x += r_textshadow.value * vid.width / vid_conwidth.value;
1177 y += r_textshadow.value * vid.height / vid_conheight.value;
1178 }
1179 */
1180 while (((bytes_left = maxlen - (text - text_start)) > 0) && *text)
1181 {
1182 nextch = ch = u8_getnchar(text, &text, bytes_left);
1183 i = text - text_start;
1184 if (!ch)
1185 break;
1186 if (ch == ' ' && !fontmap)
1187 {
1188 x += width_of[(int) ' '] * dw;
1189 continue;
1190 }
1191 if (ch == STRING_COLOR_TAG && !ignorecolorcodes && i < maxlen)
1192 {
1193 ch = *text; // colors are ascii, so no u8_ needed
1194 if (ch <= '9' && ch >= '0') // ^[0-9] found
1195 {
1196 colorindex = ch - '0';
1197 DrawQ_GetTextColor(DrawQ_Color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
1198 ++text;
1199 ++i;
1200 continue;
1201 }
1202 else if (ch == STRING_COLOR_RGB_TAG_CHAR && i+3 < maxlen ) // ^x found
1203 {
1204 const char *text_p = &text[1];
1205 int tempcolorindex = RGBstring_to_colorindex(text_p);
1206 if(tempcolorindex)
1207 {
1208 colorindex = tempcolorindex;
1209 DrawQ_GetTextColor(DrawQ_Color, colorindex, basered, basegreen, baseblue, basealpha, shadow != 0);
1210 i+=4;
1211 text+=4;
1212 continue;
1213 }
1214 }
1215 else if (ch == STRING_COLOR_TAG)
1216 {
1217 i++;
1218 text++;
1219 }
1220 i--;
1221 }
1222 // get the backup
1223 ch = nextch;
1224 // using a value of -1 for the oldstyle map because NULL means uninitialized...
1225 // this way we don't need to rebind fnt->tex for every old-style character
1226 // E000..E0FF: emulate old-font characters (to still have smileys and such available)
1227 if (shadow)
1228 {
1229 x += 1.0/pix_x * r_textshadow.value;
1230 y += 1.0/pix_y * r_textshadow.value;
1231 }
1232 if (!fontmap || (ch <= 0xFF && fontmap->glyphs[ch].image) || (ch >= 0xE000 && ch <= 0xE0FF))
1233 {
1234 if (ch >= 0xE000)
1235 ch -= 0xE000;
1236 if (ch > 0xFF)
1237 goto out;
1238 if (fontmap)
1239 map = ft2_oldstyle_map;
1240 prevch = 0;
1241 //num = (unsigned char) text[i];
1242 //thisw = fnt->width_of[num];
1243 thisw = fnt->width_of[ch];
1244 // FIXME make these smaller to just include the occupied part of the character for slightly faster rendering
1246 {
1247 s = (ch & 15)*0.0625f;
1248 t = (ch >> 4)*0.0625f;
1249 u = 0.0625f * thisw;
1250 v = 0.0625f;
1251 }
1252 else
1253 {
1254 s = (ch & 15)*0.0625f + (0.5f / tw);
1255 t = (ch >> 4)*0.0625f + (0.5f / th);
1256 u = 0.0625f * thisw - (1.0f / tw);
1257 v = 0.0625f - (1.0f / th);
1258 }
1260 e0 = Mod_Mesh_IndexForVertex(mod, surf, x , y , 10, 0, 0, -1, s , t , 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
1261 e1 = Mod_Mesh_IndexForVertex(mod, surf, x+dw*thisw, y , 10, 0, 0, -1, s+u, t , 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
1262 e2 = Mod_Mesh_IndexForVertex(mod, surf, x+dw*thisw, y+dh, 10, 0, 0, -1, s+u, t+v, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
1263 e3 = Mod_Mesh_IndexForVertex(mod, surf, x , y+dh, 10, 0, 0, -1, s , t+v, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
1264 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
1265 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
1266 x += width_of[ch] * dw;
1267 } else {
1268 if (!map || map == ft2_oldstyle_map || ch != prevch)
1269 {
1270 Font_GetMapForChar(ft2, map_index, ch, &map, &mapch);
1271 if (!map)
1272 {
1273 shadow = -1;
1274 break;
1275 }
1276 }
1277
1278 thisw = map->glyphs[mapch].advance_x;
1279
1280 //x += ftbase_x;
1281 y += ftbase_y;
1282 if (prevch && Font_GetKerningForMap(ft2, map_index, w, h, prevch, ch, &kx, &ky))
1283 {
1284 x += kx * dw;
1285 y += ky * dh;
1286 }
1287 else
1288 kx = ky = 0;
1290 e0 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmin, y + dh * map->glyphs[mapch].vymin, 10, 0, 0, -1, map->glyphs[mapch].txmin, map->glyphs[mapch].tymin, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
1291 e1 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmax, y + dh * map->glyphs[mapch].vymin, 10, 0, 0, -1, map->glyphs[mapch].txmax, map->glyphs[mapch].tymin, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
1292 e2 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmax, y + dh * map->glyphs[mapch].vymax, 10, 0, 0, -1, map->glyphs[mapch].txmax, map->glyphs[mapch].tymax, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
1293 e3 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmin, y + dh * map->glyphs[mapch].vymax, 10, 0, 0, -1, map->glyphs[mapch].txmin, map->glyphs[mapch].tymax, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
1294 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
1295 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
1296 //x -= ftbase_x;
1297 y -= ftbase_y;
1298
1299 x += thisw * dw;
1300
1301 //prevmap = map;
1302 prevch = ch;
1303 }
1304out:
1305 if (shadow)
1306 {
1307 x -= 1.0/pix_x * r_textshadow.value;
1308 y -= 1.0/pix_y * r_textshadow.value;
1309 }
1310 }
1311 }
1312
1313 if (outcolor)
1314 *outcolor = colorindex;
1315
1316 // note: this relies on the proper text (not shadow) being drawn last
1317 return x;
1318}
#define STRING_COLOR_RGB_TAG_CHAR
Definition draw.h:143
#define STRING_COLOR_DEFAULT
Definition draw.h:141
#define STRING_COLOR_TAG
Definition draw.h:140
ft2_font_map_t * Font_MapForIndex(ft2_font_t *font, int index)
Definition ft2.c:1052
qbool Font_GetKerningForMap(ft2_font_t *font, int map_index, float w, float h, Uchar left, Uchar right, float *outx, float *outy)
Definition ft2.c:1085
int Font_IndexForSize(ft2_font_t *font, float _fsize, float *outw, float *outh)
Definition ft2.c:999
qbool Font_GetMapForChar(ft2_font_t *font, int map_index, Uchar ch, ft2_font_map_t **outmap, int *outmapch)
Query for or load a font map for a character, with the character's place on it.
Definition ft2.c:1971
#define ft2_oldstyle_map
Definition ft2.h:30
static void DrawQ_GetTextColor(float color[4], int colorindex, float r, float g, float b, float a, qbool shadow)
Definition gl_draw.c:883
float DrawQ_Color[4]
Definition gl_draw.c:1084
static int RGBstring_to_colorindex(const char *str)
Definition gl_draw.c:906
cvar_t r_textshadow
Definition gl_draw.c:53
int Draw_GetPicWidth(cachepic_t *pic)
Definition gl_draw.c:197
static float snap_to_pixel_x(float x, float roundUpAt)
Definition gl_draw.c:518
static float snap_to_pixel_y(float y, float roundUpAt)
Definition gl_draw.c:531
cvar_t r_nearest_conchars
Definition gl_draw.c:67
int Draw_GetPicHeight(cachepic_t *pic)
Definition gl_draw.c:204
float DrawQ_TextWidth_UntilWidth_TrackColors_Scale(const char *text, size_t *maxlen, float w, float h, float sw, float sh, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt, float maxwidth)
Definition gl_draw.c:928
const GLdouble * v
Definition glquake.h:762
bool qbool
Definition qtypes.h:9
vec4 sw
struct ft2_font_s * ft2
Definition draw.h:110
float width_of[256]
Definition draw.h:100
ft2_settings_t settings
Definition draw.h:112
float width_of_ft2[MAX_FONT_SIZES][256]
Definition draw.h:101
cachepic_t * pic
Definition draw.h:99
float scale
Definition draw.h:88
float voffset
Definition draw.h:88
#define u8_getnchar(c, e, n)
Definition utf8lib.h:74
int32_t Uchar
Definition utf8lib.h:35

References CL_Mesh_UI, Draw_GetPicHeight(), Draw_GetPicWidth(), DrawQ_Color, DrawQ_GetTextColor(), DrawQ_TextWidth_UntilWidth_TrackColors_Scale(), flags, Font_GetKerningForMap(), Font_GetMapForChar(), Font_IndexForSize(), Font_MapForIndex(), dp_font_t::ft2, ft2_oldstyle_map, viddef_mode_t::height, i, int(), cvar_t::integer, MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_BLENDED, MATERIALFLAG_NOSHADOW, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_WALL, mod(), Mod_Mesh_AddSurface(), Mod_Mesh_AddTriangle(), Mod_Mesh_GetTexture(), Mod_Mesh_IndexForVertex(), viddef_t::mode, NULL, dp_font_t::pic, r_draw2d, r_draw2d_force, r_nearest_conchars, r_textshadow, RGBstring_to_colorindex(), ft2_settings_t::scale, dp_font_t::settings, snap_to_pixel_x(), snap_to_pixel_y(), STRING_COLOR_DEFAULT, STRING_COLOR_RGB_TAG_CHAR, STRING_COLOR_TAG, sw, TEXF_ALPHA, TEXF_CLAMP, u8_getnchar, v, cvar_t::value, vid, vid_conheight, vid_conwidth, ft2_settings_t::voffset, w, viddef_mode_t::width, dp_font_t::width_of, dp_font_t::width_of_ft2, x, and y.

Referenced by DrawQ_String(), VM_drawcharacter(), VM_drawcolorcodedstring(), and VM_drawstring().

◆ DrawQ_SuperPic()

void DrawQ_SuperPic ( float x,
float y,
cachepic_t * pic,
float width,
float height,
float s1,
float t1,
float r1,
float g1,
float b1,
float a1,
float s2,
float t2,
float r2,
float g2,
float b2,
float a2,
float s3,
float t3,
float r3,
float g3,
float b3,
float a3,
float s4,
float t4,
float r4,
float g4,
float b4,
float a4,
int flags )

Definition at line 1380 of file gl_draw.c.

1381{
1382 model_t *mod = CL_Mesh_UI();
1383 msurface_t *surf;
1384 int e0, e1, e2, e3;
1385 if (!pic)
1386 pic = Draw_CachePic("white");
1387 // make sure pic is loaded - we don't use the texture here, Mod_Mesh_GetTexture looks up the skinframe by name
1388 Draw_GetPicTexture(pic);
1389 if (width == 0)
1390 width = pic->width;
1391 if (height == 0)
1392 height = pic->height;
1394 e0 = Mod_Mesh_IndexForVertex(mod, surf, x , y , 0, 0, 0, -1, s1, t1, 0, 0, r1, g1, b1, a1);
1395 e1 = Mod_Mesh_IndexForVertex(mod, surf, x + width, y , 0, 0, 0, -1, s2, t2, 0, 0, r2, g2, b2, a2);
1396 e2 = Mod_Mesh_IndexForVertex(mod, surf, x + width, y + height, 0, 0, 0, -1, s4, t4, 0, 0, r4, g4, b4, a4);
1397 e3 = Mod_Mesh_IndexForVertex(mod, surf, x , y + height, 0, 0, 0, -1, s3, t3, 0, 0, r3, g3, b3, a3);
1398 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
1399 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
1400}

References CL_Mesh_UI, Draw_CachePic(), Draw_GetPicTexture(), flags, height, MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_BLENDED, MATERIALFLAG_NOSHADOW, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_WALL, mod(), Mod_Mesh_AddSurface(), Mod_Mesh_AddTriangle(), Mod_Mesh_GetTexture(), Mod_Mesh_IndexForVertex(), width, x, and y.

Referenced by CL_DrawVideo(), Con_DrawConsole(), M_Options_ColorControl_Draw(), Sbar_Draw(), Sbar_DrawGauge(), and VM_drawsubpic().

◆ DrawQ_TextWidth()

float DrawQ_TextWidth ( const char * text,
size_t maxlen,
float w,
float h,
qbool ignorecolorcodes,
const dp_font_t * fnt )

Definition at line 1330 of file gl_draw.c.

1331{
1332 return DrawQ_TextWidth_UntilWidth(text, &maxlen, w, h, ignorecolorcodes, fnt, 1000000000);
1333}
float DrawQ_TextWidth_UntilWidth(const char *text, size_t *maxlen, float w, float h, qbool ignorecolorcodes, const dp_font_t *fnt, float maxWidth)
Definition gl_draw.c:1335

References DrawQ_TextWidth_UntilWidth(), and w.

Referenced by CL_DrawVideo_WordWidthFunc(), Con_DrawConsole(), Con_DrawInput(), Con_WordWidthFunc(), Sbar_ShowFPS(), SCR_DrawCenterString(), SCR_DrawCurlDownload(), SCR_DrawInfobarString(), SCR_DrawLoadingStack_r(), SCR_DrawQWDownload(), and SCR_DrawTouchscreenOverlay().

◆ DrawQ_TextWidth_UntilWidth()

float DrawQ_TextWidth_UntilWidth ( const char * text,
size_t * maxlen,
float w,
float h,
qbool ignorecolorcodes,
const dp_font_t * fnt,
float maxWidth )

Definition at line 1335 of file gl_draw.c.

1336{
1337 return DrawQ_TextWidth_UntilWidth_TrackColors(text, maxlen, w, h, NULL, ignorecolorcodes, fnt, maxWidth);
1338}
float DrawQ_TextWidth_UntilWidth_TrackColors(const char *text, size_t *maxlen, float w, float h, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt, float maxwidth)
Definition gl_draw.c:1325

References DrawQ_TextWidth_UntilWidth_TrackColors(), NULL, and w.

Referenced by CL_DrawVideo_WordWidthFunc(), Con_WordWidthFunc(), and DrawQ_TextWidth().

◆ DrawQ_TextWidth_UntilWidth_TrackColors()

float DrawQ_TextWidth_UntilWidth_TrackColors ( const char * text,
size_t * maxlen,
float w,
float h,
int * outcolor,
qbool ignorecolorcodes,
const dp_font_t * fnt,
float maxwidth )

Definition at line 1325 of file gl_draw.c.

1326{
1327 return DrawQ_TextWidth_UntilWidth_TrackColors_Scale(text, maxlen, w, h, 1, 1, outcolor, ignorecolorcodes, fnt, maxwidth);
1328}

References DrawQ_TextWidth_UntilWidth_TrackColors_Scale(), and w.

Referenced by Con_DrawInput(), and DrawQ_TextWidth_UntilWidth().

◆ DrawQ_TextWidth_UntilWidth_TrackColors_Scale()

float DrawQ_TextWidth_UntilWidth_TrackColors_Scale ( const char * text,
size_t * maxlen,
float w,
float h,
float sw,
float sh,
int * outcolor,
qbool ignorecolorcodes,
const dp_font_t * fnt,
float maxwidth )

Definition at line 928 of file gl_draw.c.

929{
930 const char *text_start = text;
931 int colorindex;
932 size_t i;
933 float x = 0;
934 Uchar ch, mapch, nextch;
935 Uchar prevch = 0; // used for kerning
936 float kx;
937 int map_index = 0;
938 size_t bytes_left;
939 ft2_font_map_t *fontmap = NULL;
940 ft2_font_map_t *map = NULL;
941 ft2_font_t *ft2 = fnt->ft2;
942 // float ftbase_x;
943 qbool snap = true;
944 qbool least_one = false;
945 float dw; // display w
946 //float dh; // display h
947 const float *width_of;
948
949 if (!h) h = w;
950 if (!h) {
951 w = h = 1;
952 snap = false;
953 }
954 // do this in the end
955 w *= fnt->settings.scale;
956 h *= fnt->settings.scale;
957
958 // find the most fitting size:
959 if (ft2 != NULL)
960 {
961 if (snap)
962 map_index = Font_IndexForSize(ft2, h, &w, &h);
963 else
964 map_index = Font_IndexForSize(ft2, h, NULL, NULL);
965 fontmap = Font_MapForIndex(ft2, map_index);
966 }
967
968 dw = w * sw;
969 //dh = h * sh;
970
971 if (*maxlen < 1)
972 *maxlen = 1<<30;
973
974 if (!outcolor || *outcolor == -1)
975 colorindex = STRING_COLOR_DEFAULT;
976 else
977 colorindex = *outcolor;
978
979 // maxwidth /= fnt->scale; // w and h are multiplied by it already
980 // ftbase_x = snap_to_pixel_x(0);
981
982 if(maxwidth <= 0)
983 {
984 least_one = true;
985 maxwidth = -maxwidth;
986 }
987
988 //if (snap)
989 // x = snap_to_pixel_x(x, 0.4); // haha, it's 0 anyway
990
991 if (fontmap)
992 width_of = fnt->width_of_ft2[map_index];
993 else
994 width_of = fnt->width_of;
995
996 i = 0;
997 while (((bytes_left = *maxlen - (text - text_start)) > 0) && *text)
998 {
999 size_t i0 = i;
1000 nextch = ch = u8_getnchar(text, &text, bytes_left);
1001 i = text - text_start;
1002 if (!ch)
1003 break;
1004 if (ch == ' ' && !fontmap)
1005 {
1006 if(!least_one || i0) // never skip the first character
1007 if(x + width_of[(int) ' '] * dw > maxwidth)
1008 {
1009 i = i0;
1010 break; // oops, can't draw this
1011 }
1012 x += width_of[(int) ' '] * dw;
1013 continue;
1014 }
1015 if (ch == STRING_COLOR_TAG && !ignorecolorcodes && i < *maxlen)
1016 {
1017 ch = *text; // colors are ascii, so no u8_ needed
1018 if (ch <= '9' && ch >= '0') // ^[0-9] found
1019 {
1020 colorindex = ch - '0';
1021 ++text;
1022 ++i;
1023 continue;
1024 }
1025 else if (ch == STRING_COLOR_RGB_TAG_CHAR && i + 3 < *maxlen ) // ^x found
1026 {
1027 const char *text_p = &text[1];
1028 int tempcolorindex = RGBstring_to_colorindex(text_p);
1029 if (tempcolorindex)
1030 {
1031 colorindex = tempcolorindex;
1032 i+=4;
1033 text += 4;
1034 continue;
1035 }
1036 }
1037 else if (ch == STRING_COLOR_TAG) // ^^ found
1038 {
1039 i++;
1040 text++;
1041 }
1042 i--;
1043 }
1044 ch = nextch;
1045
1046 if (!fontmap || (ch <= 0xFF && fontmap->glyphs[ch].image) || (ch >= 0xE000 && ch <= 0xE0FF))
1047 {
1048 if (ch > 0xE000)
1049 ch -= 0xE000;
1050 if (ch > 0xFF)
1051 continue;
1052 if (fontmap)
1053 map = ft2_oldstyle_map;
1054 prevch = 0;
1055 if(!least_one || i0) // never skip the first character
1056 if(x + width_of[ch] * dw > maxwidth)
1057 {
1058 i = i0;
1059 break; // oops, can't draw this
1060 }
1061 x += width_of[ch] * dw;
1062 } else {
1063 if (!map || map == ft2_oldstyle_map || ch != prevch)
1064 {
1065 Font_GetMapForChar(ft2, map_index, ch, &map, &mapch);
1066 if (!map)
1067 break;
1068 }
1069 if (prevch && Font_GetKerningForMap(ft2, map_index, w, h, prevch, ch, &kx, NULL))
1070 x += kx * dw;
1071 x += map->glyphs[mapch].advance_x * dw;
1072 prevch = ch;
1073 }
1074 }
1075
1076 *maxlen = i;
1077
1078 if (outcolor)
1079 *outcolor = colorindex;
1080
1081 return x;
1082}

References Font_GetKerningForMap(), Font_GetMapForChar(), Font_IndexForSize(), Font_MapForIndex(), dp_font_t::ft2, ft2_oldstyle_map, i, int(), NULL, RGBstring_to_colorindex(), ft2_settings_t::scale, dp_font_t::settings, STRING_COLOR_DEFAULT, STRING_COLOR_RGB_TAG_CHAR, STRING_COLOR_TAG, sw, u8_getnchar, w, dp_font_t::width_of, dp_font_t::width_of_ft2, and x.

Referenced by DrawQ_String_Scale(), DrawQ_TextWidth_UntilWidth_TrackColors(), and VM_stringwidth().

Variable Documentation

◆ dp_fonts

◆ DrawQ_Color

float DrawQ_Color[4]
extern

Definition at line 1084 of file gl_draw.c.

Referenced by DrawQ_String_Scale(), and VM_drawcolorcodedstring().

◆ drawtexturepool

rtexturepool_t* drawtexturepool
extern

Definition at line 76 of file gl_draw.c.

Referenced by gl_draw_shutdown(), gl_draw_start(), and LoadFont().

◆ string_colors

const vec4_t string_colors[]
extern

color tag printing

Definition at line 853 of file gl_draw.c.

854{
855 // Quake3 colors
856 // LadyHavoc: why on earth is cyan before magenta in Quake3?
857 // LadyHavoc: note: Doom3 uses white for [0] and [7]
858 {0.0, 0.0, 0.0, 1.0}, // black
859 {1.0, 0.0, 0.0, 1.0}, // red
860 {0.0, 1.0, 0.0, 1.0}, // green
861 {1.0, 1.0, 0.0, 1.0}, // yellow
862 //{0.0, 0.0, 1.0, 1.0}, // blue
863 {0.05, 0.15, 1.0, 1.0}, // lighter blue, readable unlike the above
864 {0.0, 1.0, 1.0, 1.0}, // cyan
865 {1.0, 0.0, 1.0, 1.0}, // magenta
866 {1.0, 1.0, 1.0, 1.0}, // white
867 // [515]'s BX_COLOREDTEXT extension
868 {1.0, 1.0, 1.0, 0.5}, // half transparent
869 {0.5, 0.5, 0.5, 1.0} // half brightness
870 // Black's color table
871 //{1.0, 1.0, 1.0, 1.0},
872 //{1.0, 0.0, 0.0, 1.0},
873 //{0.0, 1.0, 0.0, 1.0},
874 //{0.0, 0.0, 1.0, 1.0},
875 //{1.0, 1.0, 0.0, 1.0},
876 //{0.0, 1.0, 1.0, 1.0},
877 //{1.0, 0.0, 1.0, 1.0},
878 //{0.1, 0.1, 0.1, 1.0}
879};

Referenced by Con_MaskPrint(), and DrawQ_GetTextColor().