get the GL shit going
This commit is contained in:
parent
bc4a83abca
commit
4e34359a80
|
@ -2,6 +2,7 @@ project(qt_sdl)
|
|||
|
||||
SET(SOURCES_QT_SDL
|
||||
main.cpp
|
||||
main_shaders.h
|
||||
EmuSettingsDialog.cpp
|
||||
InputConfigDialog.cpp
|
||||
AudioSettingsDialog.cpp
|
||||
|
|
|
@ -639,7 +639,7 @@ void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
|
|||
}
|
||||
|
||||
|
||||
MainWindowPanel::MainWindowPanel(QWidget* parent) : QWidget(parent)
|
||||
ScreenPanelNative::ScreenPanelNative(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
screen[0] = QImage(256, 192, QImage::Format_RGB32);
|
||||
screen[1] = QImage(256, 192, QImage::Format_RGB32);
|
||||
|
@ -650,16 +650,11 @@ MainWindowPanel::MainWindowPanel(QWidget* parent) : QWidget(parent)
|
|||
touching = false;
|
||||
}
|
||||
|
||||
MainWindowPanel::~MainWindowPanel()
|
||||
ScreenPanelNative::~ScreenPanelNative()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindowPanel::ensureProperMinSize()
|
||||
{
|
||||
setMinimumSize(screenGetMinSize());
|
||||
}
|
||||
|
||||
void MainWindowPanel::setupScreenLayout()
|
||||
void ScreenPanelNative::setupScreenLayout()
|
||||
{
|
||||
int w = width();
|
||||
int h = height();
|
||||
|
@ -678,7 +673,7 @@ void MainWindowPanel::setupScreenLayout()
|
|||
mtx[4], mtx[5], 1.f);
|
||||
}
|
||||
|
||||
void MainWindowPanel::paintEvent(QPaintEvent* event)
|
||||
void ScreenPanelNative::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
|
@ -702,28 +697,78 @@ void MainWindowPanel::paintEvent(QPaintEvent* event)
|
|||
painter.drawImage(screenrc, screen[1]);
|
||||
}
|
||||
|
||||
void MainWindowPanel::resizeEvent(QResizeEvent* event)
|
||||
void ScreenPanelNative::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
setupScreenLayout();
|
||||
}
|
||||
|
||||
void MainWindowPanel::mousePressEvent(QMouseEvent* event)
|
||||
void ScreenPanelNative::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
screenOnMousePress(event);
|
||||
}
|
||||
|
||||
void MainWindowPanel::mouseReleaseEvent(QMouseEvent* event)
|
||||
void ScreenPanelNative::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
screenOnMouseRelease(event);
|
||||
}
|
||||
|
||||
void MainWindowPanel::mouseMoveEvent(QMouseEvent* event)
|
||||
void ScreenPanelNative::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
screenOnMouseMove(event);
|
||||
}
|
||||
|
||||
void MainWindowPanel::onScreenLayoutChanged()
|
||||
void ScreenPanelNative::onScreenLayoutChanged()
|
||||
{
|
||||
setMinimumSize(screenGetMinSize());
|
||||
setupScreenLayout();
|
||||
}
|
||||
|
||||
|
||||
ScreenPanelGL::ScreenPanelGL(QWidget* parent) : QOpenGLWidget(parent)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
ScreenPanelGL::~ScreenPanelGL()
|
||||
{
|
||||
}
|
||||
|
||||
void ScreenPanelGL::setupScreenLayout()
|
||||
{
|
||||
int w = width();
|
||||
int h = height();
|
||||
|
||||
screenSetupLayout(w, h);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
// TODO?
|
||||
}
|
||||
|
||||
void ScreenPanelGL::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
setupScreenLayout();
|
||||
}
|
||||
|
||||
void ScreenPanelGL::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
screenOnMousePress(event);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
screenOnMouseRelease(event);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
screenOnMouseMove(event);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::onScreenLayoutChanged()
|
||||
{
|
||||
setMinimumSize(screenGetMinSize());
|
||||
setupScreenLayout();
|
||||
}
|
||||
|
||||
|
@ -932,9 +977,10 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
|||
}
|
||||
setMenuBar(menubar);
|
||||
|
||||
panel = new MainWindowPanel(this);
|
||||
panel = new ScreenPanelNative(this);
|
||||
setCentralWidget(panel);
|
||||
panel->ensureProperMinSize();
|
||||
connect(this, SIGNAL(screenLayoutChange()), panel, SLOT(onScreenLayoutChanged()));
|
||||
emit screenLayoutChange();
|
||||
|
||||
resize(Config::WindowWidth, Config::WindowHeight);
|
||||
|
||||
|
@ -1413,8 +1459,7 @@ void MainWindow::onChangeScreenRotation(QAction* act)
|
|||
int rot = act->data().toInt();
|
||||
Config::ScreenRotation = rot;
|
||||
|
||||
panel->ensureProperMinSize();
|
||||
panel->setupScreenLayout();
|
||||
emit screenLayoutChange();
|
||||
}
|
||||
|
||||
void MainWindow::onChangeScreenGap(QAction* act)
|
||||
|
@ -1422,8 +1467,7 @@ void MainWindow::onChangeScreenGap(QAction* act)
|
|||
int gap = act->data().toInt();
|
||||
Config::ScreenGap = gap;
|
||||
|
||||
panel->ensureProperMinSize();
|
||||
panel->setupScreenLayout();
|
||||
emit screenLayoutChange();
|
||||
}
|
||||
|
||||
void MainWindow::onChangeScreenLayout(QAction* act)
|
||||
|
@ -1431,8 +1475,7 @@ void MainWindow::onChangeScreenLayout(QAction* act)
|
|||
int layout = act->data().toInt();
|
||||
Config::ScreenLayout = layout;
|
||||
|
||||
panel->ensureProperMinSize();
|
||||
panel->setupScreenLayout();
|
||||
emit screenLayoutChange();
|
||||
}
|
||||
|
||||
void MainWindow::onChangeScreenSizing(QAction* act)
|
||||
|
@ -1440,14 +1483,14 @@ void MainWindow::onChangeScreenSizing(QAction* act)
|
|||
int sizing = act->data().toInt();
|
||||
Config::ScreenSizing = sizing;
|
||||
|
||||
panel->setupScreenLayout();
|
||||
emit screenLayoutChange();
|
||||
}
|
||||
|
||||
void MainWindow::onChangeIntegerScaling(bool checked)
|
||||
{
|
||||
Config::IntegerScaling = checked?1:0;
|
||||
|
||||
panel->setupScreenLayout();
|
||||
emit screenLayoutChange();
|
||||
}
|
||||
|
||||
void MainWindow::onChangeScreenFiltering(bool checked)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <QMainWindow>
|
||||
#include <QImage>
|
||||
#include <QActionGroup>
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
|
||||
class EmuThread : public QThread
|
||||
|
@ -66,6 +67,11 @@ private:
|
|||
|
||||
class ScreenHandler
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
public:
|
||||
virtual ~ScreenHandler() {}
|
||||
|
||||
protected:
|
||||
void screenSetupLayout(int w, int h);
|
||||
|
||||
|
@ -81,16 +87,13 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class MainWindowPanel : public QWidget, public ScreenHandler
|
||||
class ScreenPanelNative : public QWidget, public ScreenHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindowPanel(QWidget* parent);
|
||||
~MainWindowPanel();
|
||||
|
||||
void ensureProperMinSize();
|
||||
void setupScreenLayout();
|
||||
explicit ScreenPanelNative(QWidget* parent);
|
||||
~ScreenPanelNative();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
@ -105,11 +108,40 @@ private slots:
|
|||
void onScreenLayoutChanged();
|
||||
|
||||
private:
|
||||
void setupScreenLayout();
|
||||
|
||||
QImage screen[2];
|
||||
QTransform screenTrans[2];
|
||||
};
|
||||
|
||||
|
||||
class ScreenPanelGL : public QOpenGLWidget, public ScreenHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ScreenPanelGL(QWidget* parent);
|
||||
~ScreenPanelGL();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void onScreenLayoutChanged();
|
||||
|
||||
private:
|
||||
void setupScreenLayout();
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -127,6 +159,9 @@ protected:
|
|||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
|
||||
signals:
|
||||
void screenLayoutChange();
|
||||
|
||||
private slots:
|
||||
void onOpenFile();
|
||||
void onBootFirmware();
|
||||
|
@ -167,7 +202,7 @@ private:
|
|||
QString loadErrorStr(int error);
|
||||
|
||||
public:
|
||||
MainWindowPanel* panel;
|
||||
QWidget* panel;
|
||||
|
||||
QAction* actOpenROM;
|
||||
QAction* actBootFirmware;
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
Copyright 2016-2020 Arisotura
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#ifndef MAIN_SHADERS_H
|
||||
#define MAIN_SHADERS_H
|
||||
|
||||
const char* kScreenVS = R"(#version 140
|
||||
|
||||
layout(std140) uniform uConfig
|
||||
{
|
||||
vec2 uScreenSize;
|
||||
uint u3DScale;
|
||||
uint uFilterMode;
|
||||
};
|
||||
|
||||
in vec2 vPosition;
|
||||
in vec2 vTexcoord;
|
||||
|
||||
smooth out vec2 fTexcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 fpos;
|
||||
fpos.xy = ((vPosition * 2.0) / uScreenSize) - 1.0;
|
||||
fpos.y *= -1;
|
||||
fpos.z = 0.0;
|
||||
fpos.w = 1.0;
|
||||
|
||||
gl_Position = fpos;
|
||||
fTexcoord = vTexcoord;
|
||||
}
|
||||
)";
|
||||
|
||||
const char* kScreenFS = R"(#version 140
|
||||
|
||||
layout(std140) uniform uConfig
|
||||
{
|
||||
vec2 uScreenSize;
|
||||
uint u3DScale;
|
||||
uint uFilterMode;
|
||||
};
|
||||
|
||||
uniform usampler2D ScreenTex;
|
||||
|
||||
smooth in vec2 fTexcoord;
|
||||
|
||||
out vec4 oColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec4 pixel = ivec4(texelFetch(ScreenTex, ivec2(fTexcoord), 0));
|
||||
|
||||
// TODO: filters
|
||||
|
||||
oColor = vec4(vec3(pixel.bgr) / 255.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
|
||||
const char* kScreenVS_OSD = R"(#version 140
|
||||
|
||||
layout(std140) uniform uConfig
|
||||
{
|
||||
vec2 uScreenSize;
|
||||
uint u3DScale;
|
||||
uint uFilterMode;
|
||||
};
|
||||
|
||||
uniform ivec2 uOSDPos;
|
||||
uniform ivec2 uOSDSize;
|
||||
|
||||
in vec2 vPosition;
|
||||
|
||||
smooth out vec2 fTexcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 fpos;
|
||||
|
||||
vec2 osdpos = (vPosition * vec2(uOSDSize));
|
||||
fTexcoord = osdpos;
|
||||
osdpos += uOSDPos;
|
||||
|
||||
fpos.xy = ((osdpos * 2.0) / uScreenSize) - 1.0;
|
||||
fpos.y *= -1;
|
||||
fpos.z = 0.0;
|
||||
fpos.w = 1.0;
|
||||
|
||||
gl_Position = fpos;
|
||||
}
|
||||
)";
|
||||
|
||||
const char* kScreenFS_OSD = R"(#version 140
|
||||
|
||||
uniform sampler2D OSDTex;
|
||||
|
||||
smooth in vec2 fTexcoord;
|
||||
|
||||
out vec4 oColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pixel = texelFetch(OSDTex, ivec2(fTexcoord), 0);
|
||||
oColor = pixel.bgra;
|
||||
}
|
||||
)";
|
||||
|
||||
#endif // MAIN_SHADERS_H
|
Loading…
Reference in New Issue