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

setClipRect on the return value of getClipRect not always a no-op. #629

Closed
jorgenpt opened this issue Jan 23, 2015 · 4 comments
Closed

setClipRect on the return value of getClipRect not always a no-op. #629

jorgenpt opened this issue Jan 23, 2015 · 4 comments

Comments

@jorgenpt
Copy link
Contributor

Looking at a bug reported by @pwaller, I noticed an interesting fact:

THClipRect rc = {};
pCanvas->getClipRect(&rc) 
pCanvas->setClipRect(&rc);

Is not guaranteed to return the clip rect to the original state. I don't know if we ever render something without a clip rect (we might not), but if we have clipping disabled, then getClipRect returns an empty clip rect (0x0 size.) setClipRect() has special casing for empty cliprects, converting them to out-of-bounds clipping, so that nothing is ever rendered.

This is because SDL and CTH has different notions of what an empty clip-rect means: We say it's clip every pixel, SDL says it's clip none of the pixels. The right solution might be to have THClipRect contain a "clip_enabled" field, and use that to convert rects to & from SDL convention.

pwaller added a commit to pwaller/CorsixTH that referenced this issue Jan 23, 2015
@pwaller
Copy link
Contributor

pwaller commented Jan 24, 2015

So my attempt at fixing this doesn't solve the bug I was complaining about (graphics cease updating after some minutes of gameplay).

However, disabling the clipping entirely does fix the bug!

@pwaller
Copy link
Contributor

pwaller commented Jan 28, 2015

@jorgenpt so we have to solve this mystery, why doesn't #629 fix the problem, but disabling clipping entirely does?

@Andy51
Copy link
Contributor

Andy51 commented Feb 1, 2015

@pwaller after some research i know why your fix is not correct:
it only handles

THClipRect rc = {};
pCanvas->getClipRect(&rc);
pCanvas->setClipRect(&rc);

case, but not the

local x_, y_, w, h = canvas:getClip()
canvas:setClip(x_, y_, w, h)

so in order to have correct mapping of SDL behavior to TH expected behavior, we have to return nonempty clip rect when clipping disabled, like canvas size.

Andy51 added a commit to Andy51/CorsixTH that referenced this issue Feb 1, 2015
@jorgenpt
Copy link
Contributor Author

jorgenpt commented Feb 7, 2015

@Andy51, nice catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants