| 17 | namespace su |
| 18 | { |
| 19 | glm::mat4x4 createModelViewProjectionClipMatrix( vk::Extent2D const & extent ) |
| 20 | { |
| 21 | float fov = glm::radians( 45.0f ); |
| 22 | if ( extent.width > extent.height ) |
| 23 | { |
| 24 | fov *= static_cast<float>( extent.height ) / static_cast<float>( extent.width ); |
| 25 | } |
| 26 | |
| 27 | glm::mat4x4 model = glm::mat4x4( 1.0f ); |
| 28 | glm::mat4x4 view = glm::lookAt( glm::vec3( -5.0f, 3.0f, -10.0f ), glm::vec3( 0.0f, 0.0f, 0.0f ), glm::vec3( 0.0f, -1.0f, 0.0f ) ); |
| 29 | glm::mat4x4 projection = glm::perspective( fov, 1.0f, 0.1f, 100.0f ); |
| 30 | // clang-format off |
| 31 | glm::mat4x4 clip = glm::mat4x4( 1.0f, 0.0f, 0.0f, 0.0f, |
| 32 | 0.0f, -1.0f, 0.0f, 0.0f, |
| 33 | 0.0f, 0.0f, 0.5f, 0.0f, |
| 34 | 0.0f, 0.0f, 0.5f, 1.0f ); // vulkan clip space has inverted y and half z ! |
| 35 | // clang-format on |
| 36 | return clip * projection * view * model; |
| 37 | } |
| 38 | } // namespace su |
| 39 | } // namespace vk |