[renderer] Add fontid to Draw_AddFont and Draw_FontString

It's not used yet, but the vulkan draw implementation will eventually
support multiple fonts being loaded (and rendered at a time).
This commit is contained in:
Bill Currie 2022-10-03 08:58:27 +09:00
parent 0352af4542
commit 51b73eee73
11 changed files with 33 additions and 26 deletions

View file

@ -57,8 +57,8 @@ void gl_Draw_Pic (int x, int y, struct qpic_s *pic);
void gl_Draw_Picf (float x, float y, struct qpic_s *pic); void gl_Draw_Picf (float x, float y, struct qpic_s *pic);
void gl_Draw_SubPic(int x, int y, struct qpic_s *pic, void gl_Draw_SubPic(int x, int y, struct qpic_s *pic,
int srcx, int srcy, int width, int height); int srcx, int srcy, int width, int height);
void gl_Draw_AddFont (struct rfont_s *font); int gl_Draw_AddFont (struct rfont_s *font);
void gl_Draw_FontString (int x, int y, const char *str); void gl_Draw_FontString (int x, int y, int fontid, const char *str);
void GL_Set2D (void); void GL_Set2D (void);
void GL_Set2DScaled (void); void GL_Set2DScaled (void);

View file

@ -57,8 +57,8 @@ void glsl_Draw_Pic (int x, int y, struct qpic_s *pic);
void glsl_Draw_Picf (float x, float y, struct qpic_s *pic); void glsl_Draw_Picf (float x, float y, struct qpic_s *pic);
void glsl_Draw_SubPic(int x, int y, struct qpic_s *pic, void glsl_Draw_SubPic(int x, int y, struct qpic_s *pic,
int srcx, int srcy, int width, int height); int srcx, int srcy, int width, int height);
void glsl_Draw_AddFont (struct rfont_s *font); int glsl_Draw_AddFont (struct rfont_s *font);
void glsl_Draw_FontString (int x, int y, const char *str); void glsl_Draw_FontString (int x, int y, int fontid, const char *str);
void GLSL_Set2D (void); void GLSL_Set2D (void);
void GLSL_Set2DScaled (void); void GLSL_Set2DScaled (void);

View file

@ -75,8 +75,8 @@ void Vulkan_Draw_Picf (float x, float y, struct qpic_s *pic,
void Vulkan_Draw_SubPic(int x, int y, struct qpic_s *pic, void Vulkan_Draw_SubPic(int x, int y, struct qpic_s *pic,
int srcx, int srcy, int width, int height, int srcx, int srcy, int width, int height,
struct vulkan_ctx_s *ctx); struct vulkan_ctx_s *ctx);
void Vulkan_Draw_AddFont (struct rfont_s *font, struct vulkan_ctx_s *ctx); int Vulkan_Draw_AddFont (struct rfont_s *font, struct vulkan_ctx_s *ctx);
void Vulkan_Draw_FontString (int x, int y, const char *str, void Vulkan_Draw_FontString (int x, int y, int fontid, const char *str,
struct vulkan_ctx_s *ctx); struct vulkan_ctx_s *ctx);
void Vulkan_Set2D (struct vulkan_ctx_s *ctx); void Vulkan_Set2D (struct vulkan_ctx_s *ctx);

View file

@ -265,8 +265,8 @@ void Draw_Picf (float x, float y, qpic_t *pic);
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height); void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
struct rfont_s; struct rfont_s;
void Draw_AddFont (struct rfont_s *font); int Draw_AddFont (struct rfont_s *font);
void Draw_FontString (int x, int y, const char *str); void Draw_FontString (int x, int y, int fontid, const char *str);
///@} ///@}

View file

@ -107,8 +107,8 @@ typedef struct vid_render_funcs_s {
void (*Draw_Pic) (int x, int y, qpic_t *pic); void (*Draw_Pic) (int x, int y, qpic_t *pic);
void (*Draw_Picf) (float x, float y, qpic_t *pic); void (*Draw_Picf) (float x, float y, qpic_t *pic);
void (*Draw_SubPic) (int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height); void (*Draw_SubPic) (int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
void (*Draw_AddFont) (struct rfont_s *font); int (*Draw_AddFont) (struct rfont_s *font);
void (*Draw_FontString) (int x, int y, const char *str); void (*Draw_FontString) (int x, int y, int fontid, const char *str);
struct psystem_s *(*ParticleSystem) (void); struct psystem_s *(*ParticleSystem) (void);

View file

@ -1037,12 +1037,13 @@ gl_Draw_BlendScreen (quat_t color)
qfglEnable (GL_TEXTURE_2D); qfglEnable (GL_TEXTURE_2D);
} }
void int
gl_Draw_AddFont (struct rfont_s *font) gl_Draw_AddFont (struct rfont_s *font)
{ {
return 0;
} }
void void
gl_Draw_FontString (int x, int y, const char *str) gl_Draw_FontString (int x, int y, int fontid, const char *str)
{ {
} }

View file

@ -860,12 +860,13 @@ glsl_Draw_BlendScreen (quat_t color)
draw_blendscreen (color); draw_blendscreen (color);
} }
void int
glsl_Draw_AddFont (struct rfont_s *font) glsl_Draw_AddFont (struct rfont_s *font)
{ {
return 0;
} }
void void
glsl_Draw_FontString (int x, int y, const char *str) glsl_Draw_FontString (int x, int y, int fontid, const char *str)
{ {
} }

View file

@ -390,7 +390,7 @@ bi_Font_Load (progs_t *pr, void *_res)
QFile *font_file = QFS_FOpenFile (font_path); QFile *font_file = QFS_FOpenFile (font_path);
rfont_t *font = R_FontLoad (font_file, font_size); rfont_t *font = R_FontLoad (font_file, font_size);
r_funcs->Draw_AddFont (font); R_INT (pr) = r_funcs->Draw_AddFont (font);
} }
static void static void
@ -398,8 +398,9 @@ bi_Font_String (progs_t *pr, void *_res)
{ {
int x = P_INT (pr, 0); int x = P_INT (pr, 0);
int y = P_INT (pr, 1); int y = P_INT (pr, 1);
const char *str = P_GSTRING (pr, 2); int fontid = P_INT (pr, 2);
r_funcs->Draw_FontString (x, y, str); const char *str = P_GSTRING (pr, 3);
r_funcs->Draw_FontString (x, y, fontid, str);
} }
static void static void
@ -531,7 +532,7 @@ static builtin_t builtins[] = {
bi(Draw_Crosshair, 5, p(int), p(int), p(int), p(int)), bi(Draw_Crosshair, 5, p(int), p(int), p(int), p(int)),
bi(Font_Load, 2, p(string), p(int)), bi(Font_Load, 2, p(string), p(int)),
bi(Font_String, 3, p(int), p(int), p(string)), bi(Font_String, 4, p(int), p(int), p(int), p(string)),
bi(Draw_CreateBuffer, 2, p(int), p(int)), bi(Draw_CreateBuffer, 2, p(int), p(int)),
bi(Draw_DestroyBuffer, 1, p(ptr)), bi(Draw_DestroyBuffer, 1, p(ptr)),

View file

@ -987,12 +987,13 @@ Draw_BlendScreen (quat_t color)
vid.vid_internal->set_palette (vid.vid_internal->data, pal); vid.vid_internal->set_palette (vid.vid_internal->data, pal);
} }
void int
Draw_AddFont (struct rfont_s *font) Draw_AddFont (struct rfont_s *font)
{ {
return 0;
} }
void void
Draw_FontString (int x, int y, const char *str) Draw_FontString (int x, int y, int fontid, const char *str)
{ {
} }

View file

@ -270,16 +270,16 @@ vulkan_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, in
Vulkan_Draw_SubPic (x, y, pic, srcx, srcy, width, height, vulkan_ctx); Vulkan_Draw_SubPic (x, y, pic, srcx, srcy, width, height, vulkan_ctx);
} }
static void static int
vulkan_Draw_AddFont (struct rfont_s *font) vulkan_Draw_AddFont (struct rfont_s *font)
{ {
Vulkan_Draw_AddFont (font, vulkan_ctx); return Vulkan_Draw_AddFont (font, vulkan_ctx);
} }
static void static void
vulkan_Draw_FontString (int x, int y, const char *str) vulkan_Draw_FontString (int x, int y, int fontid, const char *str)
{ {
Vulkan_Draw_FontString (x, y, str, vulkan_ctx); Vulkan_Draw_FontString (x, y, fontid, str, vulkan_ctx);
} }
static void static void

View file

@ -1074,7 +1074,7 @@ Vulkan_Draw_BlendScreen (quat_t color, vulkan_ctx_t *ctx)
} }
} }
void int
Vulkan_Draw_AddFont (rfont_t *font, vulkan_ctx_t *ctx) Vulkan_Draw_AddFont (rfont_t *font, vulkan_ctx_t *ctx)
{ {
drawctx_t *dctx = ctx->draw_context; drawctx_t *dctx = ctx->draw_context;
@ -1094,6 +1094,8 @@ Vulkan_Draw_AddFont (rfont_t *font, vulkan_ctx_t *ctx)
}; };
dctx->font_tex = Vulkan_LoadTex (ctx, &tex, 0, "draw.font"); dctx->font_tex = Vulkan_LoadTex (ctx, &tex, 0, "draw.font");
} }
return 0;
} }
typedef struct { typedef struct {
@ -1115,7 +1117,8 @@ vulkan_render_glyph (rglyph_t *glyph, int x, int y, void *_rgctx)
} }
void void
Vulkan_Draw_FontString (int x, int y, const char *str, vulkan_ctx_t *ctx) Vulkan_Draw_FontString (int x, int y, int fontid, const char *str,
vulkan_ctx_t *ctx)
{ {
drawctx_t *dctx = ctx->draw_context; drawctx_t *dctx = ctx->draw_context;
if (!dctx->font) { if (!dctx->font) {