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