Skip to content

Commit

Permalink
fix: #61 by introducing limits
Browse files Browse the repository at this point in the history
  • Loading branch information
ElhamAryanpur committed Jun 6, 2024
1 parent d3af15a commit 62ad461
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
target
.vscode
.idea
tools
res
resources/*.png
resources/*.png
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ unsafe impl Sync for ObjectSettings {}
/// use blue_engine::header::{Engine, WindowDescriptor};
///
/// fn main() {
/// let engine = Engine::new(WindowDescriptor::default()).expect("Couldn't create the engine");
/// let engine = Engine::new().expect("Couldn't create the engine");
/// }
/// ```
/// The WindowDescriptor simply holds what features you would like for your window. If you are reading this on later version of
Expand Down Expand Up @@ -270,7 +270,7 @@ unsafe impl Sync for Renderer {}
unsafe impl Send for Renderer {}

/// Descriptor and settings for a window.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub struct WindowDescriptor {
/// The width of the window
pub width: u32,
Expand All @@ -292,6 +292,8 @@ pub struct WindowDescriptor {
pub control_flow: crate::winit::event_loop::ControlFlow,
/// The presentation mode of renderer for things like VSync
pub present_mode: crate::wgpu::PresentMode,
/// Limits to be required based on the generation of the GPU and the API
pub limits: crate::wgpu::Limits,
/// The alpha mode which specifies how the alpha channel of the textures should be handled during compositing.
pub alpha_mode: crate::wgpu::CompositeAlphaMode,
/// The desired frame latency, check [wgpu::SurfaceConfiguration::desired_maximum_frame_latency]
Expand Down Expand Up @@ -320,6 +322,7 @@ impl std::default::Default for WindowDescriptor {
},
control_flow: crate::winit::event_loop::ControlFlow::Poll,
present_mode: crate::wgpu::PresentMode::AutoNoVsync,
limits: crate::wgpu::Limits::default(),
alpha_mode: crate::wgpu::CompositeAlphaMode::Auto,
desired_maximum_frame_latency: 2,
}
Expand Down
8 changes: 4 additions & 4 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Renderer {
&wgpu::DeviceDescriptor {
label: Some("Device"),
required_features: settings.features,
required_limits: wgpu::Limits::default(),
required_limits: settings.limits,
},
None, // Trace path
)
Expand Down Expand Up @@ -185,7 +185,7 @@ impl Renderer {
/// # Arguments
/// * `new_size` - The new window size.
pub(crate) fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
// check if new_size is non zero
// check if new_size is non-zero
if new_size.width != 0 && new_size.height != 0 {
self.size = new_size;
self.config.width = new_size.width;
Expand Down Expand Up @@ -270,8 +270,8 @@ impl Renderer {
if self.scissor_rect.is_some() {
let scissor_rect = self.scissor_rect.unwrap();
// check if scissor bounds are smaller than the window
if scissor_rect.0 + scissor_rect.2 < window_size.width as u32
&& scissor_rect.1 + scissor_rect.3 < window_size.height as u32
if scissor_rect.0 + scissor_rect.2 < window_size.width
&& scissor_rect.1 + scissor_rect.3 < window_size.height
{
render_pass.set_scissor_rect(
scissor_rect.0,
Expand Down

0 comments on commit 62ad461

Please sign in to comment.