From a2c6a4e8b02f2a45f48b600e05c71f9c56481b05 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 4 Mar 2019 18:00:51 +0100 Subject: [PATCH] 3d:: a system for drawing transparent things, with sorting being the responsibility of HR --- hyper.h | 4 ++++ polygons.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/hyper.h b/hyper.h index 6fae4c63..3d8dc49f 100644 --- a/hyper.h +++ b/hyper.h @@ -2090,6 +2090,9 @@ enum class PPR { MINEMARK, ARROW, MOBILE_ARROW, LINE, + // in depth tested models transparent surfaces need to be depth sorted by HyperRogue + // and set to PPR::TRANSPARENT to draw them after all the opaque ones + TRANSPARENT, // no depth testing for SUPERLINE and above SUPERLINE, TEXT, CIRCLE, MAX, @@ -2832,6 +2835,7 @@ struct textureinfo { struct drawqueueitem { PPR prio; color_t color; + int subprio; virtual void draw() = 0; virtual void draw_back() {} virtual void draw_pre() {} diff --git a/polygons.cpp b/polygons.cpp index 522d41ac..3be7e8d4 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -1515,6 +1515,12 @@ void drawqueue() { < xintval(ap2.V * xpush0(.1)); }); + for(PPR p: {PPR::TRANSPARENT}) + sort(&ptds[qp0[int(p)]], &ptds[qp[int(p)]], + [] (const unique_ptr& p1, const unique_ptr& p2) { + return p1->subprio > p2->subprio; + }); + profile_stop(3); #if CAP_SDL