summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/present/present_uniforms.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/renderer_opengl/present/present_uniforms.h')
-rw-r--r--src/video_core/renderer_opengl/present/present_uniforms.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/present/present_uniforms.h b/src/video_core/renderer_opengl/present/present_uniforms.h
new file mode 100644
index 000000000..3a19f05c7
--- /dev/null
+++ b/src/video_core/renderer_opengl/present/present_uniforms.h
@@ -0,0 +1,43 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "video_core/renderer_opengl/gl_resource_manager.h"
+
+namespace OpenGL {
+
+constexpr GLint PositionLocation = 0;
+constexpr GLint TexCoordLocation = 1;
+constexpr GLint ModelViewMatrixLocation = 0;
+
+struct ScreenRectVertex {
+ constexpr ScreenRectVertex() = default;
+
+ constexpr ScreenRectVertex(u32 x, u32 y, GLfloat u, GLfloat v)
+ : position{{static_cast<GLfloat>(x), static_cast<GLfloat>(y)}}, tex_coord{{u, v}} {}
+
+ std::array<GLfloat, 2> position{};
+ std::array<GLfloat, 2> tex_coord{};
+};
+
+/**
+ * Defines a 1:1 pixel orthographic projection matrix with (0,0) on the top-left
+ * corner and (width, height) on the lower-bottom.
+ *
+ * The projection part of the matrix is trivial, hence these operations are represented
+ * by a 3x2 matrix.
+ */
+static inline std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(float width, float height) {
+ std::array<GLfloat, 3 * 2> matrix; // Laid out in column-major order
+
+ // clang-format off
+ matrix[0] = 2.f / width; matrix[2] = 0.f; matrix[4] = -1.f;
+ matrix[1] = 0.f; matrix[3] = -2.f / height; matrix[5] = 1.f;
+ // Last matrix row is implicitly assumed to be [0, 0, 1].
+ // clang-format on
+
+ return matrix;
+}
+
+} // namespace OpenGL