From 51b73eee73c1e563cf7cd99314f74ebeb8759f33 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 3 Oct 2022 08:58:27 +0900 Subject: [PATCH] [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). --- include/QF/GL/qf_draw.h | 4 ++-- include/QF/GLSL/qf_draw.h | 4 ++-- include/QF/Vulkan/qf_draw.h | 4 ++-- include/QF/draw.h | 4 ++-- include/QF/plugin/vid_render.h | 4 ++-- libs/video/renderer/gl/gl_draw.c | 5 +++-- libs/video/renderer/glsl/glsl_draw.c | 5 +++-- libs/video/renderer/r_progs.c | 9 +++++---- libs/video/renderer/sw/draw.c | 5 +++-- libs/video/renderer/vid_render_vulkan.c | 8 ++++---- libs/video/renderer/vulkan/vulkan_draw.c | 7 +++++-- 11 files changed, 33 insertions(+), 26 deletions(-) diff --git a/include/QF/GL/qf_draw.h b/include/QF/GL/qf_draw.h index 7a7283c5c..ff7b9a30a 100644 --- a/include/QF/GL/qf_draw.h +++ b/include/QF/GL/qf_draw.h @@ -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_SubPic(int x, int y, struct qpic_s *pic, int srcx, int srcy, int width, int height); -void gl_Draw_AddFont (struct rfont_s *font); -void gl_Draw_FontString (int x, int y, const char *str); +int gl_Draw_AddFont (struct rfont_s *font); +void gl_Draw_FontString (int x, int y, int fontid, const char *str); void GL_Set2D (void); void GL_Set2DScaled (void); diff --git a/include/QF/GLSL/qf_draw.h b/include/QF/GLSL/qf_draw.h index 59ecb1668..6481cf7aa 100644 --- a/include/QF/GLSL/qf_draw.h +++ b/include/QF/GLSL/qf_draw.h @@ -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_SubPic(int x, int y, struct qpic_s *pic, int srcx, int srcy, int width, int height); -void glsl_Draw_AddFont (struct rfont_s *font); -void glsl_Draw_FontString (int x, int y, const char *str); +int glsl_Draw_AddFont (struct rfont_s *font); +void glsl_Draw_FontString (int x, int y, int fontid, const char *str); void GLSL_Set2D (void); void GLSL_Set2DScaled (void); diff --git a/include/QF/Vulkan/qf_draw.h b/include/QF/Vulkan/qf_draw.h index 1da531fb1..fa4f83772 100644 --- a/include/QF/Vulkan/qf_draw.h +++ b/include/QF/Vulkan/qf_draw.h @@ -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, int srcx, int srcy, int width, int height, struct vulkan_ctx_s *ctx); -void Vulkan_Draw_AddFont (struct rfont_s *font, struct vulkan_ctx_s *ctx); -void Vulkan_Draw_FontString (int x, int y, const char *str, +int Vulkan_Draw_AddFont (struct rfont_s *font, struct vulkan_ctx_s *ctx); +void Vulkan_Draw_FontString (int x, int y, int fontid, const char *str, struct vulkan_ctx_s *ctx); void Vulkan_Set2D (struct vulkan_ctx_s *ctx); diff --git a/include/QF/draw.h b/include/QF/draw.h index aabbf7e16..3c439f190 100644 --- a/include/QF/draw.h +++ b/include/QF/draw.h @@ -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); struct rfont_s; -void Draw_AddFont (struct rfont_s *font); -void Draw_FontString (int x, int y, const char *str); +int Draw_AddFont (struct rfont_s *font); +void Draw_FontString (int x, int y, int fontid, const char *str); ///@} diff --git a/include/QF/plugin/vid_render.h b/include/QF/plugin/vid_render.h index eaf74c599..b3e591ad4 100644 --- a/include/QF/plugin/vid_render.h +++ b/include/QF/plugin/vid_render.h @@ -107,8 +107,8 @@ typedef struct vid_render_funcs_s { void (*Draw_Pic) (int x, int 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_AddFont) (struct rfont_s *font); - void (*Draw_FontString) (int x, int y, const char *str); + int (*Draw_AddFont) (struct rfont_s *font); + void (*Draw_FontString) (int x, int y, int fontid, const char *str); struct psystem_s *(*ParticleSystem) (void); diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index d22ef1fed..d27d3deaa 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -1037,12 +1037,13 @@ gl_Draw_BlendScreen (quat_t color) qfglEnable (GL_TEXTURE_2D); } -void +int gl_Draw_AddFont (struct rfont_s *font) { + return 0; } void -gl_Draw_FontString (int x, int y, const char *str) +gl_Draw_FontString (int x, int y, int fontid, const char *str) { } diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index f9bc2504b..835b93948 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -860,12 +860,13 @@ glsl_Draw_BlendScreen (quat_t color) draw_blendscreen (color); } -void +int glsl_Draw_AddFont (struct rfont_s *font) { + return 0; } void -glsl_Draw_FontString (int x, int y, const char *str) +glsl_Draw_FontString (int x, int y, int fontid, const char *str) { } diff --git a/libs/video/renderer/r_progs.c b/libs/video/renderer/r_progs.c index b7a1004f3..9c00c35f9 100644 --- a/libs/video/renderer/r_progs.c +++ b/libs/video/renderer/r_progs.c @@ -390,7 +390,7 @@ bi_Font_Load (progs_t *pr, void *_res) QFile *font_file = QFS_FOpenFile (font_path); rfont_t *font = R_FontLoad (font_file, font_size); - r_funcs->Draw_AddFont (font); + R_INT (pr) = r_funcs->Draw_AddFont (font); } static void @@ -398,8 +398,9 @@ bi_Font_String (progs_t *pr, void *_res) { int x = P_INT (pr, 0); int y = P_INT (pr, 1); - const char *str = P_GSTRING (pr, 2); - r_funcs->Draw_FontString (x, y, str); + int fontid = P_INT (pr, 2); + const char *str = P_GSTRING (pr, 3); + r_funcs->Draw_FontString (x, y, fontid, str); } static void @@ -531,7 +532,7 @@ static builtin_t builtins[] = { bi(Draw_Crosshair, 5, p(int), p(int), p(int), 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_DestroyBuffer, 1, p(ptr)), diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index 1edbd5a51..303678cff 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -987,12 +987,13 @@ Draw_BlendScreen (quat_t color) vid.vid_internal->set_palette (vid.vid_internal->data, pal); } -void +int Draw_AddFont (struct rfont_s *font) { + return 0; } void -Draw_FontString (int x, int y, const char *str) +Draw_FontString (int x, int y, int fontid, const char *str) { } diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index f7a6c103b..6457ba8bc 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -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); } -static void +static int vulkan_Draw_AddFont (struct rfont_s *font) { - Vulkan_Draw_AddFont (font, vulkan_ctx); + return Vulkan_Draw_AddFont (font, vulkan_ctx); } 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 diff --git a/libs/video/renderer/vulkan/vulkan_draw.c b/libs/video/renderer/vulkan/vulkan_draw.c index f5da3468b..2fed1cb1f 100644 --- a/libs/video/renderer/vulkan/vulkan_draw.c +++ b/libs/video/renderer/vulkan/vulkan_draw.c @@ -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) { 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"); } + + return 0; } typedef struct { @@ -1115,7 +1117,8 @@ vulkan_render_glyph (rglyph_t *glyph, int x, int y, void *_rgctx) } 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; if (!dctx->font) {