MCPcopy Create free account
hub / github.com/SFML/SFML / matrixPerspective

Function matrixPerspective

examples/vulkan/Vulkan.cpp:128–151  ·  view source on GitHub ↗

Construct a perspective projection matrix

Source from the content-addressed store, hash-verified

126
127// Construct a perspective projection matrix
128void 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
154GLADapiproc getVulkanFunction(const char* name)

Callers 1

updateUniformBufferMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected