| 188 | } |
| 189 | |
| 190 | Vector2 GetAspectCorrect2DPosition(const Vector2& pos) |
| 191 | { |
| 192 | constexpr auto DISPLAY_SPACE_ASPECT = DISPLAY_SPACE_RES.x / DISPLAY_SPACE_RES.y; |
| 193 | |
| 194 | auto screenRes = g_Renderer.GetScreenResolution().ToVector2(); |
| 195 | float screenResAspect = screenRes.x / screenRes.y; |
| 196 | float aspectDelta = screenResAspect - DISPLAY_SPACE_ASPECT; |
| 197 | |
| 198 | auto correctedPos = pos; |
| 199 | if (aspectDelta > EPSILON) |
| 200 | { |
| 201 | correctedPos.x *= 1.0f - (aspectDelta / 2); |
| 202 | } |
| 203 | else if (aspectDelta < -EPSILON) |
| 204 | { |
| 205 | correctedPos.y *= 1.0f - (aspectDelta / 2); |
| 206 | } |
| 207 | |
| 208 | return correctedPos; |
| 209 | } |
| 210 | |
| 211 | Vector2 Convert2DPositionToNDC(const Vector2& pos) |
| 212 | { |
no test coverage detected