diff options
| author | 2015-03-07 18:18:40 -0500 | |
|---|---|---|
| committer | 2015-03-07 18:18:40 -0500 | |
| commit | 06bf4715810489548a9a3b5e9274dfc78bc3fc4d (patch) | |
| tree | a2722e2b7e1356d9cb9725f18f0561fcaf815ec1 /src/video_core | |
| parent | Merge pull request #637 from Subv/etc (diff) | |
| parent | Set framebuffer layout from EmuWindow. (diff) | |
| download | yuzu-06bf4715810489548a9a3b5e9274dfc78bc3fc4d.tar.gz yuzu-06bf4715810489548a9a3b5e9274dfc78bc3fc4d.tar.xz yuzu-06bf4715810489548a9a3b5e9274dfc78bc3fc4d.zip | |
Merge pull request #636 from bunnei/refactor-screen-win
Set framebuffer layout from EmuWindow.
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 48 | ||||
| -rw-r--r-- | src/video_core/video_core.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/video_core.h | 1 |
3 files changed, 9 insertions, 43 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index db7538ddd..95ab96340 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -254,28 +254,26 @@ void RendererOpenGL::DrawSingleScreenRotated(const TextureInfo& texture, float x | |||
| 254 | * Draws the emulated screens to the emulator window. | 254 | * Draws the emulated screens to the emulator window. |
| 255 | */ | 255 | */ |
| 256 | void RendererOpenGL::DrawScreens() { | 256 | void RendererOpenGL::DrawScreens() { |
| 257 | auto viewport_extent = GetViewportExtent(); | 257 | auto layout = render_window->GetFramebufferLayout(); |
| 258 | glViewport(viewport_extent.left, viewport_extent.top, viewport_extent.GetWidth(), viewport_extent.GetHeight()); // TODO: Or bottom? | 258 | |
| 259 | glViewport(0, 0, layout.width, layout.height); | ||
| 259 | glClear(GL_COLOR_BUFFER_BIT); | 260 | glClear(GL_COLOR_BUFFER_BIT); |
| 260 | 261 | ||
| 261 | glUseProgram(program_id); | 262 | glUseProgram(program_id); |
| 262 | 263 | ||
| 263 | // Set projection matrix | 264 | // Set projection matrix |
| 264 | std::array<GLfloat, 3*2> ortho_matrix = MakeOrthographicMatrix((float)resolution_width, (float)resolution_height); | 265 | std::array<GLfloat, 3 * 2> ortho_matrix = MakeOrthographicMatrix((float)layout.width, |
| 266 | (float)layout.height); | ||
| 265 | glUniformMatrix3x2fv(uniform_modelview_matrix, 1, GL_FALSE, ortho_matrix.data()); | 267 | glUniformMatrix3x2fv(uniform_modelview_matrix, 1, GL_FALSE, ortho_matrix.data()); |
| 266 | 268 | ||
| 267 | // Bind texture in Texture Unit 0 | 269 | // Bind texture in Texture Unit 0 |
| 268 | glActiveTexture(GL_TEXTURE0); | 270 | glActiveTexture(GL_TEXTURE0); |
| 269 | glUniform1i(uniform_color_texture, 0); | 271 | glUniform1i(uniform_color_texture, 0); |
| 270 | 272 | ||
| 271 | const float max_width = std::max((float)VideoCore::kScreenTopWidth, (float)VideoCore::kScreenBottomWidth); | 273 | DrawSingleScreenRotated(textures[0], (float)layout.top_screen.left, (float)layout.top_screen.top, |
| 272 | const float top_x = 0.5f * (max_width - VideoCore::kScreenTopWidth); | 274 | (float)layout.top_screen.GetWidth(), (float)layout.top_screen.GetHeight()); |
| 273 | const float bottom_x = 0.5f * (max_width - VideoCore::kScreenBottomWidth); | 275 | DrawSingleScreenRotated(textures[1], (float)layout.bottom_screen.left,(float)layout.bottom_screen.top, |
| 274 | 276 | (float)layout.bottom_screen.GetWidth(), (float)layout.bottom_screen.GetHeight()); | |
| 275 | DrawSingleScreenRotated(textures[0], top_x, 0, | ||
| 276 | (float)VideoCore::kScreenTopWidth, (float)VideoCore::kScreenTopHeight); | ||
| 277 | DrawSingleScreenRotated(textures[1], bottom_x, (float)VideoCore::kScreenTopHeight, | ||
| 278 | (float)VideoCore::kScreenBottomWidth, (float)VideoCore::kScreenBottomHeight); | ||
| 279 | 277 | ||
| 280 | m_current_frame++; | 278 | m_current_frame++; |
| 281 | } | 279 | } |
| @@ -292,34 +290,6 @@ void RendererOpenGL::SetWindow(EmuWindow* window) { | |||
| 292 | render_window = window; | 290 | render_window = window; |
| 293 | } | 291 | } |
| 294 | 292 | ||
| 295 | MathUtil::Rectangle<unsigned> RendererOpenGL::GetViewportExtent() { | ||
| 296 | unsigned framebuffer_width; | ||
| 297 | unsigned framebuffer_height; | ||
| 298 | std::tie(framebuffer_width, framebuffer_height) = render_window->GetFramebufferSize(); | ||
| 299 | |||
| 300 | float window_aspect_ratio = static_cast<float>(framebuffer_height) / framebuffer_width; | ||
| 301 | float emulation_aspect_ratio = static_cast<float>(resolution_height) / resolution_width; | ||
| 302 | |||
| 303 | MathUtil::Rectangle<unsigned> viewport_extent; | ||
| 304 | if (window_aspect_ratio > emulation_aspect_ratio) { | ||
| 305 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 306 | unsigned viewport_height = static_cast<unsigned>(std::round(emulation_aspect_ratio * framebuffer_width)); | ||
| 307 | viewport_extent.left = 0; | ||
| 308 | viewport_extent.top = (framebuffer_height - viewport_height) / 2; | ||
| 309 | viewport_extent.right = viewport_extent.left + framebuffer_width; | ||
| 310 | viewport_extent.bottom = viewport_extent.top + viewport_height; | ||
| 311 | } else { | ||
| 312 | // Otherwise, apply borders to the left and right sides of the window. | ||
| 313 | unsigned viewport_width = static_cast<unsigned>(std::round(framebuffer_height / emulation_aspect_ratio)); | ||
| 314 | viewport_extent.left = (framebuffer_width - viewport_width) / 2; | ||
| 315 | viewport_extent.top = 0; | ||
| 316 | viewport_extent.right = viewport_extent.left + viewport_width; | ||
| 317 | viewport_extent.bottom = viewport_extent.top + framebuffer_height; | ||
| 318 | } | ||
| 319 | |||
| 320 | return viewport_extent; | ||
| 321 | } | ||
| 322 | |||
| 323 | /// Initialize the renderer | 293 | /// Initialize the renderer |
| 324 | void RendererOpenGL::Init() { | 294 | void RendererOpenGL::Init() { |
| 325 | render_window->MakeCurrent(); | 295 | render_window->MakeCurrent(); |
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 0a236595c..b9d4ede3a 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp | |||
| @@ -18,7 +18,6 @@ namespace VideoCore { | |||
| 18 | 18 | ||
| 19 | EmuWindow* g_emu_window = nullptr; ///< Frontend emulator window | 19 | EmuWindow* g_emu_window = nullptr; ///< Frontend emulator window |
| 20 | RendererBase* g_renderer = nullptr; ///< Renderer plugin | 20 | RendererBase* g_renderer = nullptr; ///< Renderer plugin |
| 21 | int g_current_frame = 0; | ||
| 22 | 21 | ||
| 23 | /// Initialize the video core | 22 | /// Initialize the video core |
| 24 | void Init(EmuWindow* emu_window) { | 23 | void Init(EmuWindow* emu_window) { |
| @@ -27,8 +26,6 @@ void Init(EmuWindow* emu_window) { | |||
| 27 | g_renderer->SetWindow(g_emu_window); | 26 | g_renderer->SetWindow(g_emu_window); |
| 28 | g_renderer->Init(); | 27 | g_renderer->Init(); |
| 29 | 28 | ||
| 30 | g_current_frame = 0; | ||
| 31 | |||
| 32 | LOG_DEBUG(Render, "initialized OK"); | 29 | LOG_DEBUG(Render, "initialized OK"); |
| 33 | } | 30 | } |
| 34 | 31 | ||
diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h index b782f17bd..1b51d39bf 100644 --- a/src/video_core/video_core.h +++ b/src/video_core/video_core.h | |||
| @@ -30,7 +30,6 @@ static const int kScreenBottomHeight = 240; ///< 3DS bottom screen height | |||
| 30 | // --------------------- | 30 | // --------------------- |
| 31 | 31 | ||
| 32 | extern RendererBase* g_renderer; ///< Renderer plugin | 32 | extern RendererBase* g_renderer; ///< Renderer plugin |
| 33 | extern int g_current_frame; ///< Current frame | ||
| 34 | extern EmuWindow* g_emu_window; ///< Emu window | 33 | extern EmuWindow* g_emu_window; ///< Emu window |
| 35 | 34 | ||
| 36 | /// Start the video core | 35 | /// Start the video core |