Compare commits

...

6 Commits

Author SHA1 Message Date
Rosalie Wanders 6e2a77b542 RMG: don't store and load geometry during emulation start or end 2026-01-14 06:41:53 +01:00
Rosalie Wanders 0833630619 3rdParty: implement SetInitialVideoSize() in mupen64plus-video-angrylion-plus 2026-01-13 15:23:32 +01:00
Rosalie Wanders caa2da2900 3rdParty: implement SetInitialVideoSize() in mupen64plus-video-parallel 2026-01-13 15:23:32 +01:00
Rosalie Wanders 33b3c3b1b0 3rdParty: implement SetInitialVideoSize() in mupen64plus-video-GLideN64 2026-01-13 15:23:32 +01:00
Rosalie Wanders e16d50c368 RMG: use CoreSetInitialVideoSize() 2026-01-13 15:23:32 +01:00
Rosalie Wanders 402870048b RMG-Core: add CoreSetInitialVideoSize() 2026-01-13 15:20:49 +01:00
21 changed files with 115 additions and 84 deletions
@@ -110,6 +110,11 @@ void DisplayWindow::closeWindow()
m_bToggleFullscreen = false;
}
void DisplayWindow::setInitialWindowSize(u32 width, u32 height)
{
m_initialWidth = width;
m_initialHeight = height;
}
void DisplayWindow::setWindowSize(u32 _width, u32 _height)
{
@@ -17,6 +17,7 @@ public:
bool changeWindow();
bool resizeWindow();
void closeWindow();
void setInitialWindowSize(u32 width, u32 height);
void setWindowSize(u32 _width, u32 _height);
void setCaptureScreen(const char * const _strDirectory);
void setToggleFullscreen() { m_bToggleFullscreen = true; }
@@ -55,6 +56,8 @@ protected:
bool m_bAdjustScreen = false;
u32 m_buffersSwapCount = 0;
u32 m_initialWidth = 0;
u32 m_initialHeight = 0;
u32 m_width = 0;
u32 m_height = 0;
u32 m_heightOffset = 0;
@@ -90,8 +90,8 @@ bool DisplayWindowMupen64plus::_start()
_setAttributes();
m_bFullscreen = config.video.fullscreen > 0;
m_screenWidth = config.video.windowedWidth;
m_screenHeight = config.video.windowedHeight;
m_screenWidth = m_initialWidth > 0 ? m_initialWidth : config.video.windowedWidth;
m_screenHeight = m_initialHeight > 0 ? m_initialHeight : config.video.windowedHeight;
m_screenRefresh = config.video.fullscreenRefresh;
_getDisplaySize();
@@ -57,6 +57,11 @@ EXPORT void CALL SetRenderingCallback(void (*callback)(int))
api().SetRenderingCallback(callback);
}
EXPORT void CALL SetInitialVideoSize(int width, int height)
{
api().SetInitialVideoSize(width, height);
}
EXPORT void CALL ResizeVideoOutput(int width, int height)
{
api().ResizeVideoOutput(width, height);
@@ -80,6 +80,9 @@ public:
void FBGetFrameBufferInfo(void *pinfo);
#else
// MupenPlus
#ifdef M64P_GLIDENUI
void SetInitialVideoSize(int width, int height);
#endif
void ResizeVideoOutput(int _Width, int _Height);
void ReadScreen2(void * _dest, int * _width, int * _height, int _front);
@@ -166,6 +166,13 @@ void PluginAPI::SetRenderingCallback(void (*callback)(int))
renderCallback = callback;
}
#ifdef M64P_GLIDENUI
void PluginAPI::SetInitialVideoSize(int width, int height)
{
dwnd().setInitialWindowSize(width, height);
}
#endif
void PluginAPI::ResizeVideoOutput(int _Width, int _Height)
{
dwnd().setWindowSize(_Width, _Height);
@@ -16,6 +16,7 @@ ViStatusChanged;
ViWidthChanged;
ReadScreen2;
SetRenderingCallback;
SetInitialVideoSize;
ResizeVideoOutput;
FBRead;
FBWrite;
@@ -68,6 +68,9 @@ extern int32_t win_width;
extern int32_t win_height;
extern int32_t win_fullscreen;
extern int32_t init_win_width;
extern int32_t init_win_height;
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle _CoreLibHandle, void *Context,
void (*DebugCallback)(void *, int, const char *))
{
@@ -169,6 +172,12 @@ extern "C"
return M64ERR_SUCCESS;
}
EXPORT void CALL SetInitialVideoSize(int width, int height)
{
init_win_width = width;
init_win_height = height;
}
}
EXPORT int CALL InitiateGFX (GFX_INFO Gfx_Info)
@@ -23,6 +23,8 @@ static ptr_VidExt_GL_GetAttribute CoreVideo_GL_GetAttribute = NULL;
static ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers = NULL;
// framebuffer texture states
int32_t init_win_width = 0;
int32_t init_win_height = 0;
int32_t win_width;
int32_t win_height;
int32_t win_fullscreen;
@@ -62,6 +64,9 @@ void screen_init(struct n64video_config* config)
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, config->vi.vsync);
win_width = init_win_width > 0 ? init_win_width : win_width;
win_height = init_win_height > 0 ? init_win_height : win_height;
CoreVideo_SetVideoMode(win_width, win_height, 0, win_fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, M64VIDEOFLAG_SUPPORT_RESIZING);
}
+19
View File
@@ -71,6 +71,10 @@ m64p_handle configVideoParallel = NULL;
uint32_t rdram_size;
static ptr_PluginGetVersion CoreGetVersion = NULL;
static int initialWidth = 0;
static int initialHeight = 0;
static bool initialSizeSet = false;
void plugin_init(void)
{
CoreGetVersion = (ptr_PluginGetVersion)DLSYM(CoreLibHandle, "PluginGetVersion");
@@ -268,6 +272,13 @@ extern "C"
return M64ERR_SUCCESS;
}
EXPORT void CALL SetInitialVideoSize(int width, int height)
{
initialWidth = width;
initialHeight = height;
initialSizeSet = true;
}
}
#endif // CONFIG_GUI
@@ -326,6 +337,12 @@ EXPORT int CALL RomOpen(void)
vk_ssreadbacks = 0; // can cause desyncs
}
if (initialSizeSet)
{
window_width = initialWidth;
window_height = initialHeight;
}
plugin_init();
if (vk_init())
@@ -347,6 +364,8 @@ EXPORT void CALL RomClosed(void)
{
vk_destroy();
}
initialSizeSet = false;
}
EXPORT void CALL ShowCFB(void)
+11
View File
@@ -511,6 +511,17 @@ CORE_EXPORT bool CorePluginsOpenROMConfig(CorePluginType type, void* parent, std
return open_plugin_config(type, parent, true, file);
}
CORE_EXPORT void CoreSetInitialVideoSize(int width, int height)
{
m64p::PluginApi& plugin = get_plugin(CorePluginType::Gfx);
if (!plugin.IsHooked() || plugin.SetInitialVideoSize == nullptr)
{
return;
}
plugin.SetInitialVideoSize(width, height);
}
CORE_EXPORT bool CoreAttachPlugins(void)
{
std::string error;
+3
View File
@@ -62,6 +62,9 @@ bool CorePluginsHasROMConfig(CorePluginType type);
// used plugin of given type
bool CorePluginsOpenROMConfig(CorePluginType type, void* parent = nullptr, std::filesystem::path file = "");
// sets initial video size for the video plugin
void CoreSetInitialVideoSize(int width, int height);
// attaches all used plugins
bool CoreAttachPlugins(void);
+2
View File
@@ -29,6 +29,7 @@ bool PluginApi::Hook(m64p_dynlib_handle handle)
HOOK_FUNC(handle, Plugin, Shutdown);
HOOK_FUNC_OPT(handle, Plugin, Config);
HOOK_FUNC_OPT(handle, Plugin, ConfigWithRomConfig);
HOOK_FUNC_OPT(handle, , SetInitialVideoSize);
HOOK_FUNC(handle, Plugin, GetVersion);
this->handle = handle;
@@ -42,6 +43,7 @@ bool PluginApi::Unhook(void)
UNHOOK_FUNC(Plugin, Shutdown);
UNHOOK_FUNC(Plugin, Config);
UNHOOK_FUNC(Plugin, ConfigWithRomConfig);
UNHOOK_FUNC(Plugin, SetInitialVideoSize);
UNHOOK_FUNC(Plugin, GetVersion);
this->handle = nullptr;
+1
View File
@@ -37,6 +37,7 @@ class PluginApi
ptr_PluginShutdown Shutdown;
ptr_PluginConfig Config;
ptr_PluginConfigWithRomConfig ConfigWithRomConfig;
ptr_SetInitialVideoSize SetInitialVideoSize;
ptr_PluginGetVersion GetVersion;
private:
+11
View File
@@ -39,6 +39,17 @@ typedef m64p_error (*ptr_PluginConfigWithRomConfig)(void*, int, CoreRomHeader*,
EXPORT m64p_error CALL PluginConfigWithRomConfig(void*, int, CoreRomHeader*, CoreRomSettings*);
#endif
/* SetInitialVideoSize(int width, int height)
*
* This optional function allows a front-end to set the initial video
* size for a video plugin.
*
*/
typedef void (*ptr_SetInitialVideoSize)(int width, int height);
#if defined(M64P_PLUGIN_PROTOTYPES) || defined(M64P_CORE_PROTOTYPES)
EXPORT void CALL SetInitialVideoSize(int width, int height);
#endif
#endif // __cplusplus
#ifdef __cplusplus
+8
View File
@@ -10,6 +10,7 @@
#include "EmulationThread.hpp"
#include <RMG-Core/Emulation.hpp>
#include <RMG-Core/Plugins.hpp>
#include <RMG-Core/Error.hpp>
#ifdef _WIN32
@@ -54,12 +55,19 @@ void EmulationThread::SetNetplay(QString address, int port, int player)
this->player = player;
}
void EmulationThread::SetVideoSize(int width, int height)
{
this->videoSize = QSize(width, height);
}
void EmulationThread::run(void)
{
this->inhibitScreensaver();
emit this->on_Emulation_Started();
CoreSetInitialVideoSize(this->videoSize.width(), this->videoSize.height());
bool ret = CoreStartEmulation(this->rom.toStdU32String(), this->disk.toStdU32String(),
this->address.toStdString(), this->port, this->player);
+3
View File
@@ -16,6 +16,7 @@
#include <QSurfaceFormat>
#include <QString>
#include <QThread>
#include <QSize>
enum class VidExtRenderMode
{
@@ -37,6 +38,7 @@ class EmulationThread : public QThread
void SetRomFile(QString);
void SetDiskFile(QString);
void SetNetplay(QString address, int port, int player);
void SetVideoSize(int width, int height);
void run(void) override;
@@ -46,6 +48,7 @@ class EmulationThread : public QThread
QString address;
int port = -1;
int player = -1;
QSize videoSize;
#ifndef _WIN32
uint32_t dbusCookieId = 0;
QDBusInterface* dbusInterface = nullptr;
+7 -76
View File
@@ -601,15 +601,12 @@ void MainWindow::updateUI(bool inEmulation, bool isPaused)
// launch RMG with a ROM on the commandline or drag & drop
this->ui_Widgets->setCurrentWidget(this->ui_Widget_Dummy);
}
this->storeGeometry();
}
else if (!this->ui_NoSwitchToRomBrowser)
{
this->setWindowTitle(this->ui_WindowTitle);
this->ui_Widgets->setCurrentWidget(this->ui_Widget_RomBrowser);
this->ui_StatusBar_RenderModeLabel->clear();
this->loadGeometry();
}
else
{
@@ -622,69 +619,9 @@ void MainWindow::updateUI(bool inEmulation, bool isPaused)
void MainWindow::storeGeometry(void)
{
if (this->ui_Geometry_Saved)
{
return;
}
this->ui_Geometry = this->saveGeometry();
this->ui_Geometry_Maximized = this->isMaximized();
this->ui_Geometry_Saved = true;
std::string geometryStr = this->ui_Geometry.toBase64().toStdString();
std::string geometryStr = this->saveGeometry().toBase64().toStdString();
CoreSettingsSetValue(SettingsID::RomBrowser_Geometry, geometryStr);
CoreSettingsSetValue(SettingsID::RomBrowser_Maximized, this->ui_Geometry_Maximized);
}
void MainWindow::loadGeometry(void)
{
if (!this->ui_Geometry_Saved)
{
return;
}
if (this->ui_Geometry_Maximized)
{
this->showMaximized();
}
else
{
this->restoreGeometry(this->ui_Geometry);
}
if (this->isFullScreen())
{
this->showNormal();
}
if (this->ui_ShowMenubar && this->menuBar()->isHidden())
{
this->menuBar()->show();
}
else if (!this->ui_ShowMenubar && !this->menuBar()->isHidden())
{
this->menuBar()->hide();
}
if (this->ui_ShowToolbar && this->toolBar->isHidden())
{
this->toolBar->show();
}
else if (!this->ui_ShowToolbar && !this->toolBar->isHidden())
{
this->toolBar->hide();
}
if (this->ui_ShowStatusbar && this->statusBar()->isHidden())
{
this->statusBar()->show();
}
else if (!this->ui_ShowStatusbar && !this->statusBar()->isHidden())
{
this->statusBar()->hide();
}
this->ui_Geometry_Saved = false;
CoreSettingsSetValue(SettingsID::RomBrowser_Maximized, this->isMaximized());
}
void MainWindow::initializeEmulationThread(void)
@@ -801,6 +738,8 @@ void MainWindow::launchEmulationThread(QString cartRom, QString diskRom, bool re
this->ui_ShowStatusbar = CoreSettingsGetBoolValue(SettingsID::GUI_StatusBar);
}
this->emulationThread->SetVideoSize(this->ui_Widgets->width() * this->devicePixelRatio(),
this->ui_Widgets->height() * this->devicePixelRatio());
this->emulationThread->SetRomFile(cartRom);
this->emulationThread->SetDiskFile(diskRom);
this->emulationThread->start();
@@ -2365,8 +2304,7 @@ void MainWindow::on_NetplaySessionDialog_rejected()
void MainWindow::on_VidExt_Init(VidExtRenderMode renderMode)
{
this->ui_VidExtRenderMode = renderMode;
this->ui_VidExtForceSetMode = true;
this->ui_VidExtRenderMode = renderMode;
if (CoreSettingsGetBoolValue(SettingsID::GUI_OpenGLES))
{
@@ -2553,12 +2491,9 @@ void MainWindow::on_VidExt_ResizeWindow(int width, int height)
height += this->statusBar()->height();
}
if (!this->ui_VidExtForceSetMode)
if (this->size() == QSize(width, height))
{
if (this->size() == QSize(width, height))
{
return;
}
return;
}
if (this->isMaximized() || this->isMinimized())
@@ -2567,10 +2502,6 @@ void MainWindow::on_VidExt_ResizeWindow(int width, int height)
}
this->resize(width, height);
// we've force set the size once,
// we can safely disable it now
this->ui_VidExtForceSetMode = false;
}
void MainWindow::on_VidExt_ToggleFS(bool fullscreen)
-6
View File
@@ -63,14 +63,9 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
QLabel *ui_StatusBar_Label = nullptr;
QLabel *ui_StatusBar_RenderModeLabel = nullptr;
QByteArray ui_Geometry;
bool ui_Geometry_Maximized = false;
bool ui_Geometry_Saved = false;
bool ui_HideCursorInEmulation = false;
bool ui_HideCursorInFullscreenEmulation = false;
bool ui_NoSwitchToRomBrowser = false;
bool ui_VidExtForceSetMode = false;
bool ui_LaunchInFullscreen = false;
bool ui_QuitAfterEmulation = false;
bool ui_RefreshRomListAfterEmulation = false;
@@ -136,7 +131,6 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
void updateUI(bool inEmulation, bool isPaused);
void storeGeometry(void);
void loadGeometry(void);
void initializeEmulationThread(void);
void connectEmulationThreadSignals(void);
@@ -69,6 +69,11 @@ void OGLWidget::resizeEvent(QResizeEvent *event)
return;
}
if (event->oldSize() == event->size())
{
return;
}
if (this->timerId != 0)
{
this->killTimer(this->timerId);
@@ -42,6 +42,11 @@ void VKWidget::resizeEvent(QResizeEvent *event)
return;
}
if (event->oldSize() == event->size())
{
return;
}
if (this->timerId != 0)
{
this->killTimer(this->timerId);