|
2 | 2 | extern crate vulkano;
|
3 | 3 | extern crate vulkano_win;
|
4 | 4 | extern crate winit;
|
| 5 | +extern crate cgmath; |
5 | 6 |
|
6 | 7 | use std::sync::{Arc, Mutex};
|
7 | 8 | use std::collections::HashSet;
|
@@ -61,6 +62,13 @@ use vulkano::descriptor::descriptor_set::{
|
61 | 62 | FixedSizeDescriptorSetsPool,
|
62 | 63 | FixedSizeDescriptorSet
|
63 | 64 | };
|
| 65 | +use cgmath::{ |
| 66 | + Rad, |
| 67 | + Deg, |
| 68 | + Matrix4, |
| 69 | + Vector3, |
| 70 | + Point3 |
| 71 | +}; |
64 | 72 |
|
65 | 73 | const WIDTH: u32 = 800;
|
66 | 74 | const HEIGHT: u32 = 600;
|
@@ -111,9 +119,9 @@ impl_vertex!(Vertex, pos, color);
|
111 | 119 | #[allow(dead_code)]
|
112 | 120 | #[derive(Copy, Clone)]
|
113 | 121 | struct UniformBufferObject {
|
114 |
| - model: glm::Mat4, |
115 |
| - view: glm::Mat4, |
116 |
| - proj: glm::Mat4, |
| 122 | + model: Matrix4<f32>, |
| 123 | + view: Matrix4<f32>, |
| 124 | + proj: Matrix4<f32>, |
117 | 125 | }
|
118 | 126 |
|
119 | 127 | fn vertices() -> [Vertex; 4] {
|
@@ -727,28 +735,22 @@ impl HelloTriangleApplication {
|
727 | 735 | let duration = Instant::now().duration_since(start_time);
|
728 | 736 | let elapsed = (duration.as_secs() * 1000) + u64::from(duration.subsec_millis());
|
729 | 737 |
|
730 |
| - let identity_matrix = glm::mat4( |
731 |
| - 1.0, 0.0, 0.0, 0.0, |
732 |
| - 0.0, 1.0, 0.0, 0.0, |
733 |
| - 0.0, 0.0, 1.0, 0.0, |
734 |
| - 0.0, 0.0, 0.0, 1.0, |
735 |
| - ); |
736 |
| - |
737 |
| - let model = glm::ext::rotate(&identity_matrix, (elapsed as f32) * glm::radians(0.180), glm::vec3(0.0, 0.0, 1.00)); |
| 738 | + let model = Matrix4::from_angle_z(Rad::from(Deg(elapsed as f32 * 0.180))); |
738 | 739 |
|
739 |
| - let view = glm::ext::look_at( |
740 |
| - glm::vec3(2.0, 2.0, 2.0), |
741 |
| - glm::vec3(0.0, 0.0, 0.0), |
742 |
| - glm::vec3(0.0, 0.0, 1.0) |
| 740 | + let view = Matrix4::look_at( |
| 741 | + Point3::new(2.0, 2.0, 2.0), |
| 742 | + Point3::new(0.0, 0.0, 0.0), |
| 743 | + Vector3::new(0.0, 0.0, 1.0) |
743 | 744 | );
|
744 |
| - let mut proj = glm::ext::perspective( |
745 |
| - glm::radians(45.0,), |
| 745 | + |
| 746 | + let mut proj = cgmath::perspective( |
| 747 | + Rad::from(Deg(45.0)), |
746 | 748 | dimensions[0] as f32 / dimensions[1] as f32,
|
747 | 749 | 0.1,
|
748 | 750 | 10.0
|
749 | 751 | );
|
750 | 752 |
|
751 |
| - proj.c1.y *= -1.0; |
| 753 | + proj.y.y *= -1.0; |
752 | 754 |
|
753 | 755 | UniformBufferObject { model, view, proj }
|
754 | 756 | }
|
|
0 commit comments