OpenGLRenderer: Choose between OpenGL/OpenGL ES at loading

This commit is contained in:
Jérôme Leclercq
2021-11-02 09:13:12 +01:00
parent d872428658
commit 9946c17a23
7 changed files with 79 additions and 28 deletions

View File

@@ -23,25 +23,11 @@ namespace Nz
OpenGLDevice::OpenGLDevice(GL::Loader& loader) :
m_loader(loader)
{
// Favor OpenGL on desktop and OpenGL ES on mobile
std::array<GL::ContextType, 2> contextTypes = {
#if defined(NAZARA_PLATFORM_DESKTOP)
GL::ContextType::OpenGL, GL::ContextType::OpenGL_ES
#else
GL::ContextType::OpenGL_ES, GL::ContextType::OpenGL
#endif
};
GL::ContextParams params;
params.type = loader.GetPreferredContextType();
for (GL::ContextType contextType : contextTypes)
{
GL::ContextParams params;
params.type = contextType;
m_referenceContext = loader.CreateContext(this, params);
if (m_referenceContext)
break;
}
m_referenceContext = loader.CreateContext(this, params);
if (!m_referenceContext)
throw std::runtime_error("failed to create reference context");