From e6a0a30334c2b9d869ba3a1d2f189e2d6308c956 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 28 Nov 2019 20:36:02 -0300 Subject: [PATCH] renderer_opengl: Make ScreenRectVertex's constructor constexpr --- .../renderer_opengl/renderer_opengl.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index aa837eb95..bba16afaf 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -66,17 +66,12 @@ constexpr GLint PositionLocation = 0; constexpr GLint TexCoordLocation = 1; constexpr GLint ModelViewMatrixLocation = 0; -/// Vertex structure that the drawn screen rectangles are composed of. struct ScreenRectVertex { - ScreenRectVertex(GLfloat x, GLfloat y, GLfloat u, GLfloat v) { - position[0] = x; - position[1] = y; - tex_coord[0] = u; - tex_coord[1] = v; - } + constexpr ScreenRectVertex(GLfloat x, GLfloat y, GLfloat u, GLfloat v) + : position{{x, y}}, tex_coord{{u, v}} {} - GLfloat position[2]; - GLfloat tex_coord[2]; + std::array position; + std::array tex_coord; }; /** @@ -383,18 +378,18 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x, static_cast(screen_info.texture.height); } - std::array vertices = {{ + const std::array vertices = { ScreenRectVertex(x, y, texcoords.top * scale_u, left * scale_v), ScreenRectVertex(x + w, y, texcoords.bottom * scale_u, left * scale_v), ScreenRectVertex(x, y + h, texcoords.top * scale_u, right * scale_v), ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v), - }}; + }; state.textures[0] = screen_info.display_texture; state.framebuffer_srgb.enabled = screen_info.display_srgb; state.AllDirty(); state.Apply(); - glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), vertices.data()); + glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), std::data(vertices)); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Restore default state state.framebuffer_srgb.enabled = false;