mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 13:20:27 -06:00
GLContext: Remove global context pointer
This commit is contained in:
@ -66,7 +66,7 @@ std::string VideoBackend::GetName() const
|
||||
|
||||
std::string VideoBackend::GetDisplayName() const
|
||||
{
|
||||
if (g_main_gl_context && g_main_gl_context->GetMode() == GLContext::Mode::OpenGLES)
|
||||
if (g_renderer && static_cast<Renderer*>(g_renderer.get())->IsGLES())
|
||||
return _trans("OpenGL ES");
|
||||
else
|
||||
return _trans("OpenGL");
|
||||
@ -108,10 +108,10 @@ void VideoBackend::InitBackendInfo()
|
||||
g_Config.backend_info.AAModes = {1, 2, 4, 8};
|
||||
}
|
||||
|
||||
bool VideoBackend::InitializeGLExtensions()
|
||||
bool VideoBackend::InitializeGLExtensions(GLContext* context)
|
||||
{
|
||||
// Init extension support.
|
||||
if (!GLExtensions::Init())
|
||||
if (!GLExtensions::Init(context))
|
||||
{
|
||||
// OpenGL 2.0 is required for all shader based drawings. There is no way to get this by
|
||||
// extensions
|
||||
@ -161,15 +161,16 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
{
|
||||
InitializeShared();
|
||||
|
||||
g_main_gl_context = GLContext::Create(wsi, g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer);
|
||||
if (!g_main_gl_context)
|
||||
std::unique_ptr<GLContext> main_gl_context =
|
||||
GLContext::Create(wsi, g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer);
|
||||
if (!main_gl_context)
|
||||
return false;
|
||||
|
||||
g_main_gl_context->MakeCurrent();
|
||||
if (!InitializeGLExtensions() || !FillBackendInfo())
|
||||
main_gl_context->MakeCurrent();
|
||||
if (!InitializeGLExtensions(main_gl_context.get()) || !FillBackendInfo())
|
||||
return false;
|
||||
|
||||
g_renderer = std::make_unique<Renderer>();
|
||||
g_renderer = std::make_unique<Renderer>(std::move(main_gl_context));
|
||||
g_vertex_manager = std::make_unique<VertexManager>();
|
||||
g_perf_query = GetPerfQuery();
|
||||
ProgramShaderCache::Init();
|
||||
@ -195,9 +196,6 @@ void VideoBackend::Shutdown()
|
||||
g_perf_query.reset();
|
||||
g_vertex_manager.reset();
|
||||
g_renderer.reset();
|
||||
g_main_gl_context->ClearCurrent();
|
||||
g_main_gl_context->Shutdown();
|
||||
g_main_gl_context.reset();
|
||||
ShutdownShared();
|
||||
}
|
||||
} // namespace OGL
|
||||
|
Reference in New Issue
Block a user