From 4707347f3bb20ae2b3b100d737207ad805c0d49d Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 26 Apr 2022 01:10:08 +0200 Subject: [PATCH] netgen:: should no longer switch to OpenGL-less and crash --- netgen.cpp | 60 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/netgen.cpp b/netgen.cpp index c7999f61..6ea15516 100644 --- a/netgen.cpp +++ b/netgen.cpp @@ -12,6 +12,7 @@ namespace hr { EX namespace netgen { // We need a two-dimensional vector class for this. + // (actually we could just use hyperpoint but this is very old...) struct vec { double x, y; @@ -491,21 +492,48 @@ EX namespace netgen { (edgist[i]+edgist[j]) * ang(rot[j] + 2*M_PI*(je+.5)/jt); } + shiftpoint vec_to_p(vec v) { + return shiftless(hyperpoint(v.x - current_display->xcenter, v.y - current_display->ycenter, 0, 1)); + } + + void netline(vec a, vec b, color_t col) { + if(vid.usingGL) + queueline(vec_to_p(a), vec_to_p(b), col, 0); + else + blackline(a, b, col); + } + + void netcircle(vec ctr, int rad, color_t col) { + if(vid.usingGL) + queuecircle(ctr.x, ctr.y, rad, col); + else + blackcircle(ctr, rad, col); + } + void displaynets() { - SDL_LockSurface(s); + if(!vid.usingGL) SDL_LockSurface(s); setRaylen(); - for(int uy=SY-1; uy>=0; uy--) - for(int ux=SX-1; ux>=0; ux--) { - qpixel(s, ux, uy) = 0; + if(vid.usingGL) { + calcparam(); + setGLProjection(); + glhr::set_depthtest(false); + current_display->set_all(0,0); + } + else { + for(int uy=SY-1; uy>=0; uy--) + for(int ux=SX-1; ux>=0; ux--) { + qpixel(s, ux, uy) = 0; + } + initquickqueue(); } for(int y=1; y= 0 ? 0xC0C0C0FF : 0x808080FF; - blackline(v1, v2, col); + netline(v1, v2, col); if(nei[i][e] != -1 && nei[i][e] != glued[i] && glued[nei[i][e]] != i) { vec vd = v2-v1; @@ -553,15 +581,16 @@ EX namespace netgen { vd.x *= factor; vd.y *= factor; vec v4 = v3 + vd; - blackline(v1, v4, 0xFFC0C0C0); - blackline(v2, v4, 0xFFC0C0C0); + netline(v1, v4, 0xFFC0C0C0); + netline(v2, v4, 0xFFC0C0C0); } } } - SDL_UnlockSurface(s); + if(!vid.usingGL) SDL_UnlockSurface(s); + else quickqueue(); - present_surface(); + present_screen(); } double rs, rz; @@ -655,6 +684,9 @@ EX namespace netgen { dynamicval dr(resizable, false); dynamicval dws(vid.relative_window_size, false); dynamicval dfs(vid.change_fullscr, true); + dynamicval dcf(vid.want_fullscreen, false); + dynamicval m(pmodel, mdPixel); + apply_screen_settings(); netgen_loop();