From d67316454c649093209d02cb60b3cc84a15580c3 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 12 Jul 2019 23:15:09 +0200 Subject: [PATCH] linewidth bugs fixed when MINIMIZE_GL_CALLS --- drawing.cpp | 17 ++++++++++++----- shaders.cpp | 9 +++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 4be8d4c0..443059f3 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -559,7 +559,7 @@ ld scale_at(const transmatrix& T) { ld linewidthat(const hyperpoint& h) { if(!(vid.antialias & AA_LINEWIDTH)) return 1; - else if(hyperbolic && pmodel == mdDisk && vid.alpha == 1) { + else if(hyperbolic && pmodel == mdDisk && vid.alpha == 1 && !ISWEB) { double dz = h[DIM]; if(dz < 1 || abs(dz-current_display->scrdist) < 1e-6) return 1; else { @@ -578,6 +578,13 @@ ld linewidthat(const hyperpoint& h) { return 1; } +void set_width(ld w) { + #if MINIMIZE_GL_CALLS + if(w != glhr::current_linewidth) glflush(); + #endif + glhr::set_linewidth(w); + } + // -radius to +3radius int mercator_coord; @@ -889,7 +896,7 @@ void dqi_poly::draw() { #if CAP_GL if(vid.usingGL && (current_display->set_all(global_projection), shaderside_projection)) { - glLineWidth(get_width(this)); + set_width(get_width(this)); flags &= ~POLY_INVERSE; gldraw(); return; @@ -1024,7 +1031,7 @@ void dqi_poly::draw() { if(tinf && (poly_flags & POLY_INVERSE)) { return; } - glLineWidth(get_width(this)); + set_width(get_width(this)); dqi_poly npoly = (*this); npoly.V = Id; npoly.tab = &glcoords; @@ -1253,11 +1260,11 @@ void sort_drawqueue() { #if MINIMIZE_GL_CALLS unordered_map>> subqueue; - for(auto& p: ptds) subqueue[p->prio == PPR::CIRCLE ? 0 : p->outline_group()].push_back(move(p)); + for(auto& p: ptds) subqueue[(p->prio == PPR::CIRCLE || p->prio == PPR::OUTCIRCLE) ? 0 : p->outline_group()].push_back(move(p)); ptds.clear(); for(auto& p: subqueue) for(auto& r: p.second) ptds.push_back(move(r)); subqueue.clear(); - for(auto& p: ptds) subqueue[p->prio == PPR::CIRCLE ? 0 : p->color].push_back(move(p)); + for(auto& p: ptds) subqueue[(p->prio == PPR::CIRCLE || p->prio == PPR::OUTCIRCLE) ? 0 : p->color].push_back(move(p)); ptds.clear(); for(auto& p: subqueue) for(auto& r: p.second) ptds.push_back(move(r)); #endif diff --git a/shaders.cpp b/shaders.cpp index abf61dcc..4e855ace 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -43,6 +43,7 @@ ld fogbase; typedef const void *constvoidptr; constvoidptr current_vertices, buffered_vertices; +ld current_linewidth; GLuint buf_current, buf_buffered; @@ -468,6 +469,7 @@ void switch_mode(eMode m, shader_projection sp) { current_projection[0][0] = -1e8; }, {}); id_modelview(); + current_linewidth = -1; /* if(current_depthwrite) glDepthMask(GL_TRUE); else glDepthMask(GL_FALSE); if(current_depthtest) glEnable(GL_DEPTH_TEST); @@ -824,6 +826,13 @@ void set_depthwrite(bool b) { } } +void set_linewidth(ld lw) { + if(lw != current_linewidth) { + current_linewidth = lw; + glLineWidth(lw); + } + } + void switch_to_text(const vector& v, const vector& t) { glhr::be_textured(); dynamicval pm(pmodel, mdUnchanged);