diff --git a/include/QF/GL/qf_draw.h b/include/QF/GL/qf_draw.h index d348e2534..9e2f4e8d6 100644 --- a/include/QF/GL/qf_draw.h +++ b/include/QF/GL/qf_draw.h @@ -29,6 +29,7 @@ #define __gl_draw_h struct qpic_s; +struct rfont_s; void gl_Draw_Init (void); void gl_Draw_Shutdown (void); @@ -54,6 +55,7 @@ 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_Set2D (void); void GL_Set2DScaled (void); diff --git a/include/QF/GLSL/qf_draw.h b/include/QF/GLSL/qf_draw.h index 5c93713fc..e38b39d92 100644 --- a/include/QF/GLSL/qf_draw.h +++ b/include/QF/GLSL/qf_draw.h @@ -29,6 +29,7 @@ #define __QF_GLSL_qf_draw_h struct qpic_s; +struct rfont_s; void glsl_Draw_Init (void); void glsl_Draw_Shutdown (void); @@ -54,6 +55,7 @@ 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_Set2D (void); void GLSL_Set2DScaled (void); diff --git a/include/QF/Vulkan/qf_draw.h b/include/QF/Vulkan/qf_draw.h index 216f4b3a0..e8a28e40f 100644 --- a/include/QF/Vulkan/qf_draw.h +++ b/include/QF/Vulkan/qf_draw.h @@ -31,6 +31,7 @@ struct vulkan_ctx_s; struct qfv_renderframe_s; struct qpic_s; +struct rfont_s; void Vulkan_Draw_Init (struct vulkan_ctx_s *ctx); void Vulkan_Draw_Shutdown (struct vulkan_ctx_s *ctx); @@ -71,6 +72,7 @@ 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_Set2D (struct vulkan_ctx_s *ctx); void Vulkan_Set2DScaled (struct vulkan_ctx_s *ctx); diff --git a/include/QF/draw.h b/include/QF/draw.h index 5f6037e15..9e0bf654e 100644 --- a/include/QF/draw.h +++ b/include/QF/draw.h @@ -243,6 +243,10 @@ void Draw_Picf (float x, float y, qpic_t *pic); \param height vertical size of the sub-region to be drawn */ 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); + ///@} #endif//__QF_draw_h diff --git a/include/QF/plugin/vid_render.h b/include/QF/plugin/vid_render.h index 3d6774d08..a8a6c418e 100644 --- a/include/QF/plugin/vid_render.h +++ b/include/QF/plugin/vid_render.h @@ -78,6 +78,7 @@ typedef struct vid_model_funcs_s { } vid_model_funcs_t; struct tex_s; +struct rfont_s; typedef void (*capfunc_t) (struct tex_s *screencap, void *data); typedef struct vid_render_funcs_s { @@ -103,6 +104,7 @@ 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); struct psystem_s *(*ParticleSystem) (void); diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index c4abb9753..084104165 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -1018,3 +1018,8 @@ gl_Draw_BlendScreen (quat_t color) qfglColor3ubv (color_white); qfglEnable (GL_TEXTURE_2D); } + +void +gl_Draw_AddFont (struct rfont_s *font) +{ +} diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index a150fe20f..707fcdcb8 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -841,3 +841,8 @@ glsl_Draw_BlendScreen (quat_t color) return; draw_blendscreen (color); } + +void +glsl_Draw_AddFont (struct rfont_s *font) +{ +} diff --git a/libs/video/renderer/r_progs.c b/libs/video/renderer/r_progs.c index f7d884c4f..387b2989e 100644 --- a/libs/video/renderer/r_progs.c +++ b/libs/video/renderer/r_progs.c @@ -343,7 +343,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, preload); - (void)font; + r_funcs->Draw_AddFont (font); } static const char * diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index c861da9b4..4a9ba34cc 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -974,3 +974,8 @@ Draw_BlendScreen (quat_t color) } vid.vid_internal->set_palette (vid.vid_internal->data, pal); } + +void +Draw_AddFont (struct rfont_s *font) +{ +} diff --git a/libs/video/renderer/vid_render_gl.c b/libs/video/renderer/vid_render_gl.c index 3fe390bf9..3e165bdf7 100644 --- a/libs/video/renderer/vid_render_gl.c +++ b/libs/video/renderer/vid_render_gl.c @@ -507,6 +507,7 @@ vid_render_funcs_t gl_vid_render_funcs = { gl_Draw_Pic, gl_Draw_Picf, gl_Draw_SubPic, + gl_Draw_AddFont, gl_ParticleSystem, gl_R_Init, diff --git a/libs/video/renderer/vid_render_glsl.c b/libs/video/renderer/vid_render_glsl.c index 958cfbfdc..12b0425eb 100644 --- a/libs/video/renderer/vid_render_glsl.c +++ b/libs/video/renderer/vid_render_glsl.c @@ -451,6 +451,7 @@ vid_render_funcs_t glsl_vid_render_funcs = { glsl_Draw_Pic, glsl_Draw_Picf, glsl_Draw_SubPic, + glsl_Draw_AddFont, glsl_ParticleSystem, glsl_R_Init, diff --git a/libs/video/renderer/vid_render_sw.c b/libs/video/renderer/vid_render_sw.c index e1398bc72..b9bb753d1 100644 --- a/libs/video/renderer/vid_render_sw.c +++ b/libs/video/renderer/vid_render_sw.c @@ -471,6 +471,7 @@ vid_render_funcs_t sw_vid_render_funcs = { Draw_Pic, Draw_Picf, Draw_SubPic, + Draw_AddFont, sw_ParticleSystem, sw_R_Init, diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index cce63d511..85033e9c7 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -261,6 +261,12 @@ 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 +vulkan_Draw_AddFont (struct rfont_s *font) +{ + Vulkan_Draw_AddFont (font, vulkan_ctx); +} + static void vulkan_begin_frame (void) { @@ -749,6 +755,7 @@ vid_render_funcs_t vulkan_vid_render_funcs = { vulkan_Draw_Pic, vulkan_Draw_Picf, vulkan_Draw_SubPic, + vulkan_Draw_AddFont, vulkan_ParticleSystem, vulkan_R_Init, diff --git a/libs/video/renderer/vulkan/vulkan_draw.c b/libs/video/renderer/vulkan/vulkan_draw.c index b4d8b2ac4..29d93f65d 100644 --- a/libs/video/renderer/vulkan/vulkan_draw.c +++ b/libs/video/renderer/vulkan/vulkan_draw.c @@ -52,6 +52,7 @@ #include "compat.h" #include "QF/Vulkan/qf_draw.h" #include "QF/Vulkan/qf_matrices.h" +#include "QF/Vulkan/qf_texture.h" #include "QF/Vulkan/qf_vid.h" #include "QF/Vulkan/barrier.h" #include "QF/Vulkan/buffer.h" @@ -66,6 +67,7 @@ #include "QF/Vulkan/staging.h" #include "QF/ui/view.h" +#include "r_font.h" #include "r_internal.h" #include "vid_vulkan.h" @@ -97,6 +99,8 @@ typedef struct drawframeset_s typedef struct drawctx_s { VkSampler sampler; scrap_t *scrap; + rfont_t *font; + qfv_tex_t *font_tex; qfv_stagebuf_t *stage; qpic_t *crosshair; qpic_t *conchars; @@ -369,6 +373,9 @@ Vulkan_Draw_Shutdown (vulkan_ctx_t *ctx) delete_memsuper (dctx->string_memsuper); QFV_DestroyScrap (dctx->scrap); QFV_DestroyStagingBuffer (dctx->stage); + if (dctx->font_tex) { + Vulkan_UnloadTex (ctx, dctx->font_tex); + } } void @@ -943,3 +950,25 @@ Vulkan_Draw_BlendScreen (quat_t color, vulkan_ctx_t *ctx) draw_blendscreen (c, ctx); } } + +void +Vulkan_Draw_AddFont (rfont_t *font, vulkan_ctx_t *ctx) +{ + drawctx_t *dctx = ctx->draw_context; + + if (dctx->font_tex) { + Vulkan_UnloadTex (ctx, dctx->font_tex); + dctx->font_tex = 0; + } + dctx->font = font; + if (dctx->font) { + tex_t tex = { + .width = font->scrap.width, + .height = font->scrap.height, + .format = tex_l, + .loaded = 1, + .data = font->scrap_bitmap, + }; + dctx->font_tex = Vulkan_LoadTex (ctx, &tex, 0, "draw.font"); + } +}