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

hidpi swap chains #973

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ impl Node for WindowTextureNode {
render_resource_context.remove_texture(old_texture);
}

self.descriptor.size.width = window.width();
self.descriptor.size.height = window.height();
self.descriptor.size.width = window.scaled_width();
self.descriptor.size.height = window.scaled_height();
let texture_resource = render_resource_context.create_texture(self.descriptor);
output.set(WINDOW_TEXTURE, RenderResourceId::Texture(texture_resource));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_wgpu/src/wgpu_type_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ impl WgpuFrom<&Window> for wgpu::SwapChainDescriptor {
wgpu::SwapChainDescriptor {
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
format: TextureFormat::default().wgpu_into(),
width: window.width(),
height: window.height(),
width: window.scaled_width(),
height: window.scaled_height(),
present_mode: if window.vsync() {
wgpu::PresentMode::Mailbox
} else {
Expand Down
8 changes: 8 additions & 0 deletions crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ impl Window {
self.width
}

pub fn scaled_width(&self) -> u32 {
(self.width as f64 * self.scale_factor) as u32
}

pub fn scaled_height(&self) -> u32 {
(self.height as f64 * self.scale_factor) as u32
}

#[inline]
pub fn height(&self) -> u32 {
self.height
Expand Down