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
Comments
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 after some research i know why your fix is not correct: 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. |
Alternative solution to CorsixTH#629, fixes CorsixTH#646
@Andy51, nice catch! |
Looking at a bug reported by @pwaller, I noticed an interesting fact:
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.
The text was updated successfully, but these errors were encountered: