OpenGLRenderer: Try to load OpenGL on desktop instead of OpenGL ES
This commit is contained in:
parent
b2aedd394c
commit
90c738023a
|
|
@ -28,8 +28,8 @@ namespace Nz
|
||||||
OpenGLDevice(OpenGLDevice&&) = delete; ///TODO?
|
OpenGLDevice(OpenGLDevice&&) = delete; ///TODO?
|
||||||
~OpenGLDevice();
|
~OpenGLDevice();
|
||||||
|
|
||||||
std::unique_ptr<GL::Context> CreateContext(const GL::ContextParams& params) const;
|
std::unique_ptr<GL::Context> CreateContext(GL::ContextParams params) const;
|
||||||
std::unique_ptr<GL::Context> CreateContext(const GL::ContextParams& params, WindowHandle handle) const;
|
std::unique_ptr<GL::Context> CreateContext(GL::ContextParams params, WindowHandle handle) const;
|
||||||
|
|
||||||
const RenderDeviceInfo& GetDeviceInfo() const override;
|
const RenderDeviceInfo& GetDeviceInfo() const override;
|
||||||
const RenderDeviceFeatures& GetEnabledFeatures() const override;
|
const RenderDeviceFeatures& GetEnabledFeatures() const override;
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@
|
||||||
|
|
||||||
// Try to identify target platform via defines
|
// Try to identify target platform via defines
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
#define NAZARA_PLATFORM_DESKTOP
|
||||||
#define NAZARA_PLATFORM_WINDOWS
|
#define NAZARA_PLATFORM_WINDOWS
|
||||||
|
|
||||||
#define NAZARA_EXPORT __declspec(dllexport)
|
#define NAZARA_EXPORT __declspec(dllexport)
|
||||||
|
|
@ -123,14 +124,16 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__linux__) || defined(__unix__)
|
#elif defined(__linux__) || defined(__unix__)
|
||||||
|
#define NAZARA_PLATFORM_DESKTOP
|
||||||
#define NAZARA_PLATFORM_LINUX
|
#define NAZARA_PLATFORM_LINUX
|
||||||
#define NAZARA_PLATFORM_POSIX
|
#define NAZARA_PLATFORM_POSIX
|
||||||
|
|
||||||
#define NAZARA_EXPORT __attribute__((visibility ("default")))
|
#define NAZARA_EXPORT __attribute__((visibility ("default")))
|
||||||
#define NAZARA_IMPORT __attribute__((visibility ("default")))
|
#define NAZARA_IMPORT __attribute__((visibility ("default")))
|
||||||
#elif defined(__APPLE__) && defined(__MACH__)
|
#elif defined(__APPLE__) && defined(__MACH__)
|
||||||
#define NAZARA_PLATFORM_MACOSX
|
#define NAZARA_PLATFORM_DESKTOP
|
||||||
#define NAZARA_PLATFORM_POSIX
|
#define NAZARA_PLATFORM_MACOSX
|
||||||
|
#define NAZARA_PLATFORM_POSIX
|
||||||
|
|
||||||
#define NAZARA_EXPORT __attribute__((visibility ("default")))
|
#define NAZARA_EXPORT __attribute__((visibility ("default")))
|
||||||
#define NAZARA_IMPORT __attribute__((visibility ("default")))
|
#define NAZARA_IMPORT __attribute__((visibility ("default")))
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
|
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
|
||||||
#include <Nazara/Renderer/CommandPool.hpp>
|
#include <Nazara/Renderer/CommandPool.hpp>
|
||||||
|
#include <array>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||||
|
|
||||||
|
|
@ -22,7 +23,25 @@ namespace Nz
|
||||||
OpenGLDevice::OpenGLDevice(GL::Loader& loader) :
|
OpenGLDevice::OpenGLDevice(GL::Loader& loader) :
|
||||||
m_loader(loader)
|
m_loader(loader)
|
||||||
{
|
{
|
||||||
m_referenceContext = loader.CreateContext(this, {});
|
// 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
|
||||||
|
};
|
||||||
|
|
||||||
|
for (GL::ContextType contextType : contextTypes)
|
||||||
|
{
|
||||||
|
GL::ContextParams params;
|
||||||
|
params.type = contextType;
|
||||||
|
|
||||||
|
m_referenceContext = loader.CreateContext(this, params);
|
||||||
|
if (m_referenceContext)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_referenceContext)
|
if (!m_referenceContext)
|
||||||
throw std::runtime_error("failed to create reference context");
|
throw std::runtime_error("failed to create reference context");
|
||||||
|
|
||||||
|
|
@ -75,16 +94,20 @@ namespace Nz
|
||||||
m_referenceContext.reset();
|
m_referenceContext.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<GL::Context> OpenGLDevice::CreateContext(const GL::ContextParams& params) const
|
std::unique_ptr<GL::Context> OpenGLDevice::CreateContext(GL::ContextParams params) const
|
||||||
{
|
{
|
||||||
|
params.type = m_referenceContext->GetParams().type;
|
||||||
|
|
||||||
auto contextPtr = m_loader.CreateContext(this, params, m_referenceContext.get());
|
auto contextPtr = m_loader.CreateContext(this, params, m_referenceContext.get());
|
||||||
m_contexts.insert(contextPtr.get());
|
m_contexts.insert(contextPtr.get());
|
||||||
|
|
||||||
return contextPtr;
|
return contextPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<GL::Context> OpenGLDevice::CreateContext(const GL::ContextParams& params, WindowHandle handle) const
|
std::unique_ptr<GL::Context> OpenGLDevice::CreateContext(GL::ContextParams params, WindowHandle handle) const
|
||||||
{
|
{
|
||||||
|
params.type = m_referenceContext->GetParams().type;
|
||||||
|
|
||||||
auto contextPtr = m_loader.CreateContext(this, params, handle, m_referenceContext.get());
|
auto contextPtr = m_loader.CreateContext(this, params, handle, m_referenceContext.get());
|
||||||
m_contexts.insert(contextPtr.get());
|
m_contexts.insert(contextPtr.get());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue