2018-03-24 11:44:53 +00:00
|
|
|
|
|
|
|
#include "Common/Log.h"
|
|
|
|
#include "Core/Config.h"
|
2018-06-17 01:42:31 +00:00
|
|
|
#include "Core/ConfigValues.h"
|
2018-03-24 11:44:53 +00:00
|
|
|
#include "Core/System.h"
|
2020-10-04 21:24:14 +00:00
|
|
|
#include "Common/GPU/OpenGL/GLFeatures.h"
|
2018-03-24 11:44:53 +00:00
|
|
|
|
|
|
|
#include "libretro/LibretroGLContext.h"
|
|
|
|
|
2018-03-26 16:37:34 +00:00
|
|
|
bool LibretroGLContext::Init() {
|
2018-03-26 16:21:11 +00:00
|
|
|
if (!LibretroHWRenderContext::Init(true))
|
2018-03-24 11:44:53 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-26 16:37:34 +00:00
|
|
|
void LibretroGLContext::CreateDrawContext() {
|
2020-05-31 09:31:48 +00:00
|
|
|
|
|
|
|
#ifndef USING_GLES2
|
|
|
|
// Some core profile drivers elide certain extensions from GL_EXTENSIONS/etc.
|
|
|
|
// glewExperimental allows us to force GLEW to search for the pointers anyway.
|
|
|
|
if (gl_extensions.IsCoreContext)
|
|
|
|
glewExperimental = true;
|
|
|
|
if (GLEW_OK != glewInit()) {
|
|
|
|
printf("Failed to initialize glew!\n");
|
|
|
|
}
|
|
|
|
// Unfortunately, glew will generate an invalid enum error, ignore.
|
|
|
|
if (gl_extensions.IsCoreContext)
|
|
|
|
glGetError();
|
2018-03-24 11:44:53 +00:00
|
|
|
#endif
|
2020-05-31 09:31:48 +00:00
|
|
|
|
|
|
|
CheckGLExtensions();
|
|
|
|
draw_ = Draw::T3DCreateGLContext();
|
|
|
|
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
|
|
|
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
|
|
|
SetGPUBackend(GPUBackend::OPENGL);
|
|
|
|
draw_->CreatePresets();
|
2018-03-24 11:44:53 +00:00
|
|
|
}
|
2018-03-26 16:21:11 +00:00
|
|
|
|
2018-03-26 16:37:34 +00:00
|
|
|
void LibretroGLContext::DestroyDrawContext() {
|
2018-03-24 11:44:53 +00:00
|
|
|
LibretroHWRenderContext::DestroyDrawContext();
|
|
|
|
renderManager_ = nullptr;
|
|
|
|
}
|