all repos — mgba @ 2f2e5398719f9d6a78ae84fc241945b46839b01c

mGBA Game Boy Advance Emulator

src/platform/qt/Display.cpp (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "Display.h"
 7
 8#include "DisplayGL.h"
 9#include "DisplayQt.h"
10
11extern "C" {
12#include "gba/video.h"
13}
14
15using namespace QGBA;
16
17#ifdef BUILD_GL
18Display::Driver Display::s_driver = Display::Driver::OPENGL;
19#else
20Display::Driver Display::s_driver = Display::Driver::QT;
21#endif
22
23Display* Display::create(QWidget* parent) {
24#ifdef BUILD_GL
25	QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer));
26	format.setSwapInterval(1);
27#endif
28
29	switch (s_driver) {
30#ifdef BUILD_GL
31	case Driver::OPENGL:
32		return new DisplayGL(format, parent);
33#endif
34
35	case Driver::QT:
36		return new DisplayQt(parent);
37
38	default:
39#ifdef BUILD_GL
40		return new DisplayGL(format, parent);
41#else
42		return new DisplayQt(parent);
43#endif
44	}
45}
46
47Display::Display(QWidget* parent)
48	: QWidget(parent)
49{
50	setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
51	setMinimumSize(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS);
52}