From d0460231646da41abe57b185bc5de8b003bb1328 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 26 Jul 2020 15:05:42 +0200 Subject: [PATCH] flatmodel now always use the standard geometry graphics --- hud.cpp | 20 +++++++-------- hypgraph.cpp | 71 ++++++++++++++++++++++++---------------------------- 2 files changed, 43 insertions(+), 48 deletions(-) diff --git a/hud.cpp b/hud.cpp index ccc35010..edb00731 100644 --- a/hud.cpp +++ b/hud.cpp @@ -406,16 +406,6 @@ EX void drawStats() { auto xc = cd->xcenter; auto yc = cd->ycenter; - flat_model_enabler fme; - - if(crosshair_color && crosshair_size > 0) { - initquickqueue(); - vid.linewidth = 1; - queueline(tC0(atscreenpos(xc - crosshair_size, yc, 1)), tC0(atscreenpos(xc + crosshair_size, yc, 1)), crosshair_color).prio = PPR::SUPERLINE; - queueline(tC0(atscreenpos(xc, yc - crosshair_size, 1)), tC0(atscreenpos(xc, yc + crosshair_size, 1)), crosshair_color).prio = PPR::SUPERLINE; - quickqueue(); - } - if(vid.radarsize > 0 && h) #if CAP_RACING if(!racing::on) @@ -424,6 +414,16 @@ EX void drawStats() { if(!(cmode & sm::MISSION)) draw_radar(cornermode); + flat_model_enabler fme; + + if(crosshair_color && crosshair_size > 0) { + initquickqueue(); + vid.linewidth = 1; + queueline(tC0(atscreenpos(xc - crosshair_size, yc, 1)), tC0(atscreenpos(xc + crosshair_size, yc, 1)), crosshair_color).prio = PPR::SUPERLINE; + queueline(tC0(atscreenpos(xc, yc - crosshair_size, 1)), tC0(atscreenpos(xc, yc + crosshair_size, 1)), crosshair_color).prio = PPR::SUPERLINE; + quickqueue(); + } + if(haveMobileCompass()) { initquickqueue(); using namespace shmupballs; diff --git a/hypgraph.cpp b/hypgraph.cpp index c52d3927..bbefecf2 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1555,50 +1555,45 @@ transmatrix screenpos(ld x, ld y) { In 2D, this does not work (as HyperRogue reduces matrices to 3x3) so we use the native disk projection */ -EX eModel flat_model() { return MDIM == 4 ? mdPixel : mdDisk; } +int flat_on; +eGeometry backup_geometry; +projection_configuration backup_pconf; +bool backup_always3; /** \brief enable the 'flat' model for drawing HUD. See hr::flat_model_enabler */ -EX void enable_flat_model() { - #if CAP_GL - glClear(GL_DEPTH_BUFFER_BIT); - #endif - pmodel = flat_model(); - pconf.alpha = 1; - pconf.scale = 1; - pconf.camera_angle = 0; - pconf.stretch = 1; - if(prod) pconf.alpha = 30, pconf.scale = 30; - calcparam(); +EX void enable_flat_model(int val) { + if(flat_on < 1 && flat_on + val >= 1) { + #if CAP_GL + glClear(GL_DEPTH_BUFFER_BIT); + #endif + backup_geometry = geometry; + backup_pconf = pconf; + geometry = gNormal; + pmodel = mdDisk; + pconf.alpha = 1; + pconf.scale = 1; + pconf.camera_angle = 0; + pconf.stretch = 1; + backup_always3 = vid.always3; + vid.always3 = false; + check_cgi(); + cgi.require_shapes(); + calcparam(); + } + if(flat_on >= 1 && flat_on + val < 1) { + geometry = backup_geometry; + pconf = backup_pconf; + vid.always3 = backup_always3; + calcparam(); + check_cgi(); + } + flat_on += val; } #if HDR -/** \brief enable the 'flat' model for drawing HUD. Use RAII so it will be switched back later */ -namespace stretch { extern ld factor; } - -#if CAP_RAY -namespace ray { extern bool in_use; } -#endif - struct flat_model_enabler { - projection_configuration bak; - ld sf; - bool ru; - flat_model_enabler() { - bak = pconf; - sf = stretch::factor; stretch::factor = 0; - #if CAP_RAY - ru = ray::in_use; ray::in_use = false; - #endif - enable_flat_model(); - } - ~flat_model_enabler() { - pconf = bak; - stretch::factor = sf; - #if CAP_RAY - ray::in_use = ru; - #endif - calcparam(); - } + flat_model_enabler() { enable_flat_model(+1); } + ~flat_model_enabler() { enable_flat_model(-1); } }; #endif