Actually do anaglyph
This commit is contained in:
+31
@@ -3,6 +3,7 @@ use imgui_wgpu::{Renderer, RendererConfig};
|
||||
use imgui_winit_support::WinitPlatform;
|
||||
use pollster::block_on;
|
||||
use std::{sync::Arc, time::Instant};
|
||||
use wgpu::util::DeviceExt as _;
|
||||
#[cfg(target_os = "windows")]
|
||||
use winit::platform::windows::{CornerPreference, WindowAttributesExtWindows as _};
|
||||
use winit::{
|
||||
@@ -79,6 +80,15 @@ impl AppWindow {
|
||||
}));
|
||||
let eyes = eyes.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor::default());
|
||||
let colors = Colors {
|
||||
left: [1.0, 0.0, 0.0, 1.0],
|
||||
right: [0.0, 0.7734375, 0.9375, 1.0],
|
||||
};
|
||||
let color_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("colors"),
|
||||
contents: bytemuck::bytes_of(&colors),
|
||||
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
|
||||
});
|
||||
let texture_bind_group_layout =
|
||||
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: Some("texture bind group layout"),
|
||||
@@ -99,6 +109,16 @@ impl AppWindow {
|
||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 2,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Buffer {
|
||||
ty: wgpu::BufferBindingType::Uniform,
|
||||
has_dynamic_offset: false,
|
||||
min_binding_size: None,
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
],
|
||||
});
|
||||
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
@@ -113,6 +133,10 @@ impl AppWindow {
|
||||
binding: 1,
|
||||
resource: wgpu::BindingResource::Sampler(&sampler),
|
||||
},
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 2,
|
||||
resource: color_buf.as_entire_binding(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -438,3 +462,10 @@ impl ApplicationHandler for App {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
|
||||
#[repr(C)]
|
||||
struct Colors {
|
||||
left: [f32; 4],
|
||||
right: [f32; 4],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user