diff options
Diffstat (limited to 'stockton-render')
-rw-r--r-- | stockton-render/src/draw/context.rs | 13 | ||||
-rw-r--r-- | stockton-render/src/error.rs | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/stockton-render/src/draw/context.rs b/stockton-render/src/draw/context.rs index 349b168..b079db1 100644 --- a/stockton-render/src/draw/context.rs +++ b/stockton-render/src/draw/context.rs @@ -34,7 +34,7 @@ use hal::pool::{CommandPoolCreateFlags, CommandPool}; use hal::command::{ClearValue, ClearColor}; use hal::pso::{Rect, PipelineStage}; use hal::queue::family::QueueGroup; -use hal::window::{PresentMode}; +use hal::window::{PresentMode, Extent2D}; use hal::adapter::Adapter; use back::{Instance}; @@ -174,7 +174,16 @@ impl<'a> RenderingContext<'a> { }, }; - let extent = caps.extents.end; + let extent = { + let window_client_area = window + .get_inner_size() + .ok_or(CreationError::NoWindow)? + .to_physical(window.get_hidpi_factor()); + Extent2D { + width: caps.extents.end.width.min(window_client_area.width as u32), + height: caps.extents.end.height.min(window_client_area.height as u32) + } + }; let image_count = if present_mode == PresentMode::Mailbox { (caps.image_count.end - 1).min(3) } else { diff --git a/stockton-render/src/error.rs b/stockton-render/src/error.rs index d46328d..41fc92d 100644 --- a/stockton-render/src/error.rs +++ b/stockton-render/src/error.rs @@ -37,6 +37,7 @@ pub enum CreationError { NoCompositeAlphas, NoImageFormats, NoColor, + NoWindow, /// # Runtime SwapchainFailed (hal::window::CreationError), |