From 414c86aa09181c7af8f9eb84aae0d12eb862db3c Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Thu, 29 Dec 2022 03:30:31 +0300 Subject: [PATCH] gl: do not draw outside map area --- src/game/renders/opengl/r_map.pas | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/game/renders/opengl/r_map.pas b/src/game/renders/opengl/r_map.pas index a1d781c..6b54fa3 100644 --- a/src/game/renders/opengl/r_map.pas +++ b/src/game/renders/opengl/r_map.pas @@ -236,6 +236,7 @@ implementation var DebugCameraScale: Single; + FillOutsizeArea: Boolean; SkyTexture: TGLTexture; RenTextures: array of record spec: LongInt; @@ -1383,10 +1384,9 @@ implementation end; procedure r_Map_Draw (x, y, w, h, camx, camy: Integer; player: TPlayer); - var iter: TPanelGrid.Iter; p: PPanel; cx, cy, cw, ch, xx, yy, ww, hh: Integer; sx, sy, sw, sh: LongInt; l, t, r, b: Integer; + var iter: TPanelGrid.Iter; p: PPanel; cx, cy, cw, ch, xx, yy, ww, hh, ml, mt, mr, mb, mcx, mcy: Integer; sx, sy, sw, sh: LongInt; l, t, r, b: Integer; begin r_Draw_GetRect(l, t, r, b); - r_Draw_SetRect(x, y, x + w, y + h); glTranslatef(x, y, 0); (* camera rect *) @@ -1422,6 +1422,17 @@ implementation if yy < 0 then yy := 0; + (* view bounds *) + ml := x; mt := y; mr := x + w; mb := y + h; + if FillOutsizeArea and (DebugCameraScale = 1.0) then + begin + ml := MAX(cx + ml, 0) - cx; + mt := MAX(cy + mt, 0) - cy; + mr := MIN(cx + mr, gMapInfo.Width - 1) - cx; + mb := MIN(cy + mb, gMapInfo.Height - 1) - cy; + end; + r_Draw_SetRect(ml, mt, mr, mb); + plist.Clear; iter := mapGrid.ForEachInAABB(xx, yy, ww, hh, GridDrawableMask); for p in iter do @@ -1502,5 +1513,7 @@ implementation initialization conRegVar('r_debug_camera_scale', @DebugCameraScale, 0.0001, 1000.0, '', ''); + conRegVar('r_gl_fill_outside', @FillOutsizeArea, '', ''); DebugCameraScale := 1.0; + FillOutsizeArea := true; end. -- 2.29.2