keep xp on life support a bit longer, check for vista+ stuff (#1456)

This commit is contained in:
Chris Pable
2017-05-25 00:34:33 -07:00
committed by Colby Klein
parent c5f51d1e5a
commit 55281cebd2
4 changed files with 58 additions and 5 deletions
+8
View File
@@ -210,7 +210,15 @@ RString DSoundBuf::Init( DSound &ds, DSoundBuf::hw hardware,
DSBUFFERDESC format; DSBUFFERDESC format;
memset( &format, 0, sizeof(format) ); memset( &format, 0, sizeof(format) );
format.dwSize = sizeof(format); format.dwSize = sizeof(format);
if (at_least_vista())
{
format.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME | DSBCAPS_TRUEPLAYPOSITION;
}
else
{
format.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME; format.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME;
}
/* Don't use DSBCAPS_STATIC. It's meant for static buffers, and we /* Don't use DSBCAPS_STATIC. It's meant for static buffers, and we
* only use streaming buffers. */ * only use streaming buffers. */
+19
View File
@@ -1,8 +1,27 @@
#ifndef DIRECTX_HELPERS_H #ifndef DIRECTX_HELPERS_H
#define DIRECTX_HELPERS_H #define DIRECTX_HELPERS_H
#include "windows.h"
RString hr_ssprintf( int hr, const char *fmt, ... ); RString hr_ssprintf( int hr, const char *fmt, ... );
//Keep XP on life support
static bool at_least_vista()
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 };
DWORDLONG const dwlConditionMask = VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
osvi.dwMajorVersion = 0x0600;
osvi.dwMinorVersion = 0x0;
osvi.wServicePackMajor = 0;
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != false;
}
#endif #endif
/* /*
+24 -3
View File
@@ -12,8 +12,7 @@
#include "archutils/Win32/WindowIcon.h" #include "archutils/Win32/WindowIcon.h"
#include "archutils/Win32/GetFileInformation.h" #include "archutils/Win32/GetFileInformation.h"
#include "CommandLineActions.h" #include "CommandLineActions.h"
#include <dwmapi.h> #include "DirectXHelpers.h"
#pragma comment(lib, "dwmapi.lib")
#include <set> #include <set>
@@ -417,6 +416,19 @@ void GraphicsWindow::Initialize( bool bD3D )
// A few things need to be handled differently for D3D. // A few things need to be handled differently for D3D.
g_bD3D = bD3D; g_bD3D = bD3D;
//keeping xp on life support -- check for vista+ for dwm
if (at_least_vista())
{
hInstanceDwmapi = LoadLibraryA("dwmapi.dll");
}
//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" );
}
AppInstance inst; AppInstance inst;
do do
{ {
@@ -499,7 +511,16 @@ void GraphicsWindow::Update()
if (g_CurrentParams.vsync) if (g_CurrentParams.vsync)
{ {
DwmFlush(); //if we can use DWM
if( hInstanceDwmapi != NULL )
{
BOOL compositeEnabled = true;
PFN_DwmIsCompositionEnabled(&compositeEnabled);
if (compositeEnabled)
{
PFN_DwmFlush();
}
}
} }
if( g_bResolutionChanged && DISPLAY != NULL ) if( g_bResolutionChanged && DISPLAY != NULL )
+5
View File
@@ -35,6 +35,11 @@ namespace GraphicsWindow
void Update(); void Update();
HWND GetHwnd(); HWND GetHwnd();
//dwm functions for vista+
static HINSTANCE hInstanceDwmapi = NULL;
static HRESULT(WINAPI* PFN_DwmIsCompositionEnabled)(BOOL*);
static HRESULT (WINAPI* PFN_DwmFlush)(VOID);
}; };
#endif #endif