linux support

This commit is contained in:
RSDuck
2022-10-12 21:53:56 +02:00
parent b4599e3064
commit cdaa52256f
23 changed files with 3130 additions and 66 deletions

View File

@ -91,6 +91,11 @@ endif()
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
if (USE_QT6)
target_include_directories(melonDS PUBLIC ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
else()
target_include_directories(melonDS PUBLIC ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
target_link_libraries(melonDS PRIVATE core)
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})

View File

@ -36,10 +36,14 @@
#include <QMimeData>
#include <QVector>
#ifndef _WIN32
#include <QGuiApplication>
#include <QSocketNotifier>
#include <unistd.h>
#include <sys/socket.h>
#include <signal.h>
#ifndef APPLE
#include <qpa/qplatformnativeinterface.h>
#endif
#endif
#include <SDL2/SDL.h>
@ -376,7 +380,6 @@ void EmuThread::initOpenGL()
glUniform1i(glGetUniformLocation(pid, "ScreenTex"), 0);
screenShaderScreenSizeULoc = glGetUniformLocation(pid, "uScreenSize");
screenShaderScaleFactorULoc = glGetUniformLocation(pid, "uScaleFactor");
screenShaderTransformULoc = glGetUniformLocation(pid, "uTransform");
// to prevent bleeding between both parts of the screen
@ -526,6 +529,16 @@ void EmuThread::run()
}
}
screenSettingsLock.lock();
if (lastScreenWidth != windowInfo.surface_width || lastScreenHeight != windowInfo.surface_height)
{
if (oglContext)
oglContext->ResizeSurface(windowInfo.surface_width, windowInfo.surface_height);
lastScreenWidth = windowInfo.surface_width;
lastScreenHeight = windowInfo.surface_height;
}
screenSettingsLock.unlock();
if (EmuRunning == 1 || EmuRunning == 3)
{
EmuStatus = 1;
@ -836,11 +849,10 @@ void EmuThread::drawScreenGL()
glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, w*factor, h*factor);
glViewport(0, 0, w, h);
glUseProgram(screenShaderProgram[2]);
glUniform2f(screenShaderScreenSizeULoc, w, h);
glUniform1f(screenShaderScaleFactorULoc, factor);
glUniform2f(screenShaderScreenSizeULoc, w / factor, h / factor);
int frontbuf = FrontBuffer;
glActiveTexture(GL_TEXTURE0);
@ -884,7 +896,7 @@ void EmuThread::drawScreenGL()
screenSettingsLock.unlock();
OSD::Update();
OSD::DrawGL(w*factor, h*factor);
OSD::DrawGL(w, h);
oglContext->SwapBuffers();
}
@ -2942,7 +2954,6 @@ void MainWindow::onChangeShowOSD(bool checked)
{
Config::ShowOSD = checked?1:0;
}
void MainWindow::onChangeLimitFramerate(bool checked)
{
Config::LimitFPS = checked?1:0;
@ -3072,6 +3083,8 @@ int main(int argc, char** argv)
{
srand(time(NULL));
qputenv("QT_SCALE_FACTOR", "1");
printf("melonDS " MELONDS_VERSION "\n");
printf(MELONDS_URL "\n");

View File

@ -102,7 +102,7 @@ private:
GLuint screenVertexBuffer, screenVertexArray;
GLuint screenTexture;
GLuint screenShaderProgram[3];
GLuint screenShaderTransformULoc, screenShaderScreenSizeULoc, screenShaderScaleFactorULoc;
GLuint screenShaderTransformULoc, screenShaderScreenSizeULoc;
QMutex screenSettingsLock;
WindowInfo windowInfo;
@ -110,6 +110,9 @@ private:
int screenKind[Frontend::MaxScreenTransforms];
int numScreens;
bool filter;
int lastScreenWidth = -1;
int lastScreenHeight = -1;
};

View File

@ -23,7 +23,6 @@ const char* kScreenVS = R"(#version 140
uniform vec2 uScreenSize;
uniform mat2x3 uTransform;
uniform float uScaleFactor;
in vec2 vPosition;
in vec2 vTexcoord;
@ -34,9 +33,9 @@ void main()
{
vec4 fpos;
fpos.xy = vec3(vPosition, 1.0) * uTransform * uScaleFactor;
fpos.xy = vec3(vPosition, 1.0) * uTransform;
fpos.xy = ((fpos.xy * 2.0) / (uScreenSize * uScaleFactor)) - 1.0;
fpos.xy = ((fpos.xy * 2.0) / uScreenSize) - 1.0;
fpos.y *= -1;
fpos.z = 0.0;
fpos.w = 1.0;