* use GL shim window instead of offscreen surface

* disable vsync by default (we'll take care of it later)
This commit is contained in:
Arisotura 2020-05-27 21:29:47 +02:00
parent 256360aebb
commit ef2802ae31
2 changed files with 29 additions and 3 deletions

View File

@ -268,7 +268,7 @@ void EmuThread::initOpenGL()
QOpenGLContext* windowctx = mainWindow->getOGLContext(); QOpenGLContext* windowctx = mainWindow->getOGLContext();
QSurfaceFormat format = windowctx->format(); QSurfaceFormat format = windowctx->format();
oglSurface = new QOffscreenSurface(); /*oglSurface = new QOffscreenSurface();
oglSurface->setFormat(format); oglSurface->setFormat(format);
oglSurface->create(); oglSurface->create();
if (!oglSurface->isValid()) if (!oglSurface->isValid())
@ -277,7 +277,8 @@ void EmuThread::initOpenGL()
printf("oglSurface shat itself :(\n"); printf("oglSurface shat itself :(\n");
delete oglSurface; delete oglSurface;
return; return;
} }*/
oglSurface = new GLShim(format);
oglContext = new QOpenGLContext();//oglSurface); oglContext = new QOpenGLContext();//oglSurface);
oglContext->setFormat(oglSurface->format()); oglContext->setFormat(oglSurface->format());
@ -957,6 +958,19 @@ void ScreenPanelGL::onScreenLayoutChanged()
} }
GLShim::GLShim(QSurfaceFormat& format) : QWindow()
{
setSurfaceType(QSurface::OpenGLSurface);
setFormat(format);
create();
hide();
}
GLShim::~GLShim()
{
}
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
{ {
setWindowTitle("melonDS " MELONDS_VERSION); setWindowTitle("melonDS " MELONDS_VERSION);
@ -1835,6 +1849,7 @@ int main(int argc, char** argv)
format.setStencilBufferSize(8); format.setStencilBufferSize(8);
format.setVersion(3, 2); format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile); format.setProfile(QSurfaceFormat::CoreProfile);
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format); QSurfaceFormat::setDefaultFormat(format);
audioSync = SDL_CreateCond(); audioSync = SDL_CreateCond();

View File

@ -21,6 +21,7 @@
#include <QThread> #include <QThread>
#include <QWidget> #include <QWidget>
#include <QWindow>
#include <QMainWindow> #include <QMainWindow>
#include <QImage> #include <QImage>
#include <QActionGroup> #include <QActionGroup>
@ -74,7 +75,7 @@ private:
int PrevEmuStatus; int PrevEmuStatus;
int EmuRunning; int EmuRunning;
QOffscreenSurface* oglSurface; QSurface* oglSurface;
QOpenGLContext* oglContext; QOpenGLContext* oglContext;
}; };
@ -162,6 +163,16 @@ private:
}; };
class GLShim : public QWindow
{
Q_OBJECT
public:
explicit GLShim(QSurfaceFormat& format);
~GLShim();
};
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT