diff options
author | Liam <byteslice@airmail.cc> | 2024-01-19 02:47:50 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-01-31 17:27:21 +0100 |
commit | 10cf0585180bcf2eab38ebf65dc593fecc4ddf92 (patch) | |
tree | c0c7680fd2a17b32b0baab91b31f3c25c597ccfd /src/video_core/renderer_opengl/present/present_uniforms.h | |
parent | renderer_vulkan: implement layer stack composition (diff) | |
download | yuzu-10cf0585180bcf2eab38ebf65dc593fecc4ddf92.tar yuzu-10cf0585180bcf2eab38ebf65dc593fecc4ddf92.tar.gz yuzu-10cf0585180bcf2eab38ebf65dc593fecc4ddf92.tar.bz2 yuzu-10cf0585180bcf2eab38ebf65dc593fecc4ddf92.tar.lz yuzu-10cf0585180bcf2eab38ebf65dc593fecc4ddf92.tar.xz yuzu-10cf0585180bcf2eab38ebf65dc593fecc4ddf92.tar.zst yuzu-10cf0585180bcf2eab38ebf65dc593fecc4ddf92.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/present/present_uniforms.h')
-rw-r--r-- | src/video_core/renderer_opengl/present/present_uniforms.h | 43 |
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 |