2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
// TODO: ugly
|
|
|
|
#ifdef _WIN32
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/D3D/VideoBackend.h"
|
2011-01-31 01:28:32 +00:00
|
|
|
#endif
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/OGL/VideoBackend.h"
|
|
|
|
#include "VideoBackends/Software/VideoBackend.h"
|
2011-03-16 22:48:17 +00:00
|
|
|
|
2014-02-19 01:27:20 +00:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
|
|
|
|
2011-01-31 01:28:32 +00:00
|
|
|
std::vector<VideoBackend*> g_available_video_backends;
|
|
|
|
VideoBackend* g_video_backend = NULL;
|
2013-03-20 23:17:43 +00:00
|
|
|
static VideoBackend* s_default_backend = NULL;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2011-03-19 12:58:55 +00:00
|
|
|
#ifdef _WIN32
|
2013-08-11 14:30:19 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2011-03-19 12:58:55 +00:00
|
|
|
// http://msdn.microsoft.com/en-us/library/ms725491.aspx
|
2013-10-29 05:23:17 +00:00
|
|
|
static bool IsGteVista()
|
2011-03-19 12:58:55 +00:00
|
|
|
{
|
|
|
|
OSVERSIONINFOEX osvi;
|
|
|
|
DWORDLONG dwlConditionMask = 0;
|
|
|
|
|
|
|
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
|
|
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
|
|
|
osvi.dwMajorVersion = 6;
|
|
|
|
|
|
|
|
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
|
|
|
|
2012-12-23 18:37:50 +00:00
|
|
|
return VerifyVersionInfo(&osvi, VER_MAJORVERSION, dwlConditionMask) != FALSE;
|
2011-03-19 12:58:55 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-01-31 01:28:32 +00:00
|
|
|
void VideoBackend::PopulateList()
|
|
|
|
{
|
2013-03-20 23:17:43 +00:00
|
|
|
VideoBackend* backends[4] = { NULL };
|
|
|
|
|
2014-01-14 20:57:32 +00:00
|
|
|
// OGL > D3D11 > SW
|
|
|
|
#if !defined(USE_GLES) || USE_GLES3
|
|
|
|
g_available_video_backends.push_back(backends[0] = new OGL::VideoBackend);
|
|
|
|
#endif
|
2011-01-31 01:28:32 +00:00
|
|
|
#ifdef _WIN32
|
2011-03-19 12:58:55 +00:00
|
|
|
if (IsGteVista())
|
2014-01-14 20:57:32 +00:00
|
|
|
g_available_video_backends.push_back(backends[1] = new DX11::VideoBackend);
|
2012-12-17 20:54:20 +00:00
|
|
|
#endif
|
2013-03-20 23:17:43 +00:00
|
|
|
g_available_video_backends.push_back(backends[3] = new SW::VideoSoftware);
|
2011-02-08 14:51:53 +00:00
|
|
|
|
2014-02-12 15:00:34 +00:00
|
|
|
for (VideoBackend* backend : backends)
|
2013-03-20 23:17:43 +00:00
|
|
|
{
|
2013-10-29 05:09:01 +00:00
|
|
|
if (backend)
|
2013-03-20 23:17:43 +00:00
|
|
|
{
|
2013-10-29 05:09:01 +00:00
|
|
|
s_default_backend = g_video_backend = backend;
|
2013-03-20 23:17:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-31 01:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VideoBackend::ClearList()
|
|
|
|
{
|
|
|
|
while (!g_available_video_backends.empty())
|
|
|
|
{
|
|
|
|
delete g_available_video_backends.back();
|
|
|
|
g_available_video_backends.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VideoBackend::ActivateBackend(const std::string& name)
|
|
|
|
{
|
2013-03-20 23:17:43 +00:00
|
|
|
if (name.length() == 0) // If NULL, set it to the default backend (expected behavior)
|
|
|
|
g_video_backend = s_default_backend;
|
2012-09-25 00:47:37 +00:00
|
|
|
|
2014-02-12 15:00:34 +00:00
|
|
|
for (VideoBackend* backend : g_available_video_backends)
|
|
|
|
if (name == backend->GetName())
|
|
|
|
g_video_backend = backend;
|
2011-01-31 01:28:32 +00:00
|
|
|
}
|