mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Merge pull request #1512 from Lopuska/OpenGL_FullScreen_Clean
[OpenGL - Win32] This fix a bug during resolution change.
This commit is contained in:
commit
d08c0df85d
1 changed files with 81 additions and 92 deletions
|
|
@ -26,8 +26,10 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
#include "math/mMath.h"
|
#include "math/mMath.h"
|
||||||
|
#include "gfx/gfxDevice.h"
|
||||||
#include "gfx/gfxStructs.h"
|
#include "gfx/gfxStructs.h"
|
||||||
|
|
||||||
|
#include "windowManager/platformWindowMgr.h"
|
||||||
#include "windowManager/win32/win32Window.h"
|
#include "windowManager/win32/win32Window.h"
|
||||||
#include "windowManager/win32/win32WindowMgr.h"
|
#include "windowManager/win32/win32WindowMgr.h"
|
||||||
#include "windowManager/win32/win32CursorController.h"
|
#include "windowManager/win32/win32CursorController.h"
|
||||||
|
|
@ -39,11 +41,6 @@
|
||||||
// for winState structure
|
// for winState structure
|
||||||
#include "platformWin32/platformWin32.h"
|
#include "platformWin32/platformWin32.h"
|
||||||
|
|
||||||
#include <d3d9types.h>
|
|
||||||
#include "gfx/gfxDevice.h"
|
|
||||||
|
|
||||||
#include <zmouse.h>
|
|
||||||
|
|
||||||
const UTF16* _MainWindowClassName = L"TorqueJuggernaughtWindow";
|
const UTF16* _MainWindowClassName = L"TorqueJuggernaughtWindow";
|
||||||
const UTF16* _CurtainWindowClassName = L"TorqueJuggernaughtCurtainWindow";
|
const UTF16* _CurtainWindowClassName = L"TorqueJuggernaughtCurtainWindow";
|
||||||
|
|
||||||
|
|
@ -152,7 +149,7 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
|
||||||
|
|
||||||
if( needCurtain )
|
if( needCurtain )
|
||||||
{
|
{
|
||||||
Con::errorf("Win32Window::setVideoMode - invoking curtain");
|
Con::printf( "Win32Window::setVideoMode - invoking curtain" );
|
||||||
mOwningManager->lowerCurtain();
|
mOwningManager->lowerCurtain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +159,7 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
|
||||||
// Can't switch to fullscreen while a child of another window
|
// Can't switch to fullscreen while a child of another window
|
||||||
if( mode.fullScreen && !Platform::getWebDeployment() && mOwningManager->getParentWindow() )
|
if( mode.fullScreen && !Platform::getWebDeployment() && mOwningManager->getParentWindow() )
|
||||||
{
|
{
|
||||||
mOldParent = (HWND)mOwningManager->getParentWindow();
|
mOldParent = reinterpret_cast<HWND>( mOwningManager->getParentWindow() );
|
||||||
mOwningManager->setParentWindow( NULL );
|
mOwningManager->setParentWindow( NULL );
|
||||||
}
|
}
|
||||||
else if( !mode.fullScreen && mOldParent )
|
else if( !mode.fullScreen && mOldParent )
|
||||||
|
|
@ -189,11 +186,10 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
|
||||||
dv.dmPelsHeight = mode.resolution.y;
|
dv.dmPelsHeight = mode.resolution.y;
|
||||||
dv.dmBitsPerPel = mode.bitDepth;
|
dv.dmBitsPerPel = mode.bitDepth;
|
||||||
dv.dmDisplayFrequency = mode.refreshRate;
|
dv.dmDisplayFrequency = mode.refreshRate;
|
||||||
dv.dmFields = (DM_PELSWIDTH | DM_PELSHEIGHT);
|
dv.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||||
ChangeDisplaySettings( &dv, CDS_FULLSCREEN );
|
ChangeDisplaySettings( &dv, CDS_FULLSCREEN );
|
||||||
SetWindowLong( getHWND(), GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW );
|
SetWindowLong( getHWND(), GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW );
|
||||||
SetWindowPos(getHWND(), HWND_TOP,
|
SetWindowPos( getHWND(), HWND_TOP, mi.rcMonitor.left,
|
||||||
mi.rcMonitor.left,
|
|
||||||
mi.rcMonitor.top,
|
mi.rcMonitor.top,
|
||||||
mi.rcMonitor.right - mi.rcMonitor.left,
|
mi.rcMonitor.right - mi.rcMonitor.left,
|
||||||
mi.rcMonitor.bottom - mi.rcMonitor.top,
|
mi.rcMonitor.bottom - mi.rcMonitor.top,
|
||||||
|
|
@ -204,11 +200,8 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
|
||||||
ShowWindow( getHWND(), SW_SHOWNORMAL );
|
ShowWindow( getHWND(), SW_SHOWNORMAL );
|
||||||
|
|
||||||
// Clear the menu bar from the window for full screen
|
// Clear the menu bar from the window for full screen
|
||||||
HMENU menu = GetMenu(getHWND());
|
if( GetMenu( getHWND() ) )
|
||||||
if(menu)
|
|
||||||
{
|
|
||||||
SetMenu( getHWND(), NULL );
|
SetMenu( getHWND(), NULL );
|
||||||
}
|
|
||||||
|
|
||||||
// When switching to Fullscreen, reset device after setting style
|
// When switching to Fullscreen, reset device after setting style
|
||||||
if( mTarget.isValid() )
|
if( mTarget.isValid() )
|
||||||
|
|
@ -224,7 +217,8 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
|
||||||
dv.dmSize = sizeof( DEVMODE );
|
dv.dmSize = sizeof( DEVMODE );
|
||||||
EnumDisplaySettings( dd.DeviceName, ENUM_CURRENT_SETTINGS, &dv );
|
EnumDisplaySettings( dd.DeviceName, ENUM_CURRENT_SETTINGS, &dv );
|
||||||
|
|
||||||
if ((mode.resolution.x != dv.dmPelsWidth) || (mode.resolution.y != dv.dmPelsHeight))
|
if ( ( WindowManager->getDesktopResolution() != mode.resolution ||
|
||||||
|
( mode.resolution.x != dv.dmPelsWidth ) || ( mode.resolution.y != dv.dmPelsHeight ) ) )
|
||||||
ChangeDisplaySettings( NULL, 0 );
|
ChangeDisplaySettings( NULL, 0 );
|
||||||
|
|
||||||
// Reset device *first*, so that when we call setSize() and let it
|
// Reset device *first*, so that when we call setSize() and let it
|
||||||
|
|
@ -253,20 +247,16 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HWND parentWin = (HWND)mOwningManager->getParentWindow();
|
HWND parentWin = reinterpret_cast<HWND>( mOwningManager->getParentWindow() );
|
||||||
RECT windowRect;
|
RECT windowRect;
|
||||||
GetClientRect( parentWin, &windowRect );
|
GetClientRect( parentWin, &windowRect );
|
||||||
Point2I res( windowRect.right - windowRect.left, windowRect.bottom - windowRect.top );
|
Point2I res( windowRect.right - windowRect.left, windowRect.bottom - windowRect.top );
|
||||||
|
|
||||||
if ( res.x == 0 || res.y == 0 )
|
if ( res.x == 0 || res.y == 0 )
|
||||||
{
|
setSize( mode.resolution ); // Must be too early in the window set up to obtain the parent's size.
|
||||||
// Must be too early in the window set up to obtain the parent's size.
|
|
||||||
setSize(mode.resolution);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
setSize( res );
|
setSize( res );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( !mOffscreenRender )
|
if ( !mOffscreenRender )
|
||||||
{
|
{
|
||||||
|
|
@ -287,7 +277,6 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
|
||||||
mOwningManager->raiseCurtain();
|
mOwningManager->raiseCurtain();
|
||||||
|
|
||||||
SetForegroundWindow( getHWND() );
|
SetForegroundWindow( getHWND() );
|
||||||
|
|
||||||
getScreenResChangeSignal().trigger( this, true );
|
getScreenResChangeSignal().trigger( this, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue