diff options
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 22 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 1 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 1930fa6ef..7810b9147 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -154,6 +154,7 @@ void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuf // Framebuffer orientation handling framebuffer_transform_flags = framebuffer.transform_flags; + framebuffer_crop_rect = framebuffer.crop_rect; // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default // only allows rows to have a memory alignement of 4. @@ -320,11 +321,24 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x, } } + ASSERT_MSG(framebuffer_crop_rect.top == 0, "Unimplemented"); + ASSERT_MSG(framebuffer_crop_rect.left == 0, "Unimplemented"); + + // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering + // (e.g. handheld mode) on a 1920x1080 framebuffer. + f32 scale_u = 1.f, scale_v = 1.f; + if (framebuffer_crop_rect.GetWidth() > 0) { + scale_u = static_cast<f32>(framebuffer_crop_rect.GetWidth()) / screen_info.texture.width; + } + if (framebuffer_crop_rect.GetHeight() > 0) { + scale_v = static_cast<f32>(framebuffer_crop_rect.GetHeight()) / screen_info.texture.height; + } + std::array<ScreenRectVertex, 4> vertices = {{ - ScreenRectVertex(x, y, texcoords.top, left), - ScreenRectVertex(x + w, y, texcoords.bottom, left), - ScreenRectVertex(x, y + h, texcoords.top, right), - ScreenRectVertex(x + w, y + h, texcoords.bottom, right), + 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.texture_units[0].texture_2d = screen_info.display_texture; diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index fd0267cf5..59d92a3dc 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -97,4 +97,5 @@ private: /// Used for transforming the framebuffer orientation Tegra::FramebufferConfig::TransformFlags framebuffer_transform_flags; + MathUtil::Rectangle<int> framebuffer_crop_rect; }; |