1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Implement window resize for MupenPlus.

This commit is contained in:
Sergey Lipskiy 2014-10-01 16:04:15 +07:00
parent 60dd897a39
commit c96b62adaf
9 changed files with 74 additions and 36 deletions

View File

@ -146,9 +146,25 @@ bool OGLVideo::changeWindow()
return true;
}
void OGLVideo::resizeWindow()
void OGLVideo::setWindowSize(u32 _width, u32 _height)
{
_resizeWindow();
if (m_width != _width || m_height != _height) {
m_resizeWidth = _width;
m_resizeHeight = _height;
m_bResizeWindow = true;
}
}
bool OGLVideo::resizeWindow()
{
if (!m_bResizeWindow)
return false;
m_render._destroyData();
if (!_resizeWindow())
_start();
m_render._initData();
m_bResizeWindow = false;
return true;
}
void OGLVideo::updateScale()

View File

@ -120,7 +120,8 @@ public:
void swapBuffers();
void saveScreenshot();
bool changeWindow();
void resizeWindow();
bool resizeWindow();
void setWindowSize(u32 _width, u32 _height);
void setCaptureScreen(const char * const _strDirectory);
void setToggleFullscreen() {m_bToggleFullscreen = true;}
void readScreen(void **_pDest, long *_pWidth, long *_pHeight );
@ -139,28 +140,30 @@ public:
protected:
OGLVideo() :
m_bCaptureScreen(false), m_bToggleFullscreen(false), m_bFullscreen(false),
m_width(0), m_height(0), m_heightOffset(0), m_scaleX(0), m_scaleY(0), m_strScreenDirectory(NULL)
m_bCaptureScreen(false), m_bToggleFullscreen(false), m_bResizeWindow(false), m_bFullscreen(false),
m_width(0), m_height(0), m_heightOffset(0), m_resizeWidth(0), m_resizeHeight(0),
m_scaleX(0), m_scaleY(0), m_strScreenDirectory(NULL)
{}
bool m_bCaptureScreen;
bool m_bToggleFullscreen;
bool m_bResizeWindow;
bool m_bFullscreen;
u32 m_width, m_height, m_heightOffset;
u32 m_width, m_height, m_heightOffset, m_resizeWidth, m_resizeHeight;
f32 m_scaleX, m_scaleY;
const char * m_strScreenDirectory;
private:
OGLRender m_render;
private:
virtual bool _start() = 0;
virtual void _stop() = 0;
virtual void _swapBuffers() = 0;
virtual void _saveScreenshot() = 0;
virtual void _changeWindow() = 0;
virtual void _resizeWindow() = 0;
virtual bool _resizeWindow() = 0;
};
inline

View File

@ -61,7 +61,7 @@ public:
void FBRead(unsigned int _addr) {}
void FBWrite(unsigned int addr, unsigned int size) {}
void FBGetFrameBufferInfo(void * _p) {}
void ResizeVideoOutput(int _Width, int _Height) {}
void ResizeVideoOutput(int _Width, int _Height);
m64p_error PluginStartup(m64p_dynlib_handle _CoreLibHandle);
m64p_error PluginShutdown();

2
VI.cpp
View File

@ -71,6 +71,8 @@ void VI_UpdateScreen()
OGLVideo & ogl = video();
if (ogl.changeWindow())
return;
if (ogl.resizeWindow())
return;
ogl.saveScreenshot();
if (config.frameBufferEmulation.enable) {

View File

@ -103,3 +103,8 @@ void PluginAPI::SetRenderingCallback(void (*callback)(int))
{
renderCallback = callback;
}
void PluginAPI::ResizeVideoOutput(int _Width, int _Height)
{
video().setWindowSize(_Width, _Height);
}

View File

@ -19,11 +19,13 @@ public:
OGLVideoMupenPlus() {}
private:
void _setAttributes();
virtual bool _start();
virtual void _stop();
virtual void _swapBuffers();
virtual void _saveScreenshot();
virtual void _resizeWindow();
virtual bool _resizeWindow();
virtual void _changeWindow();
};
@ -33,13 +35,8 @@ OGLVideo & OGLVideo::get()
return video;
}
bool OGLVideoMupenPlus::_start()
void OGLVideoMupenPlus::_setAttributes()
{
m_bFullscreen = config.video.fullscreen > 0;
m_width = config.video.windowedWidth;
m_height = config.video.windowedHeight;
CoreVideo_Init();
CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1);
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, config.video.verticalSync);
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 32);
@ -56,9 +53,20 @@ bool OGLVideoMupenPlus::_start()
else
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 16);
}
}
bool OGLVideoMupenPlus::_start()
{
CoreVideo_Init();
_setAttributes();
m_bFullscreen = config.video.fullscreen > 0;
m_width = config.video.windowedWidth;
m_height = config.video.windowedHeight;
printf("(II) Setting video mode %dx%d...\n", m_width, m_height);
if (CoreVideo_SetVideoMode(m_width, m_height, 0, m_bFullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, (m64p_video_flags)0) != M64ERR_SUCCESS) {
const m64p_video_flags flags = M64VIDEOFLAG_SUPPORT_RESIZING;
if (CoreVideo_SetVideoMode(m_width, m_height, 0, m_bFullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, flags) != M64ERR_SUCCESS) {
printf("(EE) Error setting videomode %dx%d\n", m_width, m_height);
CoreVideo_Quit();
return false;
@ -92,16 +100,21 @@ void OGLVideoMupenPlus::_saveScreenshot()
{
}
void OGLVideoMupenPlus::_resizeWindow()
bool OGLVideoMupenPlus::_resizeWindow()
{
u32 newWidth, newHeight;
newWidth = config.video.windowedWidth;
newHeight = config.video.windowedHeight;
if (m_width != newWidth || m_height != newHeight) {
m_width = newWidth;
m_height = newHeight;
CoreVideo_ResizeWindow(m_width, m_height);
_setAttributes();
m_bFullscreen = false;
m_width = m_resizeWidth;
m_height = m_resizeHeight;
if (CoreVideo_ResizeWindow(m_width, m_height) != M64ERR_SUCCESS) {
printf("(EE) Error setting videomode %dx%d\n", m_width, m_height);
m_width = config.video.windowedWidth;
m_height = config.video.windowedHeight;
CoreVideo_Quit();
return false;
}
return true;
}
void OGLVideoMupenPlus::_changeWindow()

View File

@ -17,7 +17,7 @@ private:
virtual void _stop();
virtual void _swapBuffers();
virtual void _saveScreenshot();
virtual void _resizeWindow();
virtual bool _resizeWindow();
virtual void _changeWindow();
#if defined(USE_SDL)
@ -132,8 +132,9 @@ void OGLVideoPosix::_saveScreenshot()
{
}
void OGLVideoPosix::_resizeWindow()
bool OGLVideoPosix::_resizeWindow()
{
return false;
}
void OGLVideoPosix::_changeWindow()

View File

@ -188,7 +188,7 @@ void Config_ApplyDlgConfig( HWND hWndDlg )
config.enableHWLighting = (SendDlgItemMessage( hWndDlg, IDC_HWLIGHT, BM_GETCHECK, NULL, NULL ) == BST_CHECKED);
if (!video().isFullscreen())
video().resizeWindow();
video().setWindowSize(config.video.windowedWidth, config.video.windowedHeight);
Config_SaveConfig();
}

View File

@ -14,7 +14,7 @@ private:
virtual void _stop();
virtual void _swapBuffers();
virtual void _saveScreenshot();
virtual void _resizeWindow();
virtual bool _resizeWindow();
virtual void _changeWindow();
HGLRC hRC;
@ -84,9 +84,7 @@ bool OGLVideoWindows::_start()
return false;
}
_resizeWindow();
return true;
return _resizeWindow();
}
void OGLVideoWindows::_stop()
@ -230,7 +228,7 @@ void OGLVideoWindows::_changeWindow()
}
}
void OGLVideoWindows::_resizeWindow()
bool OGLVideoWindows::_resizeWindow()
{
RECT windowRect, statusRect, toolRect;
@ -239,7 +237,7 @@ void OGLVideoWindows::_resizeWindow()
m_height = config.video.fullscreenHeight;
m_heightOffset = 0;
SetWindowPos( hWnd, NULL, 0, 0, m_width, m_height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
return (SetWindowPos( hWnd, NULL, 0, 0, m_width, m_height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW ) == TRUE);
} else {
m_width = config.video.windowedWidth;
m_height = config.video.windowedHeight;
@ -258,7 +256,7 @@ void OGLVideoWindows::_resizeWindow()
AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL );
SetWindowPos( hWnd, NULL, 0, 0, windowRect.right - windowRect.left + 1,
windowRect.bottom - windowRect.top + 1 + toolRect.bottom - toolRect.top + 1, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE );
return (SetWindowPos( hWnd, NULL, 0, 0, windowRect.right - windowRect.left + 1,
windowRect.bottom - windowRect.top + 1 + toolRect.bottom - toolRect.top + 1, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE ) == TRUE);
}
}