mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
Make emulator output size properly configurable
This commit is contained in:
parent
27a04a806e
commit
c10a3e7160
8 changed files with 30 additions and 7 deletions
|
@ -113,6 +113,9 @@ class GPU {
|
||||||
u32 readInternalReg(u32 index);
|
u32 readInternalReg(u32 index);
|
||||||
void writeInternalReg(u32 index, u32 value, u32 mask);
|
void writeInternalReg(u32 index, u32 value, u32 mask);
|
||||||
|
|
||||||
|
// Used for setting the size of the window we'll be outputting graphics to
|
||||||
|
void setOutputSize(u32 width, u32 height) { renderer->setOutputSize(width, height); }
|
||||||
|
|
||||||
// TODO: Emulate the transfer engine & its registers
|
// TODO: Emulate the transfer engine & its registers
|
||||||
// Then this can be emulated by just writing the appropriate values there
|
// Then this can be emulated by just writing the appropriate values there
|
||||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) { renderer->clearBuffer(startAddress, endAddress, value, control); }
|
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) { renderer->clearBuffer(startAddress, endAddress, value, control); }
|
||||||
|
|
|
@ -120,5 +120,7 @@ class Emulator {
|
||||||
void initGraphicsContext() { gpu.initGraphicsContext(window); }
|
void initGraphicsContext() { gpu.initGraphicsContext(window); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void setOutputSize(u32 width, u32 height) { gpu.setOutputSize(width, height); }
|
||||||
|
|
||||||
EmulatorConfig& getConfig() { return config; }
|
EmulatorConfig& getConfig() { return config; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,6 +13,10 @@ class ScreenWidget : public QWidget {
|
||||||
ScreenWidget(QWidget* parent = nullptr);
|
ScreenWidget(QWidget* parent = nullptr);
|
||||||
GL::Context* getGLContext() { return glContext.get(); }
|
GL::Context* getGLContext() { return glContext.get(); }
|
||||||
|
|
||||||
|
// Dimensions of our output surface
|
||||||
|
u32 surfaceWidth = 0;
|
||||||
|
u32 surfaceHeight = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<GL::Context> glContext = nullptr;
|
std::unique_ptr<GL::Context> glContext = nullptr;
|
||||||
bool createGLContext();
|
bool createGLContext();
|
||||||
|
|
|
@ -40,6 +40,11 @@ class Renderer {
|
||||||
u32 depthBufferLoc;
|
u32 depthBufferLoc;
|
||||||
PICA::DepthFmt depthBufferFormat;
|
PICA::DepthFmt depthBufferFormat;
|
||||||
|
|
||||||
|
// Width and height of the window we're outputting to, needed for properly scaling the final image
|
||||||
|
// We initialize it to the 3DS resolution by default and the frontend can notify us if it changes via the setOutputSize function
|
||||||
|
u32 outputWindowWidth = 400;
|
||||||
|
u32 outputWindowHeight = 240 * 2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs, const std::array<u32, extRegNum>& externalRegs);
|
Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs, const std::array<u32, extRegNum>& externalRegs);
|
||||||
virtual ~Renderer();
|
virtual ~Renderer();
|
||||||
|
@ -78,4 +83,9 @@ class Renderer {
|
||||||
|
|
||||||
void setColourBufferLoc(u32 loc) { colourBufferLoc = loc; }
|
void setColourBufferLoc(u32 loc) { colourBufferLoc = loc; }
|
||||||
void setDepthBufferLoc(u32 loc) { depthBufferLoc = loc; }
|
void setDepthBufferLoc(u32 loc) { depthBufferLoc = loc; }
|
||||||
|
|
||||||
|
void setOutputSize(u32 width, u32 height) {
|
||||||
|
outputWindowWidth = width;
|
||||||
|
outputWindowHeight = height;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -524,7 +524,7 @@ void RendererGL::display() {
|
||||||
|
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
screenFramebuffer.bind(OpenGL::ReadFramebuffer);
|
screenFramebuffer.bind(OpenGL::ReadFramebuffer);
|
||||||
glBlitFramebuffer(0, 0, 400, 480, 0, 0, 400, 480, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
glBlitFramebuffer(0, 0, 400, 480, 0, 0, outputWindowWidth, outputWindowHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererGL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
|
void RendererGL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
|
||||||
|
|
|
@ -28,12 +28,6 @@ Emulator::Emulator()
|
||||||
Helpers::warn("Failed to initialize SDL2 GameController: %s", SDL_GetError());
|
Helpers::warn("Failed to initialize SDL2 GameController: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need OpenGL for software rendering or for OpenGL if it's enabled
|
|
||||||
bool needOpenGL = config.rendererType == RendererType::Software;
|
|
||||||
#ifdef PANDA3DS_ENABLE_OPENGL
|
|
||||||
needOpenGL = needOpenGL || (config.rendererType == RendererType::OpenGL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
||||||
if (config.discordRpcEnabled) {
|
if (config.discordRpcEnabled) {
|
||||||
discordRpc.init();
|
discordRpc.init();
|
||||||
|
@ -41,6 +35,12 @@ Emulator::Emulator()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We need OpenGL for software rendering or for OpenGL if it's enabled
|
||||||
|
bool needOpenGL = config.rendererType == RendererType::Software;
|
||||||
|
#ifdef PANDA3DS_ENABLE_OPENGL
|
||||||
|
needOpenGL = needOpenGL || (config.rendererType == RendererType::OpenGL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Only create SDL Window for SDL frontend
|
// Only create SDL Window for SDL frontend
|
||||||
#ifdef PANDA3DS_FRONTEND_SDL
|
#ifdef PANDA3DS_FRONTEND_SDL
|
||||||
if (needOpenGL) {
|
if (needOpenGL) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
||||||
connect(themeSelect, &QComboBox::currentIndexChanged, this, [&](int index) { setTheme(static_cast<Theme>(index)); });
|
connect(themeSelect, &QComboBox::currentIndexChanged, this, [&](int index) { setTheme(static_cast<Theme>(index)); });
|
||||||
|
|
||||||
emu = new Emulator();
|
emu = new Emulator();
|
||||||
|
emu->setOutputSize(screen.surfaceWidth, screen.surfaceHeight);
|
||||||
|
|
||||||
// The emulator graphics context for the thread should be initialized in the emulator thread due to how GL contexts work
|
// The emulator graphics context for the thread should be initialized in the emulator thread due to how GL contexts work
|
||||||
emuThread = std::thread([&]() {
|
emuThread = std::thread([&]() {
|
||||||
|
|
|
@ -105,6 +105,9 @@ std::optional<WindowInfo> ScreenWidget::getWindowInfo() {
|
||||||
wi.surface_height = static_cast<u32>(scaledWindowHeight());
|
wi.surface_height = static_cast<u32>(scaledWindowHeight());
|
||||||
wi.surface_scale = static_cast<float>(devicePixelRatioFromScreen());
|
wi.surface_scale = static_cast<float>(devicePixelRatioFromScreen());
|
||||||
|
|
||||||
|
surfaceWidth = wi.surface_width;
|
||||||
|
surfaceHeight = wi.surface_height;
|
||||||
|
|
||||||
return wi;
|
return wi;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
Loading…
Add table
Reference in a new issue