Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Software renderer renders bottom line when a GUI is out of screen #1847

Closed
ericoporto opened this issue Dec 10, 2022 · 1 comment · Fixed by #1848
Closed

Software renderer renders bottom line when a GUI is out of screen #1847

ericoporto opened this issue Dec 10, 2022 · 1 comment · Fixed by #1848
Labels
context: graphics type: bug unexpected/erroneous behavior in the existing functionality
Milestone

Comments

@ericoporto
Copy link
Member

ericoporto commented Dec 10, 2022

Describe the bug
When using software mode, if a GUI is Visible, but positioned with Y in excess of the screen height, the bottom of the screen will produce a black line. You can move the mouse over the line to view a small part of the line.

AGS Version
3.6.0.38

Game
Create a new game using the Sierra Template, and in the Project Explorer, select the gStatusline GUI, and in properties, set it's Y position to 201 or bigger. In default setup, chose the Software Renderer. Alternatively, download the project below.
SoftwareRendererBug.zip

To Reproduce
Steps to reproduce the behavior:

  1. Move the mouse to the bottom of the screen, and notice a black line there
  2. Where the mouse goes over, the black line is removed

Expected behavior
There should be no line at the bottom

Screenshots
Note the bottom line.
bottom_black_line

Desktop:

  • OS: Windows
  • Version 10

Additional context
Originally reported here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=60323.msg636651847#msg636651847

@ericoporto ericoporto changed the title Software renderer on screen border line renders weird with GUI out of screen Software renderer renders bottom blac line when a GUI is out of screen Dec 10, 2022
@ericoporto ericoporto changed the title Software renderer renders bottom blac line when a GUI is out of screen Software renderer renders bottom line when a GUI is out of screen Dec 10, 2022
@ivan-mogilko ivan-mogilko added this to the 3.6.0 milestone Dec 10, 2022
@ivan-mogilko ivan-mogilko added type: bug unexpected/erroneous behavior in the existing functionality context: graphics labels Dec 10, 2022
@ericoporto
Copy link
Member Author

ericoporto commented Dec 10, 2022

I noticed in invalidate_rect_on_surf, it clamps the position of the dirty rects, and I also noticed we put sprite on screen using a check but we always mark a region with dirty, with no check for boundaries. Commenting this invalidate_sprite at line 2380 seems to fix this specific case.

I think the problem is here:

if (!IsRectInsideRect(rects.Viewport, r))
invalidate_rect_on_surf(x1, y1, x2, y2, BlackRects);

Basically, we get to a condition where the rect is not in the viewport (it's outside of the screen), but it's not over the black border either. But it then it gets on the screen because of the clamping.

The below appears to fix, but I am not sure if it causes new problems - could not find any so far.

diff --git a/Engine/ac/draw_software.cpp b/Engine/ac/draw_software.cpp
index e1469aae1..947900859 100644
--- a/Engine/ac/draw_software.cpp
+++ b/Engine/ac/draw_software.cpp
@@ -256,6 +256,13 @@ void invalidate_all_camera_rects(int view_index)
     RoomCamRects[view_index].NumDirtyRegions = WHOLESCREENDIRTY;
 }

+void swap_pos(int &a, int &b)
+{
+    int tmp = a;
+    a = b;
+    b = tmp;
+}
+
 void invalidate_rect_on_surf(int x1, int y1, int x2, int y2, DirtyRects &rects)
 {
     if (rects.DirtyRows.size() == 0)
@@ -266,9 +273,15 @@ void invalidate_rect_on_surf(int x1, int y1, int x2, int y2, DirtyRects &rects)
         return;
     }

+    if(x1 > x2) swap_pos(x1, x2);
+    if(y1 > y2) swap_pos(y1, y2);
+
     int a;

     const Size &surfsz = rects.SurfaceSize;
+
+    if(x1 >= surfsz.Width || y1 >= surfsz.Height || x2 < 0 || y2 < 0) return;
+
     if (x1 >= surfsz.Width) x1 = surfsz.Width - 1;
     if (y1 >= surfsz.Height) y1 = surfsz.Height - 1;
     if (x2 >= surfsz.Width) x2 = surfsz.Width - 1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: graphics type: bug unexpected/erroneous behavior in the existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants