OpenGLRenderer: remove opengl32 dependency on Linux
This commit is contained in:
parent
e6c2302927
commit
c7b0d103e1
|
|
@ -8,7 +8,6 @@
|
||||||
#define NAZARA_OPENGLRENDERER_HPP
|
#define NAZARA_OPENGLRENDERER_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/DynLib.hpp>
|
|
||||||
#include <Nazara/Renderer/RendererImpl.hpp>
|
#include <Nazara/Renderer/RendererImpl.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/Config.hpp>
|
#include <Nazara/OpenGLRenderer/Config.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
#define NAZARA_OPENGLRENDERER_EGLLOADER_HPP
|
#define NAZARA_OPENGLRENDERER_EGLLOADER_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/DynLib.hpp>
|
|
||||||
#include <Nazara/OpenGLRenderer/Config.hpp>
|
#include <Nazara/OpenGLRenderer/Config.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
|
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.hpp>
|
#include <Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.hpp>
|
||||||
|
|
@ -20,7 +19,7 @@ namespace Nz::GL
|
||||||
class NAZARA_OPENGLRENDERER_API EGLLoader : public Loader
|
class NAZARA_OPENGLRENDERER_API EGLLoader : public Loader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EGLLoader(DynLib& openglLib);
|
EGLLoader();
|
||||||
~EGLLoader() = default;
|
~EGLLoader() = default;
|
||||||
|
|
||||||
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Nz::GL
|
||||||
class NAZARA_OPENGLRENDERER_API WGLLoader : public Loader
|
class NAZARA_OPENGLRENDERER_API WGLLoader : public Loader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WGLLoader(DynLib& openglLib);
|
WGLLoader();
|
||||||
~WGLLoader() = default;
|
~WGLLoader() = default;
|
||||||
|
|
||||||
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Nz::GL
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynLib m_gdi32Lib;
|
DynLib m_gdi32Lib;
|
||||||
DynLib& m_opengl32Lib;
|
DynLib m_opengl32Lib;
|
||||||
WGLContext m_baseContext;
|
WGLContext m_baseContext;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,6 @@ namespace Nz
|
||||||
|
|
||||||
bool OpenGLRenderer::Prepare(const ParameterList& parameters)
|
bool OpenGLRenderer::Prepare(const ParameterList& parameters)
|
||||||
{
|
{
|
||||||
if (!m_opengl32Lib.Load("opengl32" NAZARA_DYNLIB_EXTENSION))
|
|
||||||
{
|
|
||||||
NazaraError("Failed to load opengl32 library, is OpenGL installed on your system?");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<GL::Loader> loader = SelectLoader();
|
std::unique_ptr<GL::Loader> loader = SelectLoader();
|
||||||
if (!loader)
|
if (!loader)
|
||||||
{
|
{
|
||||||
|
|
@ -73,7 +67,7 @@ namespace Nz
|
||||||
#if defined(NAZARA_PLATFORM_WINDOWS) || defined(NAZARA_PLATFORM_LINUX)
|
#if defined(NAZARA_PLATFORM_WINDOWS) || defined(NAZARA_PLATFORM_LINUX)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return std::make_unique<GL::EGLLoader>(m_opengl32Lib);
|
return std::make_unique<GL::EGLLoader>();
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
@ -84,7 +78,7 @@ namespace Nz
|
||||||
#ifdef NAZARA_PLATFORM_WINDOWS
|
#ifdef NAZARA_PLATFORM_WINDOWS
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return std::make_unique<GL::WGLLoader>(m_opengl32Lib);
|
return std::make_unique<GL::WGLLoader>();
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
namespace Nz::GL
|
namespace Nz::GL
|
||||||
{
|
{
|
||||||
EGLLoader::EGLLoader(DynLib& /*openglLib*/)
|
EGLLoader::EGLLoader()
|
||||||
{
|
{
|
||||||
if (!m_eglLib.Load("libEGL"))
|
if (!m_eglLib.Load("libEGL"))
|
||||||
throw std::runtime_error("failed to load gdi32.dll: " + m_eglLib.GetLastError());
|
throw std::runtime_error("failed to load gdi32.dll: " + m_eglLib.GetLastError());
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,12 @@
|
||||||
|
|
||||||
namespace Nz::GL
|
namespace Nz::GL
|
||||||
{
|
{
|
||||||
WGLLoader::WGLLoader(DynLib& openglLib) :
|
WGLLoader::WGLLoader() :
|
||||||
m_opengl32Lib(openglLib),
|
|
||||||
m_baseContext(nullptr, *this)
|
m_baseContext(nullptr, *this)
|
||||||
{
|
{
|
||||||
|
if (!m_opengl32Lib.Load("opengl32" NAZARA_DYNLIB_EXTENSION))
|
||||||
|
throw std::runtime_error("Failed to load opengl32 library, is OpenGL installed on your system?");
|
||||||
|
|
||||||
if (!m_gdi32Lib.Load("gdi32.dll"))
|
if (!m_gdi32Lib.Load("gdi32.dll"))
|
||||||
throw std::runtime_error("failed to load gdi32.dll: " + m_gdi32Lib.GetLastError());
|
throw std::runtime_error("failed to load gdi32.dll: " + m_gdi32Lib.GetLastError());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace Nz
|
||||||
};
|
};
|
||||||
|
|
||||||
RegisterImpl(NazaraRendererPrefix "NazaraOpenGLRenderer" NazaraRendererDebugSuffix, [] { return 50; });
|
RegisterImpl(NazaraRendererPrefix "NazaraOpenGLRenderer" NazaraRendererDebugSuffix, [] { return 50; });
|
||||||
RegisterImpl(NazaraRendererPrefix "NazaraVulkanRenderer" NazaraRendererDebugSuffix, [] { return 100; });
|
//RegisterImpl(NazaraRendererPrefix "NazaraVulkanRenderer" NazaraRendererDebugSuffix, [] { return 100; });
|
||||||
|
|
||||||
std::sort(implementations.begin(), implementations.end(), [](const auto& lhs, const auto& rhs) { return lhs.score > rhs.score; });
|
std::sort(implementations.begin(), implementations.end(), [](const auto& lhs, const auto& rhs) { return lhs.score > rhs.score; });
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue