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

Don't require an aspect ratio when creating a new NavigationCubeRenderer #1584

Merged
merged 1 commit into from
Feb 14, 2023
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
13 changes: 7 additions & 6 deletions crates/fj-viewer/src/graphics/navigation_cube.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use fj_math::Transform;
use wgpu::util::DeviceExt;

use super::model::{self, load_model, DrawModel, Model};
use super::{
model::{self, load_model, DrawModel, Model},
transform,
};

#[derive(Debug)]
pub struct NavigationCubeRenderer {
Expand All @@ -19,7 +22,6 @@ impl NavigationCubeRenderer {
device: &wgpu::Device,
queue: &wgpu::Queue,
config: &wgpu::SurfaceConfiguration,
aspect_ratio: f64,
) -> Self {
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
Expand Down Expand Up @@ -48,13 +50,12 @@ impl NavigationCubeRenderer {
label: Some("texture_bind_group_layout"),
});

let mvp_matrix =
Self::get_mvp_matrix(Transform::identity(), aspect_ratio);

let mvp_matrix_buffer =
device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Model Matrix Buffer"),
contents: bytemuck::cast_slice(&[mvp_matrix]),
contents: bytemuck::cast_slice(&[
transform::Transform::identity(),
]),
usage: wgpu::BufferUsages::UNIFORM
| wgpu::BufferUsages::COPY_DST,
});
Expand Down
8 changes: 2 additions & 6 deletions crates/fj-viewer/src/graphics/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,8 @@ impl Renderer {
let pipelines =
Pipelines::new(&device, &bind_group_layout, color_format);

let navigation_cube_renderer = NavigationCubeRenderer::new(
&device,
&queue,
&surface_config,
800.0 / 600.0,
);
let navigation_cube_renderer =
NavigationCubeRenderer::new(&device, &queue, &surface_config);

Ok(Self {
surface,
Expand Down