mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-08 02:25:56 +00:00
VideoBackends: Simplify initialization and deinitialization of resources
Approximately three or four times now, the issue of pointers being in an inconsistent state been an issue in the video backend renderers with regards to tripping up other developers. Global (ugh) resources are put into a unique_ptr and will always have a well-defined state of being - null or not null
This commit is contained in:
parent
1fbab188ad
commit
f295182833
25 changed files with 104 additions and 86 deletions
|
@ -2,6 +2,8 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Common/GL/GLInterfaceBase.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
|
@ -20,19 +22,19 @@
|
|||
#error Platform doesnt have a GLInterface
|
||||
#endif
|
||||
|
||||
cInterfaceBase* HostGL_CreateGLInterface()
|
||||
std::unique_ptr<cInterfaceBase> HostGL_CreateGLInterface()
|
||||
{
|
||||
#ifdef ANDROID
|
||||
return new cInterfaceEGLAndroid;
|
||||
return std::make_unique<cInterfaceEGLAndroid>();
|
||||
#elif defined(__APPLE__)
|
||||
return new cInterfaceAGL;
|
||||
return std::make_unique<cInterfaceAGL>();
|
||||
#elif defined(_WIN32)
|
||||
return new cInterfaceWGL;
|
||||
return std::make_unique<cInterfaceWGL>();
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
#if defined(USE_EGL) && USE_EGL
|
||||
return new cInterfaceEGLX11;
|
||||
return std::make_unique<cInterfaceEGLX11>();
|
||||
#else
|
||||
return new cInterfaceGLX;
|
||||
return std::make_unique<cInterfaceGLX>();
|
||||
#endif
|
||||
#else
|
||||
return nullptr;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
@ -42,8 +43,8 @@ public:
|
|||
virtual bool PeekMessages() { return false; }
|
||||
};
|
||||
|
||||
extern cInterfaceBase *GLInterface;
|
||||
extern std::unique_ptr<cInterfaceBase> GLInterface;
|
||||
|
||||
// This function has to be defined along the Host_ functions from Core/Host.h.
|
||||
// Current canonical implementation: DolphinWX/GLInterface/GLInterface.cpp.
|
||||
cInterfaceBase* HostGL_CreateGLInterface();
|
||||
std::unique_ptr<cInterfaceBase> HostGL_CreateGLInterface();
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/GL/GLInterfaceBase.h"
|
||||
#include "Common/GL/GLUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
|
||||
cInterfaceBase *GLInterface;
|
||||
std::unique_ptr<cInterfaceBase> GLInterface;
|
||||
static GLuint attributelessVAO = 0;
|
||||
static GLuint attributelessVBO = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue