mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Implement window resize for MupenPlus.
This commit is contained in:
parent
60dd897a39
commit
c96b62adaf
20
OpenGL.cpp
20
OpenGL.cpp
|
@ -146,9 +146,25 @@ bool OGLVideo::changeWindow()
|
||||||
return true;
|
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()
|
void OGLVideo::updateScale()
|
||||||
|
|
15
OpenGL.h
15
OpenGL.h
|
@ -120,7 +120,8 @@ public:
|
||||||
void swapBuffers();
|
void swapBuffers();
|
||||||
void saveScreenshot();
|
void saveScreenshot();
|
||||||
bool changeWindow();
|
bool changeWindow();
|
||||||
void resizeWindow();
|
bool resizeWindow();
|
||||||
|
void setWindowSize(u32 _width, u32 _height);
|
||||||
void setCaptureScreen(const char * const _strDirectory);
|
void setCaptureScreen(const char * const _strDirectory);
|
||||||
void setToggleFullscreen() {m_bToggleFullscreen = true;}
|
void setToggleFullscreen() {m_bToggleFullscreen = true;}
|
||||||
void readScreen(void **_pDest, long *_pWidth, long *_pHeight );
|
void readScreen(void **_pDest, long *_pWidth, long *_pHeight );
|
||||||
|
@ -139,28 +140,30 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OGLVideo() :
|
OGLVideo() :
|
||||||
m_bCaptureScreen(false), m_bToggleFullscreen(false), m_bFullscreen(false),
|
m_bCaptureScreen(false), m_bToggleFullscreen(false), m_bResizeWindow(false), m_bFullscreen(false),
|
||||||
m_width(0), m_height(0), m_heightOffset(0), m_scaleX(0), m_scaleY(0), m_strScreenDirectory(NULL)
|
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_bCaptureScreen;
|
||||||
bool m_bToggleFullscreen;
|
bool m_bToggleFullscreen;
|
||||||
|
bool m_bResizeWindow;
|
||||||
bool m_bFullscreen;
|
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;
|
f32 m_scaleX, m_scaleY;
|
||||||
|
|
||||||
const char * m_strScreenDirectory;
|
const char * m_strScreenDirectory;
|
||||||
|
|
||||||
|
private:
|
||||||
OGLRender m_render;
|
OGLRender m_render;
|
||||||
|
|
||||||
private:
|
|
||||||
virtual bool _start() = 0;
|
virtual bool _start() = 0;
|
||||||
virtual void _stop() = 0;
|
virtual void _stop() = 0;
|
||||||
virtual void _swapBuffers() = 0;
|
virtual void _swapBuffers() = 0;
|
||||||
virtual void _saveScreenshot() = 0;
|
virtual void _saveScreenshot() = 0;
|
||||||
virtual void _changeWindow() = 0;
|
virtual void _changeWindow() = 0;
|
||||||
virtual void _resizeWindow() = 0;
|
virtual bool _resizeWindow() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
void FBRead(unsigned int _addr) {}
|
void FBRead(unsigned int _addr) {}
|
||||||
void FBWrite(unsigned int addr, unsigned int size) {}
|
void FBWrite(unsigned int addr, unsigned int size) {}
|
||||||
void FBGetFrameBufferInfo(void * _p) {}
|
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 PluginStartup(m64p_dynlib_handle _CoreLibHandle);
|
||||||
m64p_error PluginShutdown();
|
m64p_error PluginShutdown();
|
||||||
|
|
2
VI.cpp
2
VI.cpp
|
@ -71,6 +71,8 @@ void VI_UpdateScreen()
|
||||||
OGLVideo & ogl = video();
|
OGLVideo & ogl = video();
|
||||||
if (ogl.changeWindow())
|
if (ogl.changeWindow())
|
||||||
return;
|
return;
|
||||||
|
if (ogl.resizeWindow())
|
||||||
|
return;
|
||||||
ogl.saveScreenshot();
|
ogl.saveScreenshot();
|
||||||
|
|
||||||
if (config.frameBufferEmulation.enable) {
|
if (config.frameBufferEmulation.enable) {
|
||||||
|
|
|
@ -103,3 +103,8 @@ void PluginAPI::SetRenderingCallback(void (*callback)(int))
|
||||||
{
|
{
|
||||||
renderCallback = callback;
|
renderCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PluginAPI::ResizeVideoOutput(int _Width, int _Height)
|
||||||
|
{
|
||||||
|
video().setWindowSize(_Width, _Height);
|
||||||
|
}
|
||||||
|
|
|
@ -19,11 +19,13 @@ public:
|
||||||
OGLVideoMupenPlus() {}
|
OGLVideoMupenPlus() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _setAttributes();
|
||||||
|
|
||||||
virtual bool _start();
|
virtual bool _start();
|
||||||
virtual void _stop();
|
virtual void _stop();
|
||||||
virtual void _swapBuffers();
|
virtual void _swapBuffers();
|
||||||
virtual void _saveScreenshot();
|
virtual void _saveScreenshot();
|
||||||
virtual void _resizeWindow();
|
virtual bool _resizeWindow();
|
||||||
virtual void _changeWindow();
|
virtual void _changeWindow();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,13 +35,8 @@ OGLVideo & OGLVideo::get()
|
||||||
return video;
|
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_DOUBLEBUFFER, 1);
|
||||||
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, config.video.verticalSync);
|
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, config.video.verticalSync);
|
||||||
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 32);
|
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 32);
|
||||||
|
@ -56,9 +53,20 @@ bool OGLVideoMupenPlus::_start()
|
||||||
else
|
else
|
||||||
CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 16);
|
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);
|
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);
|
printf("(EE) Error setting videomode %dx%d\n", m_width, m_height);
|
||||||
CoreVideo_Quit();
|
CoreVideo_Quit();
|
||||||
return false;
|
return false;
|
||||||
|
@ -92,16 +100,21 @@ void OGLVideoMupenPlus::_saveScreenshot()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void OGLVideoMupenPlus::_resizeWindow()
|
bool OGLVideoMupenPlus::_resizeWindow()
|
||||||
{
|
{
|
||||||
u32 newWidth, newHeight;
|
_setAttributes();
|
||||||
newWidth = config.video.windowedWidth;
|
|
||||||
newHeight = config.video.windowedHeight;
|
m_bFullscreen = false;
|
||||||
if (m_width != newWidth || m_height != newHeight) {
|
m_width = m_resizeWidth;
|
||||||
m_width = newWidth;
|
m_height = m_resizeHeight;
|
||||||
m_height = newHeight;
|
if (CoreVideo_ResizeWindow(m_width, m_height) != M64ERR_SUCCESS) {
|
||||||
CoreVideo_ResizeWindow(m_width, m_height);
|
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()
|
void OGLVideoMupenPlus::_changeWindow()
|
||||||
|
|
|
@ -17,7 +17,7 @@ private:
|
||||||
virtual void _stop();
|
virtual void _stop();
|
||||||
virtual void _swapBuffers();
|
virtual void _swapBuffers();
|
||||||
virtual void _saveScreenshot();
|
virtual void _saveScreenshot();
|
||||||
virtual void _resizeWindow();
|
virtual bool _resizeWindow();
|
||||||
virtual void _changeWindow();
|
virtual void _changeWindow();
|
||||||
|
|
||||||
#if defined(USE_SDL)
|
#if defined(USE_SDL)
|
||||||
|
@ -132,8 +132,9 @@ void OGLVideoPosix::_saveScreenshot()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void OGLVideoPosix::_resizeWindow()
|
bool OGLVideoPosix::_resizeWindow()
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OGLVideoPosix::_changeWindow()
|
void OGLVideoPosix::_changeWindow()
|
||||||
|
|
|
@ -188,7 +188,7 @@ void Config_ApplyDlgConfig( HWND hWndDlg )
|
||||||
config.enableHWLighting = (SendDlgItemMessage( hWndDlg, IDC_HWLIGHT, BM_GETCHECK, NULL, NULL ) == BST_CHECKED);
|
config.enableHWLighting = (SendDlgItemMessage( hWndDlg, IDC_HWLIGHT, BM_GETCHECK, NULL, NULL ) == BST_CHECKED);
|
||||||
|
|
||||||
if (!video().isFullscreen())
|
if (!video().isFullscreen())
|
||||||
video().resizeWindow();
|
video().setWindowSize(config.video.windowedWidth, config.video.windowedHeight);
|
||||||
|
|
||||||
Config_SaveConfig();
|
Config_SaveConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ private:
|
||||||
virtual void _stop();
|
virtual void _stop();
|
||||||
virtual void _swapBuffers();
|
virtual void _swapBuffers();
|
||||||
virtual void _saveScreenshot();
|
virtual void _saveScreenshot();
|
||||||
virtual void _resizeWindow();
|
virtual bool _resizeWindow();
|
||||||
virtual void _changeWindow();
|
virtual void _changeWindow();
|
||||||
|
|
||||||
HGLRC hRC;
|
HGLRC hRC;
|
||||||
|
@ -84,9 +84,7 @@ bool OGLVideoWindows::_start()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_resizeWindow();
|
return _resizeWindow();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OGLVideoWindows::_stop()
|
void OGLVideoWindows::_stop()
|
||||||
|
@ -230,7 +228,7 @@ void OGLVideoWindows::_changeWindow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OGLVideoWindows::_resizeWindow()
|
bool OGLVideoWindows::_resizeWindow()
|
||||||
{
|
{
|
||||||
RECT windowRect, statusRect, toolRect;
|
RECT windowRect, statusRect, toolRect;
|
||||||
|
|
||||||
|
@ -239,7 +237,7 @@ void OGLVideoWindows::_resizeWindow()
|
||||||
m_height = config.video.fullscreenHeight;
|
m_height = config.video.fullscreenHeight;
|
||||||
m_heightOffset = 0;
|
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 {
|
} else {
|
||||||
m_width = config.video.windowedWidth;
|
m_width = config.video.windowedWidth;
|
||||||
m_height = config.video.windowedHeight;
|
m_height = config.video.windowedHeight;
|
||||||
|
@ -258,7 +256,7 @@ void OGLVideoWindows::_resizeWindow()
|
||||||
|
|
||||||
AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL );
|
AdjustWindowRect( &windowRect, GetWindowLong( hWnd, GWL_STYLE ), GetMenu( hWnd ) != NULL );
|
||||||
|
|
||||||
SetWindowPos( hWnd, NULL, 0, 0, windowRect.right - windowRect.left + 1,
|
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 );
|
windowRect.bottom - windowRect.top + 1 + toolRect.bottom - toolRect.top + 1, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE ) == TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user