-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix issues with GLScissorStack #229
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
Open
nazgee
wants to merge
2
commits into
nicolasgramlich:GLES2-AnchorCenter
Choose a base branch
from
nazgee:for-nicolas-scissors-issues
base: GLES2-AnchorCenter
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Doesn't this get a value that's not set?
I.e. when the stack has been pushed once,
this.mScissorStackOffsetis at4. Any value>= 4is an uninitialized value, isn't it?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.
No, it will be fine. Indeed, after
glPushScissoris called oncethis.mScissorStackOffsetequals4, but this is where the scissor rectangle is stashed (indexes 4-7).After each push
this.mScissorStackOffsetpoints to the values that were just stashed, instead to the empty space on stack. As a result, when we new value is pushed (i.e. in case ofClipEntityattached anotherClipEntity) we're intersecting it with previously pushed rectangle (perfectly valid value)Without these fixes code is pushing/popping like this: 123/321
It should be done like this: 123/21X (where X means no scissors)
Regular stack behaviour is of no use here.
After calling
glPushScissorn-times andglPopScissoronce we do not want to have n-th value, but (n-1)After calling
glPushScissorn-times and thenglPopScissorn-times, we do not want to have the first value that was pushed. We want to have an infinite rectangle instead.Just have a look at "detailed call stack" below. It will be a little bit more apparent.
glPushScissorrectangle A pushed; mScissorStackOffset is 4 after this method; no intersection done, A is saved at4-7glPushScissorrectangle B pushed; mScissorStackOffset is 8 after this method; proper intersection taken, B' is saved at8-11glPushScissorrectangle C pushed; mScissorStackOffset is 12 after this method; proper intersection taken, C' is saved at12-15glPopScissorrectangle B' is restored (it is read from8-11); mScissorStackOffset is8after this methodglPopScissorrectangle A is restored (it is read from4-7); mScissorStackOffset is4after this methodglPopScissorno scissor is used (it is read from0-3); mScissorStackOffset is0after this method; this IS nasty since nothing was pushed at this position, and this value is uninitialized, but bear with me, please.Right now It works fine, because
glDisablewill disable scissors anyway, so it does not matter what we read here. We might want to change behaviour to read something explicit, but I have no idea what should be considered as a default/empty/no_clip value for scissors. Maybe(-inf,-inf, inf, inf)? Or(0, 0, 0, 0)? I do not have any idea. If you'll come up with a good no_clip values they should be stored to the bottom (0-3) of the stack in the constructor- it does not matter forClipEntity, however.