Skip to content

Conversation

@smcv
Copy link
Contributor

@smcv smcv commented Dec 19, 2025

In older versions of "classic" SDL2, including the 2.32.x series, intersecting an empty rectangle with another rectangle would have an empty result (w=0, h=0) with an uninitialized position (x, y arbitrary). However, SDL upstream considers this to be a bug, and it caused observable visual issues in some older games when used in conjunction with sdl12-compat.

This test previously asserted that the clip rectangle would not be equal to the requested clip rectangle, but that was only true because of this bug: the uninitialized x and y coordinates were very unlikely to be equal to the requested rectangle. With the bug fix in sdl2-compat, the coordinates come out as equal to those that were requested.

If SDL2 is sufficiently new, assert that the comparison result is true (which is the correct result according to SDL upstream), and if not, make no assertion (in case the bug fix is backported).

Resolves: #289

Merge Checklist

  • the PR has been reviewed and all comments are resolved
  • all CI checks pass
  • (if applicable): the PR description includes the phrase closes #<issue-number> to automatically close an issue
  • (if applicable): bug fixes, new features, or API changes are documented in news.rst

In older versions of "classic" SDL2, including the 2.32.x series,
intersecting an empty rectangle with another rectangle would have an
empty result (w=0, h=0) with an uninitialized position (x, y arbitrary).
However, SDL upstream considers this to be a bug, and it caused
observable visual issues in some older games when used in conjunction
with sdl12-compat.

This test previously asserted that the clip rectangle would not be equal
to the requested clip rectangle, but that was only true because of
this bug: the uninitialized x and y coordinates were very unlikely to be
equal to the requested rectangle. With the bug fix in sdl2-compat,
the coordinates come out as equal to those that were requested.

If SDL2 is sufficiently new, assert that the comparison result is true
(which is the correct result according to SDL upstream), and if not,
make no assertion (in case the bug fix is backported).

Resolves: py-sdl#289
Signed-off-by: Simon McVittie <[email protected]>
@smcv
Copy link
Contributor Author

smcv commented Dec 20, 2025

I don't know whether there will ever be a 2.34.x release for "classic" SDL2 (my guess would be no), but the SDL2 branch that would be the starting point for it has the same behaviour change as in SDL3.

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

Successfully merging this pull request may close these issues.

Test failure: test_SDL_GetSetClipRect

1 participant