From 0ed74b12c4bac50ecddd0ff64befc02119dcd650 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 20 Nov 2018 19:01:10 +0100 Subject: [PATCH] fixed the rendering of Hypersian Rug --- basegraph.cpp | 14 ++++++-------- rug.cpp | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/basegraph.cpp b/basegraph.cpp index e2cef035..63ab3bdc 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -286,18 +286,16 @@ void display_data::set_mask(int ed) { } void display_data::set_viewport(int ed) { - ld xmin = vid.xres * current_display->xmin; - ld xmax = vid.xres * current_display->xmax; - ld ymin = vid.yres * current_display->ymin; - ld ymax = vid.yres * current_display->ymax; - - ld xsize = xmax - xmin, ysize = ymax - ymin; + ld xtop = current_display->xtop; + ld ytop = current_display->ytop; + ld xsize = current_display->xsize; + ld ysize = current_display->ysize; if(ed == 0 || vid.stereo_mode != sLR) ; else if(ed == 1) xsize /= 2; - else if(ed == -1) xsize /= 2, xmin += xsize; + else if(ed == -1) xsize /= 2, xtop += xsize; - glViewport(xmin, ymin, xsize, ysize); + glViewport(xtop, ytop, xsize, ysize); } bool model_needs_depth() { diff --git a/rug.cpp b/rug.cpp index fad5b5b8..14afecaf 100644 --- a/rug.cpp +++ b/rug.cpp @@ -337,17 +337,20 @@ void calcLengths() { edge.len = hdist(p->h, edge.target->h) * modelscale; } -void setVidParam() { - vid.xres = vid.yres = TEXTURESIZE; - current_display->scrsize = HTEXTURESIZE; - current_display->radius = current_display->scrsize * vid.scale; current_display->xcenter = HTEXTURESIZE; current_display->ycenter = HTEXTURESIZE; - // vid.alpha = 1; +void calcparam_rug() { + auto cd = current_display; + + cd->xtop = cd->ytop = 0; + cd->xsize = cd->ysize = TEXTURESIZE; + cd->xcenter = cd->ycenter = cd->scrsize = HTEXTURESIZE; + + cd->radius = cd->scrsize * vid.scale; } void buildTorusRug() { using namespace torusconfig; - setVidParam(); + calcparam_rug(); struct toruspoint { int x,y; @@ -1228,10 +1231,8 @@ renderbuffer *glbuf; void prepareTexture() { resetbuffer rb; - videopar svid = vid; - - setVidParam(); dynamicval d(vid.stereo_mode, sOFF); + calcparam_rug(); glbuf->enable(); current_display->set_viewport(0); @@ -1252,7 +1253,7 @@ void prepareTexture() { queueline(V * xspinpush0(i*M_PI/32, finger_range), V * xspinpush0((i+1)*M_PI/32, finger_range), 0xFFFFFFFF, vid.linequality); } drawqueue(); - vid = svid; + calcparam(); rb.reset(); } @@ -1684,10 +1685,9 @@ hyperpoint gethyper(ld x, ld y) { double px = rx1 * TEXTURESIZE, py = (1-ry1) * TEXTURESIZE; - videopar svid = vid; - setVidParam(); + calcparam_rug(); hyperpoint h = hr::gethyper(px, py); - vid = svid; + calcparam(); return h; }