From 958b6ff1d81fd0ec51a950ffc5299a95dab3e692 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 2 Dec 2022 10:51:41 +0900 Subject: [PATCH] [glsl] Implement line graph drawing Finally :/ --- include/QF/GLSL/qf_draw.h | 1 + include/QF/GLSL/qf_main.h | 1 - libs/video/renderer/glsl/glsl_draw.c | 14 ++++++++++++++ libs/video/renderer/glsl/glsl_main.c | 5 ----- libs/video/renderer/vid_render_glsl.c | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/QF/GLSL/qf_draw.h b/include/QF/GLSL/qf_draw.h index 10f18d6b9..78ce7fafa 100644 --- a/include/QF/GLSL/qf_draw.h +++ b/include/QF/GLSL/qf_draw.h @@ -46,6 +46,7 @@ void glsl_Draw_CrosshairAt (int ch, int x, int y); void glsl_Draw_TileClear (int x, int y, int w, int h); void glsl_Draw_Fill (int x, int y, int w, int h, int c); void glsl_Draw_Line (int x0, int y0, int x1, int y1, int c); +void glsl_LineGraph (int x, int y, int *h_vals, int count, int height); void glsl_Draw_TextBox (int x, int y, int width, int lines, byte alpha); void glsl_Draw_FadeScreen (void); void glsl_Draw_BlendScreen (quat_t color); diff --git a/include/QF/GLSL/qf_main.h b/include/QF/GLSL/qf_main.h index 621c0b2af..b51b64103 100644 --- a/include/QF/GLSL/qf_main.h +++ b/include/QF/GLSL/qf_main.h @@ -36,6 +36,5 @@ void glsl_R_RenderEntities (struct entqueue_s *queue); void glsl_R_RenderView (void); void glsl_R_ClearState (void); void glsl_R_ViewChanged (void); -void glsl_R_LineGraph (int x, int y, int *h_vals, int count, int height); #endif//__QF_GLSL_qf_main_h diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index b6e7e797c..b08f97a15 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -737,6 +737,20 @@ glsl_Draw_Line (int x0, int y0, int x1, int y1, int c) memcpy (v, verts, size); } +void +glsl_LineGraph (int x, int y, int *h_vals, int count, int height) +{ + static int colors[] = { 0xd0, 0x4f, 0x6f }; + + while (count-- > 0) { + int h = *h_vals++; + int c = h < 9998 || h > 10000 ? 0xfe : colors[h - 9998]; + h = min (h, height); + glsl_Draw_Line (x, y, x, y - h, c); + x++; + } +} + static inline void draw_blendscreen (quat_t color) { diff --git a/libs/video/renderer/glsl/glsl_main.c b/libs/video/renderer/glsl/glsl_main.c index 1dfbcc6a3..dec092b1c 100644 --- a/libs/video/renderer/glsl/glsl_main.c +++ b/libs/video/renderer/glsl/glsl_main.c @@ -210,11 +210,6 @@ glsl_R_NewScene (scene_t *scene) glsl_R_BuildDisplayLists (scene->models, scene->num_models); } -void -glsl_R_LineGraph (int x, int y, int *h_vals, int count, int height) -{ -} - void glsl_R_ClearState (void) { diff --git a/libs/video/renderer/vid_render_glsl.c b/libs/video/renderer/vid_render_glsl.c index 87608ab40..3969817db 100644 --- a/libs/video/renderer/vid_render_glsl.c +++ b/libs/video/renderer/vid_render_glsl.c @@ -476,7 +476,7 @@ vid_render_funcs_t glsl_vid_render_funcs = { .R_ClearState = glsl_R_ClearState, .R_LoadSkys = glsl_R_LoadSkys, .R_NewScene = glsl_R_NewScene, - .R_LineGraph = glsl_R_LineGraph, + .R_LineGraph = glsl_LineGraph, .begin_frame = glsl_begin_frame, .render_view = glsl_render_view, .draw_particles = glsl_R_DrawParticles,