diff options
| author | 2014-10-12 18:14:57 +0200 | |
|---|---|---|
| committer | 2014-11-18 13:09:01 +0100 | |
| commit | bd8f491e4c08e9b9a7b852de0b50c144da8ac8c8 (patch) | |
| tree | b1f350a3506289263c3652f46946baf267cb27f8 /src | |
| parent | Viewport scaling and display density independence (diff) | |
| download | yuzu-bd8f491e4c08e9b9a7b852de0b50c144da8ac8c8.tar.gz yuzu-bd8f491e4c08e9b9a7b852de0b50c144da8ac8c8.tar.xz yuzu-bd8f491e4c08e9b9a7b852de0b50c144da8ac8c8.zip | |
Fixup EmuWindow interface and implementations thereof.
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.cpp | 51 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.h | 13 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.cpp | 53 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.hxx | 19 | ||||
| -rw-r--r-- | src/common/emu_window.h | 61 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 6 |
6 files changed, 127 insertions, 76 deletions
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index d0f6e9a9e..28aa3450c 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <GLFW/glfw3.h> | ||
| 6 | |||
| 5 | #include "common/common.h" | 7 | #include "common/common.h" |
| 6 | 8 | ||
| 7 | #include "video_core/video_core.h" | 9 | #include "video_core/video_core.h" |
| @@ -10,22 +12,21 @@ | |||
| 10 | 12 | ||
| 11 | #include "citra/emu_window/emu_window_glfw.h" | 13 | #include "citra/emu_window/emu_window_glfw.h" |
| 12 | 14 | ||
| 15 | EmuWindow_GLFW* EmuWindow_GLFW::GetEmuWindow(GLFWwindow* win) { | ||
| 16 | return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(win)); | ||
| 17 | } | ||
| 18 | |||
| 13 | /// Called by GLFW when a key event occurs | 19 | /// Called by GLFW when a key event occurs |
| 14 | void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) { | 20 | void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) { |
| 15 | 21 | ||
| 16 | if (!VideoCore::g_emu_window) { | 22 | int keyboard_id = GetEmuWindow(win)->keyboard_id; |
| 17 | return; | ||
| 18 | } | ||
| 19 | |||
| 20 | int keyboard_id = ((EmuWindow_GLFW*)VideoCore::g_emu_window)->keyboard_id; | ||
| 21 | 23 | ||
| 22 | if (action == GLFW_PRESS) { | 24 | if (action == GLFW_PRESS) { |
| 23 | EmuWindow::KeyPressed({key, keyboard_id}); | 25 | EmuWindow::KeyPressed({key, keyboard_id}); |
| 24 | } | 26 | } else if (action == GLFW_RELEASE) { |
| 25 | |||
| 26 | if (action == GLFW_RELEASE) { | ||
| 27 | EmuWindow::KeyReleased({key, keyboard_id}); | 27 | EmuWindow::KeyReleased({key, keyboard_id}); |
| 28 | } | 28 | } |
| 29 | |||
| 29 | HID_User::PadUpdateComplete(); | 30 | HID_User::PadUpdateComplete(); |
| 30 | } | 31 | } |
| 31 | 32 | ||
| @@ -34,8 +35,18 @@ const bool EmuWindow_GLFW::IsOpen() { | |||
| 34 | return glfwWindowShouldClose(m_render_window) == 0; | 35 | return glfwWindowShouldClose(m_render_window) == 0; |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | void EmuWindow_GLFW::GetFramebufferSize(int* fbWidth, int* fbHeight) { | 38 | void EmuWindow_GLFW::OnFramebufferResizeEvent(GLFWwindow* win, int width, int height) { |
| 38 | glfwGetFramebufferSize(m_render_window, fbWidth, fbHeight); | 39 | _dbg_assert_(GUI, width > 0); |
| 40 | _dbg_assert_(GUI, height > 0); | ||
| 41 | |||
| 42 | GetEmuWindow(win)->NotifyFramebufferSizeChanged(std::pair<unsigned,unsigned>(width, height)); | ||
| 43 | } | ||
| 44 | |||
| 45 | void EmuWindow_GLFW::OnClientAreaResizeEvent(GLFWwindow* win, int width, int height) { | ||
| 46 | _dbg_assert_(GUI, width > 0); | ||
| 47 | _dbg_assert_(GUI, height > 0); | ||
| 48 | |||
| 49 | GetEmuWindow(win)->NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(width, height)); | ||
| 39 | } | 50 | } |
| 40 | 51 | ||
| 41 | /// EmuWindow_GLFW constructor | 52 | /// EmuWindow_GLFW constructor |
| @@ -54,20 +65,30 @@ EmuWindow_GLFW::EmuWindow_GLFW() { | |||
| 54 | // GLFW on OSX requires these window hints to be set to create a 3.2+ GL context. | 65 | // GLFW on OSX requires these window hints to be set to create a 3.2+ GL context. |
| 55 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); | 66 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); |
| 56 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | 67 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); |
| 57 | 68 | ||
| 58 | m_render_window = glfwCreateWindow(VideoCore::kScreenTopWidth, | 69 | m_render_window = glfwCreateWindow(VideoCore::kScreenTopWidth, |
| 59 | (VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight), | 70 | (VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight), |
| 60 | m_window_title.c_str(), NULL, NULL); | 71 | GetWindowTitle().c_str(), NULL, NULL); |
| 61 | 72 | ||
| 62 | if (m_render_window == NULL) { | 73 | if (m_render_window == NULL) { |
| 63 | printf("Failed to create GLFW window! Exiting..."); | 74 | printf("Failed to create GLFW window! Exiting..."); |
| 64 | exit(1); | 75 | exit(1); |
| 65 | } | 76 | } |
| 66 | 77 | ||
| 67 | // Setup callbacks | ||
| 68 | glfwSetWindowUserPointer(m_render_window, this); | 78 | glfwSetWindowUserPointer(m_render_window, this); |
| 69 | glfwSetKeyCallback(m_render_window, OnKeyEvent); | ||
| 70 | 79 | ||
| 80 | // Notify base interface about window state | ||
| 81 | int width, height; | ||
| 82 | glfwGetFramebufferSize(m_render_window, &width, &height); | ||
| 83 | OnFramebufferResizeEvent(m_render_window, width, height); | ||
| 84 | |||
| 85 | glfwGetWindowSize(m_render_window, &width, &height); | ||
| 86 | OnClientAreaResizeEvent(m_render_window, width, height); | ||
| 87 | |||
| 88 | // Setup callbacks | ||
| 89 | glfwSetKeyCallback(m_render_window, OnKeyEvent); | ||
| 90 | glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent); | ||
| 91 | glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent); | ||
| 71 | 92 | ||
| 72 | DoneCurrent(); | 93 | DoneCurrent(); |
| 73 | } | 94 | } |
diff --git a/src/citra/emu_window/emu_window_glfw.h b/src/citra/emu_window/emu_window_glfw.h index e96228765..0da688a54 100644 --- a/src/citra/emu_window/emu_window_glfw.h +++ b/src/citra/emu_window/emu_window_glfw.h | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <GLFW/glfw3.h> | ||
| 8 | |||
| 9 | #include "common/emu_window.h" | 7 | #include "common/emu_window.h" |
| 10 | 8 | ||
| 9 | struct GLFWwindow; | ||
| 10 | |||
| 11 | class EmuWindow_GLFW : public EmuWindow { | 11 | class EmuWindow_GLFW : public EmuWindow { |
| 12 | public: | 12 | public: |
| 13 | EmuWindow_GLFW(); | 13 | EmuWindow_GLFW(); |
| @@ -30,12 +30,15 @@ public: | |||
| 30 | /// Whether the window is still open, and a close request hasn't yet been sent | 30 | /// Whether the window is still open, and a close request hasn't yet been sent |
| 31 | const bool IsOpen(); | 31 | const bool IsOpen(); |
| 32 | 32 | ||
| 33 | void ReloadSetKeymaps() override; | 33 | static void OnClientAreaResizeEvent(GLFWwindow* win, int width, int height); |
| 34 | 34 | ||
| 35 | /// Gets the size of the window in pixels | 35 | static void OnFramebufferResizeEvent(GLFWwindow* win, int width, int height); |
| 36 | void GetFramebufferSize(int* fbWidth, int* fbHeight); | 36 | |
| 37 | void ReloadSetKeymaps() override; | ||
| 37 | 38 | ||
| 38 | private: | 39 | private: |
| 40 | static EmuWindow_GLFW* GetEmuWindow(GLFWwindow* win); | ||
| 41 | |||
| 39 | GLFWwindow* m_render_window; ///< Internal GLFW render window | 42 | GLFWwindow* m_render_window; ///< Internal GLFW render window |
| 40 | 43 | ||
| 41 | /// Device id of keyboard for use with KeyMap | 44 | /// Device id of keyboard for use with KeyMap |
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 516e115fd..34a79b306 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp | |||
| @@ -88,20 +88,20 @@ void EmuThread::Stop() | |||
| 88 | class GGLWidgetInternal : public QGLWidget | 88 | class GGLWidgetInternal : public QGLWidget |
| 89 | { | 89 | { |
| 90 | public: | 90 | public: |
| 91 | GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(fmt, parent) | 91 | GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) |
| 92 | { | 92 | : QGLWidget(fmt, parent), parent(parent) { |
| 93 | parent_ = parent; | ||
| 94 | } | 93 | } |
| 95 | 94 | ||
| 96 | void paintEvent(QPaintEvent* ev) override | 95 | void paintEvent(QPaintEvent* ev) override { |
| 97 | { | ||
| 98 | } | 96 | } |
| 97 | |||
| 99 | void resizeEvent(QResizeEvent* ev) override { | 98 | void resizeEvent(QResizeEvent* ev) override { |
| 100 | parent_->SetClientAreaWidth(size().width()); | 99 | parent->OnClientAreaResized(ev->size().width(), ev->size().height()); |
| 101 | parent_->SetClientAreaHeight(size().height()); | 100 | parent->OnFramebufferSizeChanged(); |
| 102 | } | 101 | } |
| 102 | |||
| 103 | private: | 103 | private: |
| 104 | GRenderWindow* parent_; | 104 | GRenderWindow* parent; |
| 105 | }; | 105 | }; |
| 106 | 106 | ||
| 107 | EmuThread& GRenderWindow::GetEmuThread() | 107 | EmuThread& GRenderWindow::GetEmuThread() |
| @@ -120,16 +120,23 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this | |||
| 120 | fmt.setProfile(QGLFormat::CoreProfile); | 120 | fmt.setProfile(QGLFormat::CoreProfile); |
| 121 | // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X | 121 | // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X |
| 122 | fmt.setOption(QGL::NoDeprecatedFunctions); | 122 | fmt.setOption(QGL::NoDeprecatedFunctions); |
| 123 | 123 | ||
| 124 | child = new GGLWidgetInternal(fmt, this); | 124 | child = new GGLWidgetInternal(fmt, this); |
| 125 | QBoxLayout* layout = new QHBoxLayout(this); | 125 | QBoxLayout* layout = new QHBoxLayout(this); |
| 126 | resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight); | 126 | resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight); |
| 127 | layout->addWidget(child); | 127 | layout->addWidget(child); |
| 128 | layout->setMargin(0); | 128 | layout->setMargin(0); |
| 129 | setLayout(layout); | 129 | setLayout(layout); |
| 130 | QObject::connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); | 130 | connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); |
| 131 | |||
| 132 | OnFramebufferSizeChanged(); | ||
| 133 | NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height())); | ||
| 131 | 134 | ||
| 132 | BackupGeometry(); | 135 | BackupGeometry(); |
| 136 | |||
| 137 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) | ||
| 138 | connect(this->windowHandle(), SIGNAL(screenChanged(QScreen*)), this, SLOT(OnFramebufferSizeChanged())); | ||
| 139 | #endif | ||
| 133 | } | 140 | } |
| 134 | 141 | ||
| 135 | void GRenderWindow::moveContext() | 142 | void GRenderWindow::moveContext() |
| @@ -182,22 +189,26 @@ void GRenderWindow::PollEvents() { | |||
| 182 | */ | 189 | */ |
| 183 | } | 190 | } |
| 184 | 191 | ||
| 185 | // On Qt 5.1+, this correctly gets the size of the framebuffer (pixels). | 192 | // On Qt 5.0+, this correctly gets the size of the framebuffer (pixels). |
| 186 | // | 193 | // |
| 187 | // Older versions get the window size (density independent pixels), | 194 | // Older versions get the window size (density independent pixels), |
| 188 | // and hence, do not support DPI scaling ("retina" displays). | 195 | // and hence, do not support DPI scaling ("retina" displays). |
| 189 | // The result will be a viewport that is smaller than the extent of the window. | 196 | // The result will be a viewport that is smaller than the extent of the window. |
| 190 | void GRenderWindow::GetFramebufferSize(int* fbWidth, int* fbHeight) | 197 | void GRenderWindow::OnFramebufferSizeChanged() |
| 191 | { | 198 | { |
| 192 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | 199 | // Screen changes potentially incur a change in screen DPI, hence we should update the framebuffer size |
| 193 | int pixelRatio = child->QPaintDevice::devicePixelRatio(); | 200 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
| 194 | 201 | // windowHandle() might not be accessible until the window is displayed to screen. | |
| 195 | *fbWidth = child->QPaintDevice::width() * pixelRatio; | 202 | auto pixel_ratio = windowHandle() ? (windowHandle()->screen()->devicePixelRatio()) : 1.0; |
| 196 | *fbHeight = child->QPaintDevice::height() * pixelRatio; | 203 | |
| 204 | unsigned width = child->QPaintDevice::width() * pixel_ratio; | ||
| 205 | unsigned height = child->QPaintDevice::height() * pixel_ratio; | ||
| 197 | #else | 206 | #else |
| 198 | *fbWidth = child->QPaintDevice::width(); | 207 | unsigned width = child->QPaintDevice::width(); |
| 199 | *fbHeight = child->QPaintDevice::height(); | 208 | unsigned height = child->QPaintDevice::height(); |
| 200 | #endif | 209 | #endif |
| 210 | |||
| 211 | NotifyFramebufferSizeChanged(std::make_pair(width, height)); | ||
| 201 | } | 212 | } |
| 202 | 213 | ||
| 203 | void GRenderWindow::BackupGeometry() | 214 | void GRenderWindow::BackupGeometry() |
| @@ -260,3 +271,7 @@ void GRenderWindow::ReloadSetKeymaps() | |||
| 260 | KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN); | 271 | KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN); |
| 261 | } | 272 | } |
| 262 | 273 | ||
| 274 | void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height) | ||
| 275 | { | ||
| 276 | NotifyClientAreaSizeChanged(std::make_pair(width, height)); | ||
| 277 | } | ||
diff --git a/src/citra_qt/bootmanager.hxx b/src/citra_qt/bootmanager.hxx index ec3e1fe71..3a18f98fd 100644 --- a/src/citra_qt/bootmanager.hxx +++ b/src/citra_qt/bootmanager.hxx | |||
| @@ -1,12 +1,16 @@ | |||
| 1 | #include <atomic> | ||
| 2 | |||
| 1 | #include <QThread> | 3 | #include <QThread> |
| 2 | #include <QGLWidget> | 4 | #include <QGLWidget> |
| 3 | #include <atomic> | 5 | |
| 4 | #include "common/common.h" | 6 | #include "common/common.h" |
| 5 | #include "common/emu_window.h" | 7 | #include "common/emu_window.h" |
| 6 | 8 | ||
| 7 | class GRenderWindow; | 9 | class QScreen; |
| 8 | class QKeyEvent; | 10 | class QKeyEvent; |
| 9 | 11 | ||
| 12 | class GRenderWindow; | ||
| 13 | |||
| 10 | class EmuThread : public QThread | 14 | class EmuThread : public QThread |
| 11 | { | 15 | { |
| 12 | Q_OBJECT | 16 | Q_OBJECT |
| @@ -74,7 +78,7 @@ private: | |||
| 74 | signals: | 78 | signals: |
| 75 | /** | 79 | /** |
| 76 | * Emitted when CPU when we've finished processing a single Gekko instruction | 80 | * Emitted when CPU when we've finished processing a single Gekko instruction |
| 77 | * | 81 | * |
| 78 | * @warning This will only be emitted when the CPU is not running (SetCpuRunning(false)) | 82 | * @warning This will only be emitted when the CPU is not running (SetCpuRunning(false)) |
| 79 | * @warning When connecting to this signal from other threads, make sure to specify either Qt::QueuedConnection (invoke slot within the destination object's message thread) or even Qt::BlockingQueuedConnection (additionally block source thread until slot returns) | 83 | * @warning When connecting to this signal from other threads, make sure to specify either Qt::QueuedConnection (invoke slot within the destination object's message thread) or even Qt::BlockingQueuedConnection (additionally block source thread until slot returns) |
| 80 | */ | 84 | */ |
| @@ -96,12 +100,11 @@ public: | |||
| 96 | void MakeCurrent() override; | 100 | void MakeCurrent() override; |
| 97 | void DoneCurrent() override; | 101 | void DoneCurrent() override; |
| 98 | void PollEvents() override; | 102 | void PollEvents() override; |
| 99 | void GetFramebufferSize(int* fbWidth, int* fbHeight) override; | ||
| 100 | 103 | ||
| 101 | void BackupGeometry(); | 104 | void BackupGeometry(); |
| 102 | void RestoreGeometry(); | 105 | void RestoreGeometry(); |
| 103 | void restoreGeometry(const QByteArray& geometry); // overridden | 106 | void restoreGeometry(const QByteArray& geometry); // overridden |
| 104 | QByteArray saveGeometry(); // overridden | 107 | QByteArray saveGeometry(); // overridden |
| 105 | 108 | ||
| 106 | EmuThread& GetEmuThread(); | 109 | EmuThread& GetEmuThread(); |
| 107 | 110 | ||
| @@ -110,8 +113,12 @@ public: | |||
| 110 | 113 | ||
| 111 | void ReloadSetKeymaps() override; | 114 | void ReloadSetKeymaps() override; |
| 112 | 115 | ||
| 116 | void OnClientAreaResized(unsigned width, unsigned height); | ||
| 117 | |||
| 118 | void OnFramebufferSizeChanged(); | ||
| 119 | |||
| 113 | public slots: | 120 | public slots: |
| 114 | void moveContext(); | 121 | void moveContext(); // overridden |
| 115 | 122 | ||
| 116 | private: | 123 | private: |
| 117 | QGLWidget* child; | 124 | QGLWidget* child; |
diff --git a/src/common/emu_window.h b/src/common/emu_window.h index ba9d4fa76..72c40c6a4 100644 --- a/src/common/emu_window.h +++ b/src/common/emu_window.h | |||
| @@ -43,54 +43,59 @@ public: | |||
| 43 | static void KeyReleased(KeyMap::HostDeviceKey key); | 43 | static void KeyReleased(KeyMap::HostDeviceKey key); |
| 44 | 44 | ||
| 45 | WindowConfig GetConfig() const { | 45 | WindowConfig GetConfig() const { |
| 46 | return m_config; | 46 | return config; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | void SetConfig(const WindowConfig& val) { | 49 | void SetConfig(const WindowConfig& val) { |
| 50 | m_config = val; | 50 | config = val; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | /// Gets the size of the window in pixels | 53 | /** |
| 54 | virtual void GetFramebufferSize(int* fbWidth, int* fbHeight) = 0; | 54 | * Gets the size of the framebuffer in pixels |
| 55 | 55 | */ | |
| 56 | int GetClientAreaWidth() const { | 56 | const std::pair<unsigned,unsigned> GetFramebufferSize() const { |
| 57 | return m_client_area_width; | 57 | return framebuffer_size; |
| 58 | } | ||
| 59 | |||
| 60 | void SetClientAreaWidth(const int val) { | ||
| 61 | m_client_area_width = val; | ||
| 62 | } | 58 | } |
| 63 | 59 | ||
| 64 | int GetClientAreaHeight() const { | 60 | /** |
| 65 | return m_client_area_height; | 61 | * Gets window client area width in logical coordinates |
| 62 | */ | ||
| 63 | std::pair<unsigned,unsigned> GetClientAreaSize() const { | ||
| 64 | return std::make_pair(client_area_width, client_area_height); | ||
| 66 | } | 65 | } |
| 67 | 66 | ||
| 68 | void SetClientAreaHeight(const int val) { | 67 | std::string GetWindowTitle() const { |
| 69 | m_client_area_height = val; | 68 | return window_title; |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | std::string GetWindowTitle() const { | 71 | void SetWindowTitle(const std::string& val) { |
| 73 | return m_window_title; | 72 | window_title = val; |
| 74 | } | ||
| 75 | |||
| 76 | void SetWindowTitle(std::string val) { | ||
| 77 | m_window_title = val; | ||
| 78 | } | 73 | } |
| 79 | 74 | ||
| 80 | protected: | 75 | protected: |
| 81 | EmuWindow(): | 76 | EmuWindow() : // TODO: What the hell... -.- - don't hardcode dimensions here without applying them in a sensible manner... |
| 82 | m_window_title(Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc)), | 77 | window_title(Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc)) |
| 83 | m_client_area_width(640), | 78 | m_client_area_width(640), |
| 84 | m_client_area_height(480) | 79 | m_client_area_height(480), |
| 85 | {} | 80 | {} |
| 86 | virtual ~EmuWindow() {} | 81 | virtual ~EmuWindow() {} |
| 87 | 82 | ||
| 88 | std::string m_window_title; ///< Current window title, should be used by window impl. | 83 | std::pair<unsigned,unsigned> NotifyFramebufferSizeChanged(const std::pair<unsigned,unsigned>& size) { |
| 84 | framebuffer_size = size; | ||
| 85 | } | ||
| 89 | 86 | ||
| 90 | int m_client_area_width; ///< Current client width, should be set by window impl. | 87 | void NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned> size) { |
| 91 | int m_client_area_height; ///< Current client height, should be set by window impl. | 88 | client_area_width = size.first; |
| 89 | client_area_height = size.second; | ||
| 90 | } | ||
| 92 | 91 | ||
| 93 | private: | 92 | private: |
| 94 | WindowConfig m_config; ///< Internal configuration | 93 | std::string window_title; ///< Current window title, should be used by window impl. |
| 94 | |||
| 95 | std::pair<unsigned,unsigned> framebuffer_size; | ||
| 96 | |||
| 97 | unsigned client_area_width; ///< Current client width, should be set by window impl. | ||
| 98 | unsigned client_area_height; ///< Current client height, should be set by window impl. | ||
| 95 | 99 | ||
| 100 | WindowConfig config; ///< Internal configuration | ||
| 96 | }; | 101 | }; |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 3757482db..082a464b3 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -230,10 +230,10 @@ void RendererOpenGL::SetWindow(EmuWindow* window) { | |||
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | void RendererOpenGL::UpdateViewportExtent() { | 232 | void RendererOpenGL::UpdateViewportExtent() { |
| 233 | int width_in_pixels; | 233 | unsigned width_in_pixels; |
| 234 | int height_in_pixels; | 234 | unsigned height_in_pixels; |
| 235 | 235 | ||
| 236 | render_window->GetFramebufferSize(&width_in_pixels, &height_in_pixels); | 236 | std::tie(width_in_pixels, height_in_pixels) = render_window->GetFramebufferSize(); |
| 237 | 237 | ||
| 238 | // No update needed if framebuffer size hasn't changed | 238 | // No update needed if framebuffer size hasn't changed |
| 239 | if (width_in_pixels == framebuffer_size.width && height_in_pixels == framebuffer_size.height) { | 239 | if (width_in_pixels == framebuffer_size.width && height_in_pixels == framebuffer_size.height) { |