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

Fix invalid texture sizes #250

Merged
merged 1 commit into from
Dec 18, 2022
Merged

Fix invalid texture sizes #250

merged 1 commit into from
Dec 18, 2022

Conversation

parasyte
Copy link
Owner

@parasyte parasyte commented Jan 8, 2022

  • Makes methods fallible when they create textures.
  • Breaking changes:
    • Pixels::Error is now marked #[non_exhaustive]
    • Pixels::resize_buffer() and Pixels::resize_surface() return Result<_, TextureError>.
    • Pixels::resize_buffer() no longer panics on invalid inputs.
  • Correctly handle window resize in fltk example.
  • TODO: tests
  • Closes Properly handle dubious texture sizes #240

I haven't written any tests for this, because I still don't have a great solution to the issue raised in #80.

This does add a lot of noise to the examples. I can perhaps address some of that with Result transformation methods. The "print error and exit event loop" pattern is very common in these examples but might need more intelligent handling in a real application.

width: u32,
height: u32,
) -> Result<(), TextureError> {
let limits = device.limits();
Copy link
Owner Author

@parasyte parasyte Feb 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will probably be better to store the limits in the constructor instead of making this call each time. I don't know what the exact overhead is, but we only need one of many limits here, and the limit is static. This function will be called rapidly during window resizes (dragging the corner of the window with the mouse).

- Makes methods fallible when they create textures.
- Correctly handle window resize in fltk example.
- TODO: tests
- Closes #240
@parasyte parasyte merged commit 6f4fa6c into main Dec 18, 2022
@parasyte parasyte deleted the fix/invalid-texture-size branch December 18, 2022 04:21
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.

Properly handle dubious texture sizes
1 participant