-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Experimental viewports #1389
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
Closed
Closed
Experimental viewports #1389
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ce59eff
Add Viewport component to the camera bundles
rmsc 8686fd1
Account for viewport scale factor in the render pass.
rmsc cef5e9f
Automatically resize viewports in relation to their parent surface
rmsc e8661e5
Rename viewports system, it does more than handle resizes.
rmsc 1cfed6a
Make the location of the Viewport sides linearly independent.
rmsc 321a334
Fix the 'multiple_windows' example after the changes to the Camera sy…
rmsc c0da856
Fix viewport size clamping, add support for a few more std::ops
rmsc 65017aa
Make the viewport system iterate over viewports rather than windows.
rmsc 2c4b1e4
Add viewport example.
rmsc 510e4a0
Move surface and viewport related code to its own 'surface' module.
rmsc c21c606
Rename ViewportSideLocation to just SideLocation, fix viewport clamping
rmsc 18d86ab
Make Viewport fields 'origin' and 'size' private
rmsc 319c7c1
Show how to swap viewports in the 'viewports' example
rmsc 54a1032
Update the examples README.md
rmsc 89d90b0
Use HashSet instead of HashMap for storing changed window ids.
rmsc 7fa410f
Chain camera-related systems
rmsc c0cc3ca
Use const strings as node/camera names.
rmsc e2ad8f7
Add support for viewport depth ranges.
rmsc d3f971c
Use RangeInclusive uniformly in the viewport depth range API
rmsc ef79790
Fix cargo fmt
rmsc afe0165
Panic when attempting to render with a Camera without Viewport.
rmsc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
mod viewport; | ||
|
||
pub use viewport::*; | ||
|
||
use crate::renderer::TextureId; | ||
use bevy_window::WindowId; | ||
|
||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] | ||
pub enum SurfaceId { | ||
Window(WindowId), | ||
Texture(TextureId), | ||
} | ||
|
||
impl SurfaceId { | ||
pub fn get_window(&self) -> Option<WindowId> { | ||
if let SurfaceId::Window(id) = self { | ||
Some(*id) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
pub fn get_texture(&self) -> Option<TextureId> { | ||
if let SurfaceId::Texture(id) = self { | ||
Some(*id) | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
impl Default for SurfaceId { | ||
fn default() -> Self { | ||
WindowId::primary().into() | ||
} | ||
} | ||
|
||
impl From<WindowId> for SurfaceId { | ||
fn from(value: WindowId) -> Self { | ||
SurfaceId::Window(value) | ||
} | ||
} | ||
|
||
impl From<TextureId> for SurfaceId { | ||
fn from(value: TextureId) -> Self { | ||
SurfaceId::Texture(value) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm implementing an offscreeen rendering plugin on top of this, and found the Texture variant a bit awkward to use.
Perhaps I should be using a
Handle<Texture>
here instead?