summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2016-08-29 21:28:58 -0400
committerGravatar bunnei2016-08-29 21:42:32 -0400
commit02702c66052c10b10ba0a6af6ab34734886d3728 (patch)
tree3ec2892bd94e7cf346867d8194883fdf53e084a7 /src
parentsystem: Add a function to see if the emulator is running. (diff)
downloadyuzu-02702c66052c10b10ba0a6af6ab34734886d3728.tar.gz
yuzu-02702c66052c10b10ba0a6af6ab34734886d3728.tar.xz
yuzu-02702c66052c10b10ba0a6af6ab34734886d3728.zip
qt: Recreate GL context on startup to support changing V-Sync.
Diffstat (limited to 'src')
-rw-r--r--src/citra_qt/bootmanager.cpp60
-rw-r--r--src/citra_qt/bootmanager.h2
-rw-r--r--src/citra_qt/main.cpp2
3 files changed, 39 insertions, 25 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index a9669c559..6dddde9ba 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -107,37 +107,13 @@ private:
107}; 107};
108 108
109GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread) : 109GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread) :
110 QWidget(parent), keyboard_id(0), emu_thread(emu_thread) { 110 QWidget(parent), keyboard_id(0), emu_thread(emu_thread), child(nullptr) {
111 111
112 std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); 112 std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
113 setWindowTitle(QString::fromStdString(window_title)); 113 setWindowTitle(QString::fromStdString(window_title));
114 114
115 keyboard_id = KeyMap::NewDeviceId(); 115 keyboard_id = KeyMap::NewDeviceId();
116 ReloadSetKeymaps(); 116 ReloadSetKeymaps();
117
118 // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, WA_DontShowOnScreen, WA_DeleteOnClose
119 QGLFormat fmt;
120 fmt.setVersion(3,3);
121 fmt.setProfile(QGLFormat::CoreProfile);
122 fmt.setSwapInterval(VideoCore::g_vsync_enabled);
123 // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X
124 fmt.setOption(QGL::NoDeprecatedFunctions);
125
126 child = new GGLWidgetInternal(fmt, this);
127 QBoxLayout* layout = new QHBoxLayout(this);
128
129 resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight);
130 layout->addWidget(child);
131 layout->setMargin(0);
132 setLayout(layout);
133
134 OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
135
136 OnFramebufferSizeChanged();
137 NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height()));
138
139 BackupGeometry();
140
141} 117}
142 118
143void GRenderWindow::moveContext() 119void GRenderWindow::moveContext()
@@ -282,6 +258,40 @@ void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height)
282 NotifyClientAreaSizeChanged(std::make_pair(width, height)); 258 NotifyClientAreaSizeChanged(std::make_pair(width, height));
283} 259}
284 260
261void GRenderWindow::InitRenderTarget() {
262 if (child) {
263 delete child;
264 }
265
266 if (layout()) {
267 delete layout();
268 }
269
270 // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, WA_DontShowOnScreen, WA_DeleteOnClose
271 QGLFormat fmt;
272 fmt.setVersion(3, 3);
273 fmt.setProfile(QGLFormat::CoreProfile);
274 fmt.setSwapInterval(Settings::values.use_vsync);
275
276 // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X
277 fmt.setOption(QGL::NoDeprecatedFunctions);
278
279 child = new GGLWidgetInternal(fmt, this);
280 QBoxLayout* layout = new QHBoxLayout(this);
281
282 resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight);
283 layout->addWidget(child);
284 layout->setMargin(0);
285 setLayout(layout);
286
287 OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
288
289 OnFramebufferSizeChanged();
290 NotifyClientAreaSizeChanged(std::pair<unsigned, unsigned>(child->width(), child->height()));
291
292 BackupGeometry();
293}
294
285void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { 295void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) {
286 setMinimumSize(minimal_size.first, minimal_size.second); 296 setMinimumSize(minimal_size.first, minimal_size.second);
287} 297}
diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h
index 0dcf3e5eb..c1da2bc5f 100644
--- a/src/citra_qt/bootmanager.h
+++ b/src/citra_qt/bootmanager.h
@@ -126,6 +126,8 @@ public:
126 126
127 void OnClientAreaResized(unsigned width, unsigned height); 127 void OnClientAreaResized(unsigned width, unsigned height);
128 128
129 void InitRenderTarget();
130
129public slots: 131public slots:
130 void moveContext(); // overridden 132 void moveContext(); // overridden
131 133
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 68a936087..9fd4482f6 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -243,7 +243,9 @@ bool GMainWindow::InitializeSystem() {
243 if (emu_thread != nullptr) 243 if (emu_thread != nullptr)
244 ShutdownGame(); 244 ShutdownGame();
245 245
246 render_window->InitRenderTarget();
246 render_window->MakeCurrent(); 247 render_window->MakeCurrent();
248
247 if (!gladLoadGL()) { 249 if (!gladLoadGL()) {
248 QMessageBox::critical(this, tr("Error while starting Citra!"), 250 QMessageBox::critical(this, tr("Error while starting Citra!"),
249 tr("Failed to initialize the video core!\n\n" 251 tr("Failed to initialize the video core!\n\n"