Integrate C++11 branch into 5_1-new
This commit is contained in:
@@ -23,7 +23,7 @@ static HDC g_HDC;
|
||||
static VideoModeParams g_CurrentParams;
|
||||
static bool g_bResolutionChanged = false;
|
||||
static bool g_bHasFocus = true;
|
||||
static HICON g_hIcon = NULL;
|
||||
static HICON g_hIcon = nullptr;
|
||||
static bool m_bWideWindowClass;
|
||||
static bool g_bD3D = false;
|
||||
|
||||
@@ -36,8 +36,8 @@ static UINT g_iQueryCancelAutoPlayMessage = 0;
|
||||
static RString GetNewWindow()
|
||||
{
|
||||
HWND h = GetForegroundWindow();
|
||||
if( h == NULL )
|
||||
return "(NULL)";
|
||||
if( h == nullptr )
|
||||
return "(nullptr)";
|
||||
|
||||
DWORD iProcessID;
|
||||
GetWindowThreadProcessId( h, &iProcessID );
|
||||
@@ -92,7 +92,7 @@ static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wPar
|
||||
}
|
||||
else if( !g_bHasFocus && bHadFocus )
|
||||
{
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wPar
|
||||
case WM_SETCURSOR:
|
||||
if( !g_CurrentParams.windowed )
|
||||
{
|
||||
SetCursor( NULL );
|
||||
SetCursor(nullptr);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@@ -190,7 +190,7 @@ static void AdjustVideoModeParams( VideoModeParams &p )
|
||||
DEVMODE dm;
|
||||
ZERO( dm );
|
||||
dm.dmSize = sizeof(dm);
|
||||
if( !EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) )
|
||||
if( !EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &dm) )
|
||||
{
|
||||
p.rate = 60;
|
||||
LOG->Warn( "%s", werr_ssprintf(GetLastError(), "EnumDisplaySettings failed").c_str() );
|
||||
@@ -226,7 +226,7 @@ RString GraphicsWindow::SetScreenMode( const VideoModeParams &p )
|
||||
if( p.windowed )
|
||||
{
|
||||
// We're going windowed. If we were previously fullscreen, reset.
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
|
||||
return RString();
|
||||
}
|
||||
@@ -244,7 +244,7 @@ RString GraphicsWindow::SetScreenMode( const VideoModeParams &p )
|
||||
DevMode.dmDisplayFrequency = p.rate;
|
||||
DevMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
}
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
|
||||
int ret = ChangeDisplaySettings( &DevMode, CDS_FULLSCREEN );
|
||||
if( ret != DISP_CHANGE_SUCCESSFUL && (DevMode.dmFields & DM_DISPLAYFREQUENCY) )
|
||||
@@ -278,20 +278,20 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
// Adjust g_CurrentParams to reflect the actual display settings.
|
||||
AdjustVideoModeParams( g_CurrentParams );
|
||||
|
||||
if( g_hWndMain == NULL || bForceRecreateWindow )
|
||||
if( g_hWndMain == nullptr || bForceRecreateWindow )
|
||||
{
|
||||
int iWindowStyle = GetWindowStyle( p.windowed );
|
||||
|
||||
AppInstance inst;
|
||||
HWND hWnd = CreateWindow( g_sClassName, "app", iWindowStyle,
|
||||
0, 0, 0, 0, NULL, NULL, inst, NULL );
|
||||
if( hWnd == NULL )
|
||||
0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
|
||||
if( hWnd == nullptr )
|
||||
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "CreateWindow" ).c_str() );
|
||||
|
||||
/* If an old window exists, transfer focus to the new window before
|
||||
* deleting it, or some other window may temporarily get focus, which
|
||||
* can cause it to be resized. */
|
||||
if( g_hWndMain != NULL )
|
||||
if( g_hWndMain != nullptr )
|
||||
{
|
||||
// While we change to the new window, don't do ChangeDisplaySettings in WM_ACTIVATE.
|
||||
g_bRecreatingVideoMode = true;
|
||||
@@ -319,14 +319,14 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
} while(0);
|
||||
|
||||
// Update the window icon.
|
||||
if( g_hIcon != NULL )
|
||||
if( g_hIcon != nullptr )
|
||||
{
|
||||
SetClassLong( g_hWndMain, GCL_HICON, (LONG) LoadIcon(NULL,IDI_APPLICATION) );
|
||||
SetClassLong( g_hWndMain, GCL_HICON, (LONG) LoadIcon(nullptr,IDI_APPLICATION) );
|
||||
DestroyIcon( g_hIcon );
|
||||
g_hIcon = NULL;
|
||||
g_hIcon = nullptr;
|
||||
}
|
||||
g_hIcon = IconFromFile( p.sIconFile );
|
||||
if( g_hIcon != NULL )
|
||||
if( g_hIcon != nullptr )
|
||||
SetClassLong( g_hWndMain, GCL_HICON, (LONG) g_hIcon );
|
||||
|
||||
/* The window style may change as a result of switching to or from fullscreen;
|
||||
@@ -364,9 +364,9 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
* If we don't do this, then starting up in a D3D fullscreen window may
|
||||
* cause all other windows on the system to be resized. */
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
@@ -374,36 +374,36 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
/** @brief Shut down the window, but don't reset the video mode. */
|
||||
void GraphicsWindow::DestroyGraphicsWindow()
|
||||
{
|
||||
if( g_HDC != NULL )
|
||||
if( g_HDC != nullptr )
|
||||
{
|
||||
ReleaseDC( g_hWndMain, g_HDC );
|
||||
g_HDC = NULL;
|
||||
g_HDC = nullptr;
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
if( g_hWndMain != NULL )
|
||||
if( g_hWndMain != nullptr )
|
||||
{
|
||||
DestroyWindow( g_hWndMain );
|
||||
g_hWndMain = NULL;
|
||||
g_hWndMain = nullptr;
|
||||
CrashHandler::SetForegroundWindow( g_hWndMain );
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
if( g_hIcon != NULL )
|
||||
if( g_hIcon != nullptr )
|
||||
{
|
||||
DestroyIcon( g_hIcon );
|
||||
g_hIcon = NULL;
|
||||
g_hIcon = nullptr;
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
CHECKPOINT;
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
CHECKPOINT;
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
@@ -423,10 +423,10 @@ void GraphicsWindow::Initialize( bool bD3D )
|
||||
}
|
||||
|
||||
//if we have dwm, get function pointers to the dll functions
|
||||
if( hInstanceDwmapi != NULL )
|
||||
{
|
||||
PFN_DwmFlush = (HRESULT (WINAPI *)(VOID))GetProcAddress( hInstanceDwmapi, "DwmFlush" );
|
||||
PFN_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL*))GetProcAddress( hInstanceDwmapi, "DwmIsCompositionEnabled" );
|
||||
if( hInstanceDwmapi != nullptr )
|
||||
{
|
||||
PFN_DwmFlush = (HRESULT (WINAPI *)(VOID))GetProcAddress( hInstanceDwmapi, "DwmFlush" );
|
||||
PFN_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL*))GetProcAddress( hInstanceDwmapi, "DwmIsCompositionEnabled" );
|
||||
}
|
||||
|
||||
AppInstance inst;
|
||||
@@ -440,10 +440,10 @@ void GraphicsWindow::Initialize( bool bD3D )
|
||||
0, /* cbClsExtra */
|
||||
0, /* cbWndExtra */
|
||||
inst, /* hInstance */
|
||||
NULL, /* set icon later */
|
||||
LoadCursor( NULL, IDC_ARROW ), /* default cursor */
|
||||
NULL, /* hbrBackground */
|
||||
NULL, /* lpszMenuName */
|
||||
nullptr, /* set icon later */
|
||||
LoadCursor( nullptr, IDC_ARROW ), /* default cursor */
|
||||
nullptr, /* hbrBackground */
|
||||
nullptr, /* lpszMenuName */
|
||||
wsClassName.c_str() /* lpszClassName */
|
||||
};
|
||||
|
||||
@@ -458,10 +458,10 @@ void GraphicsWindow::Initialize( bool bD3D )
|
||||
0, /* cbClsExtra */
|
||||
0, /* cbWndExtra */
|
||||
inst, /* hInstance */
|
||||
NULL, /* set icon later */
|
||||
LoadCursor( NULL, IDC_ARROW ), /* default cursor */
|
||||
NULL, /* hbrBackground */
|
||||
NULL, /* lpszMenuName */
|
||||
nullptr, /* set icon later */
|
||||
LoadCursor( nullptr, IDC_ARROW ), /* default cursor */
|
||||
nullptr, /* hbrBackground */
|
||||
nullptr, /* lpszMenuName */
|
||||
g_sClassName /* lpszClassName */
|
||||
};
|
||||
|
||||
@@ -481,7 +481,7 @@ void GraphicsWindow::Shutdown()
|
||||
* It'd be nice to not do this: Windows will do it when we quit, and if
|
||||
* we're shutting down OpenGL to try D3D, this will cause extra mode
|
||||
* switches. However, we need to do this before displaying dialogs. */
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
|
||||
AppInstance inst;
|
||||
UnregisterClass( g_sClassName, inst );
|
||||
@@ -489,7 +489,7 @@ void GraphicsWindow::Shutdown()
|
||||
|
||||
HDC GraphicsWindow::GetHDC()
|
||||
{
|
||||
ASSERT( g_HDC != NULL );
|
||||
ASSERT( g_HDC != nullptr );
|
||||
return g_HDC;
|
||||
}
|
||||
|
||||
@@ -501,29 +501,29 @@ const VideoModeParams &GraphicsWindow::GetParams()
|
||||
void GraphicsWindow::Update()
|
||||
{
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
|
||||
HOOKS->SetHasFocus( g_bHasFocus );
|
||||
|
||||
if (g_CurrentParams.vsync)
|
||||
{
|
||||
//if we can use DWM
|
||||
if( hInstanceDwmapi != NULL )
|
||||
{
|
||||
BOOL compositeEnabled = true;
|
||||
PFN_DwmIsCompositionEnabled(&compositeEnabled);
|
||||
if (compositeEnabled)
|
||||
{
|
||||
{
|
||||
//if we can use DWM
|
||||
if( hInstanceDwmapi != nullptr )
|
||||
{
|
||||
BOOL compositeEnabled = true;
|
||||
PFN_DwmIsCompositionEnabled(&compositeEnabled);
|
||||
if (compositeEnabled)
|
||||
{
|
||||
PFN_DwmFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( g_bResolutionChanged && DISPLAY != NULL )
|
||||
if( g_bResolutionChanged && DISPLAY != nullptr )
|
||||
{
|
||||
//LOG->Warn( "Changing resolution" );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user