From c19ffb35974cb1cbd819f1fd51fcb8d89c9a4b29 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 29 Apr 2019 03:37:27 +0200 Subject: [PATCH] fixes to projection streamlining --- basegraph.cpp | 1 + hud.cpp | 2 +- hyper.h | 1 + hypgraph.cpp | 3 ++- polygons.cpp | 7 ++----- shaders.cpp | 1 + 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/basegraph.cpp b/basegraph.cpp index 98026997..ec64c503 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -167,6 +167,7 @@ void setcameraangle(bool b) { } bool shaderside_projection; void start_projection(int ed, bool perspective) { + glhr::use_projection(); glhr::new_projection(); shaderside_projection = perspective; diff --git a/hud.cpp b/hud.cpp index a222ed75..4c83469b 100644 --- a/hud.cpp +++ b/hud.cpp @@ -350,6 +350,7 @@ bool nofps = false; void draw_radar(bool cornermode) { dynamicval g(geometry, gEuclid); + dynamicval pm(pmodel, mdText); initquickqueue(); int rad = vid.radarsize; @@ -372,7 +373,6 @@ void draw_radar(bool cornermode) { queueline(atscreenpos(cx+rad * r.h[0], cy - rad * r.h[2]/3 + rad * r.h[1]*2/3, 0)*C0, atscreenpos(cx+rad*r.h[0], cy - rad*r.h[2]/3, 0)*C0, r.line, -1); } - dynamicval pm(pmodel, mdText); quickqueue(); for(auto& r: radarpoints) diff --git a/hyper.h b/hyper.h index d5111da7..f5e1b733 100644 --- a/hyper.h +++ b/hyper.h @@ -3923,6 +3923,7 @@ namespace glhr { void color2(color_t color, ld scale = 1); void be_nontextured(shader_projection sp = new_shader_projection); void be_textured(shader_projection sp = new_shader_projection); + void use_projection(shader_projection sp = new_shader_projection); void set_modelview(const glmatrix& m); hyperpoint gltopoint(const glvertex& t); glvertex pointtogl(const hyperpoint& t); diff --git a/hypgraph.cpp b/hypgraph.cpp index 6e0119c9..7258d8d0 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -273,6 +273,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { } case mdUnchanged: + case mdText: ret = H / current_display->radius; return; @@ -654,7 +655,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { } } - case mdGUARD: case mdRug: case mdText: break; + case mdGUARD: case mdRug: break; } ghcheck(ret,H_orig); diff --git a/polygons.cpp b/polygons.cpp index 2f8a9503..e8ffd772 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -191,9 +191,6 @@ void glflush() { glhr::color2(text_color); glhr::set_depthtest(false); for(int ed = (current_display->stereo_active() && text_shift)?-1:0; ed<2; ed+=2) { - if(vid.scale < 0) - glhr::set_modelview(glhr::translate(-ed*text_shift-current_display->xcenter,-current_display->ycenter, current_display->scrdist_text) * glhr::scale(-1,-1,-1)); - else glhr::set_modelview(glhr::translate(-ed*text_shift-current_display->xcenter,-current_display->ycenter, current_display->scrdist_text)); current_display->set_mask(ed); @@ -1035,7 +1032,7 @@ void dqi_poly::draw() { } */ #if CAP_GL - if(vid.usingGL && shaderside_projection) { + if(vid.usingGL && (current_display->set_all(global_projection), shaderside_projection)) { glLineWidth(get_width(this)); flags &= ~POLY_INVERSE; gldraw(); @@ -1521,7 +1518,7 @@ void draw_main() { void drawqueue() { callhooks(hook_drawqueue); - reset_projection(); current_display->set_all(0); + reset_projection(); // reset_projection() is not sufficient here, because we need to know shaderside_projection #if CAP_GL diff --git a/shaders.cpp b/shaders.cpp index 18cc4e7c..a4cb6331 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -360,6 +360,7 @@ void colorClear(color_t color) { void be_nontextured(shader_projection sp) { switch_mode(gmColored, sp); } void be_textured(shader_projection sp) { switch_mode(gmTextured, sp); } +void use_projection(shader_projection sp) { switch_mode(mode, sp); } void switch_mode(eMode m, shader_projection sp) { if(m == mode && current_shader_projection == sp) return;