Allow disabling composition in Win Vista/7Allow disabling composition in Win Vista/7.

This commit is contained in:
Themaister 2011-08-07 15:00:34 +02:00
parent 6a260a57dd
commit 7425e1f879
7 changed files with 52 additions and 0 deletions

View file

@ -126,6 +126,9 @@ static const unsigned fullscreen_y = 0;
// Force 16-bit colors.
static const bool force_16bit = false;
// Forcibly disable composition. Only valid on Windows Vista/7 for now.
static const bool disable_composition = false;
// Video VSYNC (recommended)
static const bool vsync = true;

View file

@ -89,6 +89,7 @@ struct settings
float msg_pos_y;
bool force_16bit;
bool disable_composition;
char external_driver[256];
} video;

View file

@ -60,4 +60,39 @@ bool gfx_window_title(char *buf, size_t size)
return ret;
}
#ifdef _WIN32
#include <windows.h>
#include "dynamic.h"
void gfx_set_composition(void)
{
if (!g_settings.video.disable_composition)
return;
static bool inited = false;
if (inited)
return;
inited = true;
dylib_t lib = dylib_load("dwmapi.dll");
if (!lib)
{
SSNES_ERR("Did not find dwmapi.dll");
return;
}
HRESULT (WINAPI *composition_enable)(UINT) = (HRESULT (WINAPI*)(UINT))dylib_proc(lib, "DwmEnableComposition");
if (!composition_enable)
{
SSNES_ERR("Did not find DwmEnableComposition ...\n");
dylib_close(lib);
return;
}
HRESULT ret = composition_enable(0);
if (FAILED(ret))
SSNES_ERR("Failed to set composition state ...\n");
dylib_close(lib);
}
#endif

View file

@ -24,4 +24,8 @@
bool gfx_window_title(char *buf, size_t size);
void gfx_window_title_reset(void);
#ifdef _WIN32
void gfx_set_composition(void);
#endif
#endif

View file

@ -1036,6 +1036,10 @@ static void gl_set_nonblock_state(void *data, bool state)
static void* gl_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{
#ifdef _WIN32
gfx_set_composition();
#endif
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return NULL;

View file

@ -118,6 +118,7 @@ static void set_defaults(void)
g_settings.video.fullscreen_x = fullscreen_x;
g_settings.video.fullscreen_y = fullscreen_y;
g_settings.video.force_16bit = force_16bit;
g_settings.video.disable_composition = disable_composition;
g_settings.video.vsync = vsync;
g_settings.video.smooth = video_smooth;
g_settings.video.force_aspect = force_aspect;
@ -299,6 +300,7 @@ static void parse_config_file(void)
}
CONFIG_GET_BOOL(video.force_16bit, "video_force_16bit");
CONFIG_GET_BOOL(video.disable_composition, "video_disable_composition");
CONFIG_GET_BOOL(video.vsync, "video_vsync");
CONFIG_GET_BOOL(video.smooth, "video_smooth");
CONFIG_GET_BOOL(video.force_aspect, "video_force_aspect");

View file

@ -25,6 +25,9 @@
# Force 16-bit colors. Apparently some video cards in use today have troubles with 32-bit ...
# video_force_16bit = false
# Forcibly disable composition. Only works in Windows Vista/7 for now.
# video_disable_composition = false
# Video vsync.
# video_vsync = true