Construct a perspective projection matrix
| 126 | |
| 127 | // Construct a perspective projection matrix |
| 128 | void matrixPerspective(Matrix& result, sf::Angle fov, float aspect, float nearPlane, float farPlane) |
| 129 | { |
| 130 | const float a = 1.f / std::tan(fov.asRadians() / 2.f); |
| 131 | |
| 132 | result[0][0] = a / aspect; |
| 133 | result[0][1] = 0.f; |
| 134 | result[0][2] = 0.f; |
| 135 | result[0][3] = 0.f; |
| 136 | |
| 137 | result[1][0] = 0.f; |
| 138 | result[1][1] = -a; |
| 139 | result[1][2] = 0.f; |
| 140 | result[1][3] = 0.f; |
| 141 | |
| 142 | result[2][0] = 0.f; |
| 143 | result[2][1] = 0.f; |
| 144 | result[2][2] = -((farPlane + nearPlane) / (farPlane - nearPlane)); |
| 145 | result[2][3] = -1.f; |
| 146 | |
| 147 | result[3][0] = 0.f; |
| 148 | result[3][1] = 0.f; |
| 149 | result[3][2] = -((2.f * farPlane * nearPlane) / (farPlane - nearPlane)); |
| 150 | result[3][3] = 0.f; |
| 151 | } |
| 152 | |
| 153 | // Helper function we pass to GLAD to load Vulkan functions via SFML |
| 154 | GLADapiproc getVulkanFunction(const char* name) |