Add helper functions to perform NDC transformations

This commit is contained in:
Cameron Gutman
2022-04-05 00:50:04 -05:00
parent 6a0cf4bfd3
commit 940ae6406b
3 changed files with 35 additions and 13 deletions
@@ -214,13 +214,7 @@ void EGLRenderer::renderOverlay(Overlay::OverlayType type)
free(packedPixelData);
}
// SDL_FRect wasn't added until 2.0.10
struct {
float x;
float y;
float w;
float h;
} overlayRect = {};
SDL_FRect overlayRect;
// These overlay positions differ from the other renderers because OpenGL
// places the origin in the lower-left corner instead of the upper-left.
@@ -243,12 +237,7 @@ void EGLRenderer::renderOverlay(Overlay::OverlayType type)
SDL_FreeSurface(newSurface);
// Convert screen space to normalized device coordinates
overlayRect.x /= m_ViewportWidth / 2;
overlayRect.w /= m_ViewportWidth / 2;
overlayRect.y /= m_ViewportHeight / 2;
overlayRect.h /= m_ViewportHeight / 2;
overlayRect.x -= 1.0f;
overlayRect.y -= 1.0f;
StreamUtils::screenSpaceToNormalizedDeviceCoords(&overlayRect, m_ViewportWidth, m_ViewportHeight);
OVERLAY_VERTEX verts[] =
{