mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 16:25:31 +00:00
Add correct matrices to the viewport
This commit is contained in:
parent
823a635007
commit
ffdd45ae11
@ -15,6 +15,7 @@ glsl-to-spirv = { path = "../glsl-to-spirv" }
|
||||
vulkano-shaders = { path = "../vulkano-shaders" }
|
||||
|
||||
[dev-dependencies]
|
||||
cgmath = "0.7.0"
|
||||
gdi32-sys = "*"
|
||||
kernel32-sys = "*"
|
||||
user32-sys = "*"
|
||||
|
@ -2,6 +2,7 @@ extern crate kernel32;
|
||||
extern crate gdi32;
|
||||
extern crate user32;
|
||||
extern crate winapi;
|
||||
extern crate cgmath;
|
||||
|
||||
#[macro_use]
|
||||
extern crate vulkano;
|
||||
@ -34,8 +35,7 @@ fn main() {
|
||||
.expect("couldn't find a graphical queue family");
|
||||
|
||||
let (device, queues) = vulkano::device::Device::new(&physical, physical.supported_features(),
|
||||
[(queue, 0.5)].iter().cloned(),
|
||||
&[])
|
||||
[(queue, 0.5)].iter().cloned(), &[])
|
||||
.expect("failed to create device");
|
||||
let queue = queues.into_iter().next().unwrap();
|
||||
|
||||
@ -80,18 +80,17 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let proj = cgmath::perspective(cgmath::rad(3.141592 / 2.0), { let d = images[0].dimensions(); d[1] as f32 / d[0] as f32 }, 0.01, 100.0);
|
||||
let view = cgmath::Matrix4::look_at(cgmath::Point3::new(-2.0, 0.0, 0.4), cgmath::Point3::new(0.0, 0.0, 0.0), cgmath::Vector3::new(0.0, -1.0 /* FIXME */, 0.0));
|
||||
let scale = cgmath::Matrix4::from_scale(0.01);
|
||||
|
||||
let uniform_buffer = vulkano::buffer::Buffer::<[[f32; 4]; 4], _>
|
||||
::new(&device, &vulkano::buffer::Usage::all(),
|
||||
vulkano::memory::HostVisible, &queue)
|
||||
.expect("failed to create buffer");
|
||||
{
|
||||
let mut mapping = uniform_buffer.try_write().unwrap();
|
||||
*mapping = [
|
||||
[0.01, 0.0, 0.0, 0.0],
|
||||
[0.0, 0.01, 0.0, 0.0],
|
||||
[0.0, 0.0, 1.0, 0.0],
|
||||
[0.0, 0.0, 0.0, 1.0]
|
||||
];
|
||||
*mapping = (proj * view * scale).into();
|
||||
}
|
||||
|
||||
mod vs { include!{concat!(env!("OUT_DIR"), "/examples-teapot_vs.rs")} }
|
||||
|
@ -453,8 +453,34 @@ pub struct ImagePrototype<Ty, F, M> where Ty: ImageTypeMarker {
|
||||
}
|
||||
|
||||
impl<Ty, F, M> ImagePrototype<Ty, F, M>
|
||||
where Ty: ImageTypeMarker
|
||||
where M: MemorySourceChunk, Ty: ImageTypeMarker, F: FormatMarker
|
||||
{
|
||||
/// Returns the dimensions of this image.
|
||||
#[inline]
|
||||
pub fn dimensions(&self) -> Ty::Dimensions {
|
||||
self.image.dimensions()
|
||||
}
|
||||
|
||||
/// Returns the number of array layers of this image.
|
||||
#[inline]
|
||||
pub fn array_layers(&self) -> u32 {
|
||||
self.image.array_layers()
|
||||
}
|
||||
|
||||
/// Returns the number of mipmap levels of this image.
|
||||
#[inline]
|
||||
pub fn mipmap_levels(&self) -> u32 {
|
||||
self.image.mipmap_levels()
|
||||
}
|
||||
|
||||
/// Returns the number of samples of each pixel of this image.
|
||||
///
|
||||
/// Returns `1` if the image is not multisampled.
|
||||
#[inline]
|
||||
pub fn num_samples(&self) -> u32 {
|
||||
self.image.num_samples()
|
||||
}
|
||||
|
||||
/// Transitions the image prototype into a real image by submitting a one-shot command buffer.
|
||||
///
|
||||
/// # Panic
|
||||
|
Loading…
Reference in New Issue
Block a user