Renderer: Split OpenGL and OpenGL ES in two RenderAPI enums

This commit is contained in:
SirLynix
2022-12-25 16:11:28 +01:00
parent fe69cc0d27
commit e4064997d8
9 changed files with 75 additions and 30 deletions

View File

@@ -52,7 +52,7 @@ namespace Nz::GL
EGLLoader& loader;
};
EGLLoader::EGLLoader() :
EGLLoader::EGLLoader(const Renderer::Config& config) :
m_defaultDisplay(nullptr)
{
if (!m_eglLib.Load("libEGL"))
@@ -80,14 +80,29 @@ namespace Nz::GL
// Try to create a dummy context in order to check OpenGL / OpenGL ES support
// Favor OpenGL on desktop and OpenGL ES on mobile
std::array<GL::ContextType, 2> contextTypes = {
std::array<GL::ContextType, 2> contextTypes;
RenderAPI preferredAPI = config.preferredAPI;
if (preferredAPI == RenderAPI::Unknown)
{
// Favor OpenGL on desktop and OpenGL ES on mobile
#if defined(NAZARA_PLATFORM_DESKTOP)
GL::ContextType::OpenGL, GL::ContextType::OpenGL_ES
preferredAPI = RenderAPI::OpenGL;
#else
GL::ContextType::OpenGL_ES, GL::ContextType::OpenGL
preferredAPI = RenderAPI::OpenGL_ES;
#endif
};
}
if (config.preferredAPI == RenderAPI::OpenGL_ES)
{
contextTypes[0] = GL::ContextType::OpenGL_ES;
contextTypes[1] = GL::ContextType::OpenGL;
}
else
{
contextTypes[0] = GL::ContextType::OpenGL;
contextTypes[1] = GL::ContextType::OpenGL_ES;
}
ContextParams params;

View File

@@ -9,7 +9,7 @@
namespace Nz::GL
{
WGLLoader::WGLLoader() :
WGLLoader::WGLLoader(const Renderer::Config& config) :
m_baseContext(nullptr, *this)
{
if (!m_opengl32Lib.Load("opengl32" NAZARA_DYNLIB_EXTENSION))
@@ -50,14 +50,29 @@ namespace Nz::GL
throw std::runtime_error("failed to create load context");
ContextParams params;
// Favor OpenGL on desktop and OpenGL ES on mobile
std::array<GL::ContextType, 2> contextTypes = {
std::array<GL::ContextType, 2> contextTypes;
RenderAPI preferredAPI = config.preferredAPI;
if (preferredAPI == RenderAPI::Unknown)
{
// Favor OpenGL on desktop and OpenGL ES on mobile
#if defined(NAZARA_PLATFORM_DESKTOP)
GL::ContextType::OpenGL, GL::ContextType::OpenGL_ES
preferredAPI = RenderAPI::OpenGL;
#else
GL::ContextType::OpenGL_ES, GL::ContextType::OpenGL
preferredAPI = RenderAPI::OpenGL_ES;
#endif
};
}
if (config.preferredAPI == RenderAPI::OpenGL_ES)
{
contextTypes[0] = GL::ContextType::OpenGL_ES;
contextTypes[1] = GL::ContextType::OpenGL;
}
else
{
contextTypes[0] = GL::ContextType::OpenGL;
contextTypes[1] = GL::ContextType::OpenGL_ES;
}
bool created = false;
for (GL::ContextType contextType : contextTypes)