flatmodel now always use the standard geometry graphics

This commit is contained in:
Zeno Rogue 2020-07-26 15:05:42 +02:00
parent 1d94bd76f8
commit d046023164
2 changed files with 43 additions and 48 deletions

20
hud.cpp
View File

@ -406,16 +406,6 @@ EX void drawStats() {
auto xc = cd->xcenter; auto xc = cd->xcenter;
auto yc = cd->ycenter; 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(vid.radarsize > 0 && h)
#if CAP_RACING #if CAP_RACING
if(!racing::on) if(!racing::on)
@ -424,6 +414,16 @@ EX void drawStats() {
if(!(cmode & sm::MISSION)) if(!(cmode & sm::MISSION))
draw_radar(cornermode); 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()) { if(haveMobileCompass()) {
initquickqueue(); initquickqueue();
using namespace shmupballs; using namespace shmupballs;

View File

@ -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 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 */ /** \brief enable the 'flat' model for drawing HUD. See hr::flat_model_enabler */
EX void enable_flat_model() { EX void enable_flat_model(int val) {
#if CAP_GL if(flat_on < 1 && flat_on + val >= 1) {
glClear(GL_DEPTH_BUFFER_BIT); #if CAP_GL
#endif glClear(GL_DEPTH_BUFFER_BIT);
pmodel = flat_model(); #endif
pconf.alpha = 1; backup_geometry = geometry;
pconf.scale = 1; backup_pconf = pconf;
pconf.camera_angle = 0; geometry = gNormal;
pconf.stretch = 1; pmodel = mdDisk;
if(prod) pconf.alpha = 30, pconf.scale = 30; pconf.alpha = 1;
calcparam(); 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 #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 { struct flat_model_enabler {
projection_configuration bak; flat_model_enabler() { enable_flat_model(+1); }
ld sf; ~flat_model_enabler() { enable_flat_model(-1); }
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();
}
}; };
#endif #endif