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

Remove the manual viewport API #641

Merged
merged 12 commits into from
Aug 3, 2020
Merged

Remove the manual viewport API #641

merged 12 commits into from
Aug 3, 2020

Conversation

ryanisaacg
Copy link
Owner

@ryanisaacg ryanisaacg commented Aug 1, 2020

Setting the viewport yourself could be useful in relatively niche cases (picture-in-picture, split-screen rendering) but it mostly introduces various ways to shoot yourself in the foot. Instead, it's best to focus on setting the projection, and make setting the projection very easy.

Graphics::set_viewport has been removed, as has fit_to_surface and fit_to_window. Graphics::flush has been split into two functions, flush_surface and flush_window to handle setting the viewport.

Setting the projection introduces the same problem. set_projection has been removed, and ResizeHandlers have been integrated into the automatic viewport handling. Projection is now set automatically when rendering to the Window or the Surface, and the Surface-coordinate-space issue OpenGL introduces is resolved automatically.

A new function, Graphics::set_view, has been introduced. It allows for global transformations, between the projection and the local transform.

Cursor location can be easily calculated with the new Graphics function, screen_to_camera. This resolves #620.
The changes to the example should resolve #623.
The automatic projection resolves #631.

Checks

  • I have updated CHANGES.md, with [BREAKING] next to all breaking changes
  • I have updated the documentation if necessary
  • If 01_square example was changed, src/lib.rs and README.md were updated

@ryanisaacg ryanisaacg marked this pull request as ready for review August 3, 2020 22:38
@ryanisaacg ryanisaacg merged commit a8caf76 into master Aug 3, 2020
@ryanisaacg ryanisaacg deleted the easy-viewports branch August 3, 2020 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant