OpenGLRenderer: remove opengl32 dependency on Linux

This commit is contained in:
Jérôme Leclercq 2020-09-01 19:28:10 +02:00
parent e6c2302927
commit c7b0d103e1
7 changed files with 11 additions and 17 deletions

View File

@ -8,7 +8,6 @@
#define NAZARA_OPENGLRENDERER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/DynLib.hpp>
#include <Nazara/Renderer/RendererImpl.hpp>
#include <Nazara/OpenGLRenderer/Config.hpp>
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>

View File

@ -8,7 +8,6 @@
#define NAZARA_OPENGLRENDERER_EGLLOADER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/DynLib.hpp>
#include <Nazara/OpenGLRenderer/Config.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.hpp>
@ -20,7 +19,7 @@ namespace Nz::GL
class NAZARA_OPENGLRENDERER_API EGLLoader : public Loader
{
public:
EGLLoader(DynLib& openglLib);
EGLLoader();
~EGLLoader() = default;
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;

View File

@ -22,7 +22,7 @@ namespace Nz::GL
class NAZARA_OPENGLRENDERER_API WGLLoader : public Loader
{
public:
WGLLoader(DynLib& openglLib);
WGLLoader();
~WGLLoader() = default;
std::unique_ptr<Context> CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override;
@ -43,7 +43,7 @@ namespace Nz::GL
private:
DynLib m_gdi32Lib;
DynLib& m_opengl32Lib;
DynLib m_opengl32Lib;
WGLContext m_baseContext;
};
}

View File

@ -48,12 +48,6 @@ namespace Nz
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();
if (!loader)
{
@ -73,7 +67,7 @@ namespace Nz
#if defined(NAZARA_PLATFORM_WINDOWS) || defined(NAZARA_PLATFORM_LINUX)
try
{
return std::make_unique<GL::EGLLoader>(m_opengl32Lib);
return std::make_unique<GL::EGLLoader>();
}
catch (const std::exception& e)
{
@ -84,7 +78,7 @@ namespace Nz
#ifdef NAZARA_PLATFORM_WINDOWS
try
{
return std::make_unique<GL::WGLLoader>(m_opengl32Lib);
return std::make_unique<GL::WGLLoader>();
}
catch (const std::exception& e)
{

View File

@ -19,7 +19,7 @@
namespace Nz::GL
{
EGLLoader::EGLLoader(DynLib& /*openglLib*/)
EGLLoader::EGLLoader()
{
if (!m_eglLib.Load("libEGL"))
throw std::runtime_error("failed to load gdi32.dll: " + m_eglLib.GetLastError());

View File

@ -9,10 +9,12 @@
namespace Nz::GL
{
WGLLoader::WGLLoader(DynLib& openglLib) :
m_opengl32Lib(openglLib),
WGLLoader::WGLLoader() :
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"))
throw std::runtime_error("failed to load gdi32.dll: " + m_gdi32Lib.GetLastError());

View File

@ -75,7 +75,7 @@ namespace Nz
};
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; });