-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Vita: Fixed absence of clipping when viewport is set #13194
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
Conversation
43b4d75
to
c433cbf
Compare
This fix is much better than the existing behavior, but I think it might not handle the case where a manually-specified clip rect is larger than the viewport. |
A good case, then it's need to cut down the clip rect when viewport is set, and rectangle is out of viewport's range. |
@slouken, ping? I also made the limiting of the scope so true croprect will never go out of viewport's range. And I tested that behaviour on my end already. Now it should be ready to merge, but if any objections, please tell me what I should to change in the code, and I'll apply that as fast as possible. |
@@ -826,6 +826,35 @@ static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) | |||
return 0; | |||
} | |||
|
|||
static void ClamCliprectToViewport(SDL_Rect *clip, const SDL_Rect *viewport) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be ClampCliprectToViewport
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just use SDL_GetRectIntersection()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downstream application is using SDL2 which I think doesn't currentlyinclude this routine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
ClampCliprectToViewport
?
I just forgot the word (you know I am not English speaker), ye, it was "clamp", not "clam" (which is a mollusk).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just use
SDL_GetRectIntersection()
?
If it does the same as my ClamCliprectToViewport
, then I definitely should use that. Let me check that first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I checked this twice more, and result is still the same messy, it absolutely not what should be. Let me try to reformat my code so it can be better compared to yours...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s fine, I was just curious whether a rect intersection is what you were doing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is more specific, and it's required to do this very carefully, otherwise thing will glitch as I shown. In the scope of viewport, cliprect must be aligned to the viewport's 0, and then clamped in a different way. I just do subtract the difference of max points from the width, and that works just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, my summary:
- Use of
SDL_IntersectRect
requires overcomplication outside to comply with the required output. - The current output of
SDL_IntersectRect
is totally not same as expected by the current logic.
The custom function was done in order to don't duplicate multiple modified rectangle copies and just use existing values of existing rectangles to fill the proper pre-computed result without overcopmlication.
Don't allow cliprect be larger than viewport's scope
85edf9c
to
732a72f
Compare
I went ahead and merged this. Can you make a similar PR for SDL3? |
Let me make an attempt... |
Resolves a problem of viewport on the Vita set by
SDL_RenderSetViewport()
that doesn't sets any clipping by default.How it looked before the fix:

How it supposed to look everywhere (after fix):

Description
This solution sets the cliprect in shadow when real cliprect is unused. And when cliprect gets reset, the viewport's rect gets set when viewport is set (the width and height gets compared to the size of the drawable area such as screen or texture).
Existing Issue(s)
#13034