keep xp on life support a bit longer, check for vista+ stuff (#1456)
This commit is contained in:
@@ -210,7 +210,15 @@ RString DSoundBuf::Init( DSound &ds, DSoundBuf::hw hardware,
|
||||
DSBUFFERDESC format;
|
||||
memset( &format, 0, sizeof(format) );
|
||||
format.dwSize = sizeof(format);
|
||||
format.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME;
|
||||
|
||||
if (at_least_vista())
|
||||
{
|
||||
format.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME | DSBCAPS_TRUEPLAYPOSITION;
|
||||
}
|
||||
else
|
||||
{
|
||||
format.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME;
|
||||
}
|
||||
|
||||
/* Don't use DSBCAPS_STATIC. It's meant for static buffers, and we
|
||||
* only use streaming buffers. */
|
||||
|
||||
@@ -1,8 +1,27 @@
|
||||
#ifndef DIRECTX_HELPERS_H
|
||||
#define DIRECTX_HELPERS_H
|
||||
#include "windows.h"
|
||||
|
||||
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
|
||||
|
||||
/*
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
#include "archutils/Win32/WindowIcon.h"
|
||||
#include "archutils/Win32/GetFileInformation.h"
|
||||
#include "CommandLineActions.h"
|
||||
#include <dwmapi.h>
|
||||
#pragma comment(lib, "dwmapi.lib")
|
||||
#include "DirectXHelpers.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
@@ -417,6 +416,19 @@ void GraphicsWindow::Initialize( bool bD3D )
|
||||
// A few things need to be handled differently for D3D.
|
||||
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;
|
||||
do
|
||||
{
|
||||
@@ -498,8 +510,17 @@ void GraphicsWindow::Update()
|
||||
HOOKS->SetHasFocus( g_bHasFocus );
|
||||
|
||||
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 )
|
||||
|
||||
@@ -35,6 +35,11 @@ namespace GraphicsWindow
|
||||
void Update();
|
||||
|
||||
HWND GetHwnd();
|
||||
|
||||
//dwm functions for vista+
|
||||
static HINSTANCE hInstanceDwmapi = NULL;
|
||||
static HRESULT(WINAPI* PFN_DwmIsCompositionEnabled)(BOOL*);
|
||||
static HRESULT (WINAPI* PFN_DwmFlush)(VOID);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user