diff --git a/build/scripts/tools/openglrenderer.lua b/build/scripts/tools/openglrenderer.lua index fde7dcba1..48219fe80 100644 --- a/build/scripts/tools/openglrenderer.lua +++ b/build/scripts/tools/openglrenderer.lua @@ -33,8 +33,22 @@ TOOL.Libraries = { } TOOL.OsFiles.Windows = { + "../include/Nazara/OpenGLRenderer/Wrapper/Win32/**.hpp", + "../include/Nazara/OpenGLRenderer/Wrapper/Win32/**.inl", "../include/Nazara/OpenGLRenderer/Wrapper/WGL/**.hpp", "../include/Nazara/OpenGLRenderer/Wrapper/WGL/**.inl", + "../src/Nazara/OpenGLRenderer/Wrapper/Win32/**.hpp", + "../src/Nazara/OpenGLRenderer/Wrapper/Win32/**.inl", + "../src/Nazara/OpenGLRenderer/Wrapper/Win32/**.cpp", "../src/Nazara/OpenGLRenderer/Wrapper/WGL/**.hpp", + "../src/Nazara/OpenGLRenderer/Wrapper/WGL/**.inl", "../src/Nazara/OpenGLRenderer/Wrapper/WGL/**.cpp" } + +TOOL.OsFiles.Linux = { + "../include/Nazara/OpenGLRenderer/Wrapper/Linux/**.hpp", + "../include/Nazara/OpenGLRenderer/Wrapper/Linux/**.inl", + "../src/Nazara/OpenGLRenderer/Wrapper/Linux/**.hpp", + "../src/Nazara/OpenGLRenderer/Wrapper/Linux/**.inl", + "../src/Nazara/OpenGLRenderer/Wrapper/Linux/**.cpp" +} diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp index 4fb4b13ed..9580c8b04 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp @@ -36,6 +36,8 @@ namespace Nz bool Prepare(const ParameterList& parameters) override; private: + std::unique_ptr SelectLoader(); + DynLib m_opengl32Lib; std::shared_ptr m_device; std::unique_ptr m_loader; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index 1c648054e..16e0a8265 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -90,7 +91,7 @@ namespace Nz::GL class Loader; - class Context + class NAZARA_OPENGLRENDERER_API Context { public: inline Context(const OpenGLDevice* device); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.hpp b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.hpp new file mode 100644 index 000000000..308ad3f27 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.hpp @@ -0,0 +1,79 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_EGLCONTEXT_HPP +#define NAZARA_OPENGLRENDERER_EGLCONTEXT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz::GL +{ + class EGLLoader; + + // This class isn't called EGLContext to prevent a conflict with EGLContext from EGL + class NAZARA_OPENGLRENDERER_API EGLContextBase : public Context + { + public: + inline EGLContextBase(const OpenGLDevice* device, const EGLLoader& loader); + EGLContextBase(const EGLContextBase&) = delete; + EGLContextBase(EGLContextBase&&) = delete; + ~EGLContextBase(); + + virtual bool Create(const ContextParams& params, const EGLContextBase* shareContext = nullptr); + virtual bool Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext = nullptr); + virtual void Destroy(); + + void EnableVerticalSync(bool enabled) override; + + inline bool HasPlatformExtension(const std::string& str) const; + + void SwapBuffers() override; + + EGLContextBase& operator=(const EGLContextBase&) = delete; + EGLContextBase& operator=(EGLContextBase&&) = delete; + + protected: + bool BindAPI(); + bool ChooseConfig(EGLConfig* configs, std::size_t maxConfigCount, std::size_t* configCount); + bool CreateInternal(EGLConfig config, const EGLContextBase* shareContext = nullptr); + bool InitDisplay(); + + const EGLLoader& m_loader; + EGLDisplay m_display; + EGLSurface m_surface; + + private: + bool ImplementFallback(const std::string_view& function) override; + + bool Activate() const override; + void Desactivate() const override; + const Loader& GetLoader() override; + bool LoadEGLExt(); + + struct Fallback + { + using glClearDepthProc = void(*)(double depth); + + glClearDepthProc glClearDepth; + }; + Fallback fallbacks; //< m_ omitted + + std::unordered_set m_supportedPlatformExtensions; + EGLContext m_handle; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.inl b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.inl new file mode 100644 index 000000000..2910f3ff9 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.inl @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::GL +{ + inline EGLContextBase::EGLContextBase(const OpenGLDevice* device, const EGLLoader& loader) : + Context(device), + m_loader(loader), + m_display(EGL_NO_DISPLAY), + m_surface(EGL_NO_SURFACE), + m_handle(EGL_NO_CONTEXT) + { + } + + inline bool EGLContextBase::HasPlatformExtension(const std::string& str) const + { + return m_supportedPlatformExtensions.find(str) != m_supportedPlatformExtensions.end(); + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLFunctions.hpp new file mode 100644 index 000000000..0359c031f --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLFunctions.hpp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_EGLFUNCTIONS_HPP +#define NAZARA_OPENGLRENDERER_EGLFUNCTIONS_HPP + +#include +#include +#include + +#define NAZARA_OPENGLRENDERER_FOREACH_EGL_FUNC(func, extBegin, extEnd, extFunc) \ + func(eglBindAPI, PFNEGLBINDAPIPROC) \ + func(eglChooseConfig, PFNEGLCHOOSECONFIGPROC) \ + func(eglCreateContext, PFNEGLCREATECONTEXTPROC) \ + func(eglCreatePbufferSurface, PFNEGLCREATEPBUFFERSURFACEPROC) \ + func(eglCreateWindowSurface, PFNEGLCREATEWINDOWSURFACEPROC) \ + func(eglDestroyContext, PFNEGLDESTROYCONTEXTPROC) \ + func(eglDestroySurface, PFNEGLDESTROYSURFACEPROC) \ + func(eglGetDisplay, PFNEGLGETDISPLAYPROC) \ + func(eglGetError, PFNEGLGETERRORPROC) \ + func(eglGetProcAddress, PFNEGLGETPROCADDRESSPROC) \ + func(eglInitialize, PFNEGLINITIALIZEPROC) \ + func(eglMakeCurrent, PFNEGLMAKECURRENTPROC) \ + func(eglQueryString, PFNEGLQUERYSTRINGPROC) \ + func(eglSwapBuffers, PFNEGLSWAPBUFFERSPROC) \ + func(eglTerminate, PFNEGLTERMINATEPROC) + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.hpp new file mode 100644 index 000000000..45fece72b --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.hpp @@ -0,0 +1,50 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_EGLLOADER_HPP +#define NAZARA_OPENGLRENDERER_EGLLOADER_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz::GL +{ + class NAZARA_OPENGLRENDERER_API EGLLoader : public Loader + { + public: + EGLLoader(DynLib& openglLib); + ~EGLLoader() = default; + + std::unique_ptr CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override; + std::unique_ptr CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const override; + + GLFunction LoadFunction(const char* name) const override; + +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; +#define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext) +#define NAZARA_OPENGLRENDERER_EXT_END() +#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) + NAZARA_OPENGLRENDERER_FOREACH_EGL_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_BEGIN, NAZARA_OPENGLRENDERER_EXT_END, NAZARA_OPENGLRENDERER_EXT_FUNC) +#undef NAZARA_OPENGLRENDERER_EXT_BEGIN +#undef NAZARA_OPENGLRENDERER_EXT_END +#undef NAZARA_OPENGLRENDERER_EXT_FUNC +#undef NAZARA_OPENGLRENDERER_FUNC + + static const char* TranslateError(EGLint errorId); + + private: + DynLib m_eglLib; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.inl b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.inl new file mode 100644 index 000000000..bcad238e8 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::Vk +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.hpp new file mode 100644 index 000000000..7134edcc3 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_EGLCONTEXTWAYLAND_HPP +#define NAZARA_OPENGLRENDERER_EGLCONTEXTWAYLAND_HPP + +#include +#include + +namespace Nz::GL +{ + class EGLContextWayland final : public EGLContextBase + { + public: + using EGLContextBase::EGLContextBase; + EGLContextWayland(const EGLContextWayland&) = default; + EGLContextWayland(EGLContextWayland&&) = default; + ~EGLContextWayland() = default; + + bool Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext = nullptr) override; + void Destroy() override; + + EGLContextWayland& operator=(const EGLContextWayland&) = default; + EGLContextWayland& operator=(EGLContextWayland&&) = default; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.inl b/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.inl new file mode 100644 index 000000000..1e0f1bac7 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::GL +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.hpp new file mode 100644 index 000000000..0dcbae724 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_EGLCONTEXTWIN32_HPP +#define NAZARA_OPENGLRENDERER_EGLCONTEXTWIN32_HPP + +#include +#include + +namespace Nz::GL +{ + class EGLContextX11 final : public EGLContextBase + { + public: + using EGLContextBase::EGLContextBase; + EGLContextX11(const EGLContextX11&) = default; + EGLContextX11(EGLContextX11&&) = default; + ~EGLContextX11() = default; + + bool Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext = nullptr) override; + void Destroy() override; + + EGLContextX11& operator=(const EGLContextX11&) = default; + EGLContextX11& operator=(EGLContextX11&&) = default; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.inl b/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.inl new file mode 100644 index 000000000..4ff2e4a7f --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::GL +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.hpp b/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.hpp index e974ddc39..9d610f1d6 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.hpp @@ -10,20 +10,19 @@ #include #include #include +#include #include -#include +#include +#include #include #include #include -#undef WIN32_LEAN_AND_MEAN //< Redefined by OpenGL header (ty Khronos) -#include - namespace Nz::GL { class WGLLoader; - class WGLContext : public Context + class NAZARA_OPENGLRENDERER_API WGLContext : public Context { public: inline WGLContext(const OpenGLDevice* device, const WGLLoader& loader); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLFunctions.hpp index 655373ed8..5a72c9322 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLFunctions.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLFunctions.hpp @@ -7,6 +7,8 @@ #ifndef NAZARA_OPENGLRENDERER_WGLFUNCTIONS_HPP #define NAZARA_OPENGLRENDERER_WGLFUNCTIONS_HPP +#undef WIN32_LEAN_AND_MEAN //< Redefined by wgl.h header (ty Khronos) + #include #include #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLLoader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLLoader.hpp index e9130544a..d3481ea00 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLLoader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/WGL/WGLLoader.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -18,7 +19,7 @@ namespace Nz::GL { - class WGLLoader : public Loader + class NAZARA_OPENGLRENDERER_API WGLLoader : public Loader { public: WGLLoader(DynLib& openglLib); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp new file mode 100644 index 000000000..adf384054 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_EGLCONTEXTWIN32_HPP +#define NAZARA_OPENGLRENDERER_EGLCONTEXTWIN32_HPP + +#include +#include +#include + +namespace Nz::GL +{ + class EGLContextWin32 final : public EGLContextBase + { + public: + using EGLContextBase::EGLContextBase; + EGLContextWin32(const EGLContextWin32&) = default; + EGLContextWin32(EGLContextWin32&&) = default; + ~EGLContextWin32() = default; + + bool Create(const ContextParams& params, const EGLContextBase* shareContext = nullptr); + bool Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext = nullptr) override; + void Destroy() override; + + EGLContextWin32& operator=(const EGLContextWin32&) = default; + EGLContextWin32& operator=(EGLContextWin32&&) = default; + + private: + HWNDHandle m_ownedWindow; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.inl b/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.inl new file mode 100644 index 000000000..59f2625a5 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::GL +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/Gdi32Functions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/Gdi32Functions.hpp new file mode 100644 index 000000000..5a72c9322 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/Gdi32Functions.hpp @@ -0,0 +1,54 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_WGLFUNCTIONS_HPP +#define NAZARA_OPENGLRENDERER_WGLFUNCTIONS_HPP + +#undef WIN32_LEAN_AND_MEAN //< Redefined by wgl.h header (ty Khronos) + +#include +#include +#include + +#define NAZARA_OPENGLRENDERER_FOREACH_WGL_FUNC(func, extBegin, extEnd, extFunc) \ + func(wglCreateContext, PFNWGLCREATECONTEXTPROC) \ + func(wglDeleteContext, PFNWGLDELETECONTEXTPROC) \ + func(wglGetCurrentContext, PFNWGLGETCURRENTCONTEXTPROC) \ + func(wglGetProcAddress, PFNWGLGETPROCADDRESSPROC) \ + func(wglMakeCurrent, PFNWGLMAKECURRENTPROC) \ + func(wglShareLists, PFNWGLSHARELISTSPROC) \ + \ + extBegin(WGL_ARB_create_context) \ + extFunc(wglCreateContextAttribsARB, PFNWGLCREATECONTEXTATTRIBSARBPROC) \ + extEnd() \ + \ + extBegin(WGL_ARB_pixel_format) \ + extFunc(wglChoosePixelFormatARB, PFNWGLCHOOSEPIXELFORMATARBPROC) \ + extEnd() \ + \ + extBegin(WGL_EXT_pixel_format) \ + extFunc(wglChoosePixelFormatEXT, PFNWGLCHOOSEPIXELFORMATEXTPROC) \ + extEnd() \ + \ + extBegin(WGL_ARB_extensions_string) \ + extFunc(wglGetExtensionsStringARB, PFNWGLGETEXTENSIONSSTRINGARBPROC) \ + extEnd() \ + \ + extBegin(WGL_EXT_extensions_string) \ + extFunc(wglGetExtensionsStringEXT, PFNWGLGETEXTENSIONSSTRINGEXTPROC) \ + extEnd() \ + \ + extBegin(WGL_EXT_swap_control) \ + extFunc(wglSwapIntervalEXT, PFNWGLSWAPINTERVALEXTPROC) \ + extEnd() + +#define NAZARA_OPENGLRENDERER_FOREACH_GDI32_FUNC(func) \ + func(ChoosePixelFormat, PFNCHOOSEPIXELFORMATPROC) \ + func(DescribePixelFormat, PFNDESCRIBEPIXELFORMATPROC) \ + func(SetPixelFormat, PFNSETPIXELFORMATPROC) \ + func(SwapBuffers, PFNSWAPBUFFERSPROC) \ + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/WGL/Win32Helper.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp similarity index 93% rename from include/Nazara/OpenGLRenderer/Wrapper/WGL/Win32Helper.hpp rename to include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp index 2bfe28d06..a355fd353 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/WGL/Win32Helper.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp @@ -8,6 +8,8 @@ #define NAZARA_OPENGLRENDERER_WIN32HELPER_HPP #include +#include +#include #include namespace Nz::GL diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp index 67ae261e0..4e743d11e 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp @@ -12,6 +12,10 @@ #include #include +#if defined(NAZARA_PLATFORM_WINDOWS) || defined(NAZARA_PLATFORM_LINUX) +#include +#endif + #ifdef NAZARA_PLATFORM_WINDOWS #include #endif @@ -50,19 +54,7 @@ namespace Nz return false; } - std::unique_ptr loader; - -#ifdef NAZARA_PLATFORM_WINDOWS - try - { - loader = std::make_unique(m_opengl32Lib); - } - catch (const std::exception& e) - { - NazaraWarning(std::string("Failed to load WGL: ") + e.what()); - } -#endif - + std::unique_ptr loader = SelectLoader(); if (!loader) { NazaraError("Failed to initialize OpenGL loader"); @@ -76,6 +68,33 @@ namespace Nz return true; } + std::unique_ptr OpenGLRenderer::SelectLoader() + { +#if defined(NAZARA_PLATFORM_WINDOWS) || defined(NAZARA_PLATFORM_LINUX) + try + { + return std::make_unique(m_opengl32Lib); + } + catch (const std::exception& e) + { + NazaraWarning(std::string("Failed to load EGL: ") + e.what()); + } +#endif + +#ifdef NAZARA_PLATFORM_WINDOWS + try + { + return std::make_unique(m_opengl32Lib); + } + catch (const std::exception& e) + { + NazaraWarning(std::string("Failed to load WGL: ") + e.what()); + } +#endif + + return {}; + } + RenderAPI OpenGLRenderer::QueryAPI() const { return RenderAPI::OpenGL; diff --git a/src/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.cpp b/src/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.cpp new file mode 100644 index 000000000..dcc1f8a51 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.cpp @@ -0,0 +1,340 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz::GL +{ + EGLContextBase::~EGLContextBase() + { + Destroy(); + } + + bool EGLContextBase::Create(const ContextParams& params, const EGLContextBase* shareContext) + { + Destroy(); //< In case a previous display or surface hasn't been released + + m_params = params; + + if (!BindAPI()) + return false; + + m_display = m_loader.eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (!m_display) + { + NazaraError("failed to retrieve default EGL display"); + return false; + } + + if (!InitDisplay()) + return false; + + std::size_t configCount; + std::array configs; + if (!ChooseConfig(configs.data(), configs.size(), &configCount)) + return false; + + EGLint surfaceAttributes[] = { + EGL_WIDTH, 1, + EGL_HEIGHT, 1, + EGL_NONE + }; + + std::size_t configIndex = 0; + for (; configIndex < configCount; ++configIndex) + { + m_surface = m_loader.eglCreatePbufferSurface(m_display, configs[configIndex], surfaceAttributes); + if (m_surface) + break; + } + + return CreateInternal(configs[configIndex], shareContext); + } + + bool EGLContextBase::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext) + { + NazaraError("Unexpected context creation call"); + return false; + } + + void EGLContextBase::Destroy() + { + if (m_handle) + { + assert(m_display); + + OnContextRelease(); + NotifyContextDestruction(this); + + m_loader.eglDestroyContext(m_display, m_handle); + m_handle = nullptr; + } + + if (m_surface) + { + assert(m_display); + m_loader.eglDestroySurface(m_display, m_surface); + m_surface = nullptr; + } + + if (m_display) + m_loader.eglTerminate(m_display); + } + + void EGLContextBase::EnableVerticalSync(bool enabled) + { + // TODO + } + + void EGLContextBase::SwapBuffers() + { + m_loader.eglSwapBuffers(m_display, m_surface); + // TODO + } + + bool EGLContextBase::BindAPI() + { + if (m_params.type == ContextType::OpenGL_ES) + { + if (m_loader.eglBindAPI(EGL_OPENGL_ES_API) == EGL_TRUE) + return true; + + if (m_loader.eglBindAPI(EGL_OPENGL_API) == EGL_TRUE) + { + m_params.type = ContextType::OpenGL; + return true; + } + + NazaraError("neither OpenGL nor OpenGL ES are supported"); + return false; + } + else + { + if (m_loader.eglBindAPI(EGL_OPENGL_API) != EGL_TRUE) + { + NazaraError("OpenGL is not supported"); + return false; + } + + return true; + } + } + + bool EGLContextBase::ChooseConfig(EGLConfig* configs, std::size_t maxConfigCount, std::size_t* configCount) + { + EGLint configAttributes[] = + { + EGL_BUFFER_SIZE, EGLint(m_params.bitsPerPixel), + EGL_DEPTH_SIZE, m_params.depthBits, + EGL_RENDERABLE_TYPE, (m_params.type == ContextType::OpenGL_ES) ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_BIT, + EGL_SAMPLE_BUFFERS, EGLint((m_params.sampleCount > 1) ? 1 : 0), + EGL_SAMPLES, EGLint((m_params.sampleCount > 1) ? m_params.sampleCount : 0), + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT, + EGL_STENCIL_SIZE, EGLint(m_params.stencilBits), + EGL_NONE + }; + + EGLint numConfig = 0; + if (m_loader.eglChooseConfig(m_display, configAttributes, configs, maxConfigCount, &numConfig) != GL_TRUE) + { + NazaraError(std::string("failed to retrieve compatible EGL configurations: ") + EGLLoader::TranslateError(m_loader.eglGetError())); + return false; + } + + if (numConfig == 0) + { + NazaraError("no supported configuration matches required attributes"); + return false; + } + + *configCount = numConfig; + + return true; + } + + bool EGLContextBase::CreateInternal(EGLConfig config, const EGLContextBase* shareContext) + { + struct Version + { + unsigned int major; + unsigned int minor; + }; + + if (m_params.type == ContextType::OpenGL_ES) + { + // Create OpenGL ES context + std::array supportedGL_ESVersions = { + { + { 3, 2 }, + { 3, 1 }, + { 3, 0 } + } + }; + + for (const Version& version : supportedGL_ESVersions) + { + if (m_params.glMajorVersion != 0) + { + if (version.major > m_params.glMajorVersion) + continue; + + if (m_params.glMinorVersion != 0 && version.minor > m_params.glMinorVersion) + continue; + } + + std::array attributes = { + EGL_CONTEXT_MAJOR_VERSION, int(version.major), + EGL_CONTEXT_MINOR_VERSION, int(version.minor), + + EGL_NONE + }; + + m_handle = m_loader.eglCreateContext(m_display, config, (shareContext) ? shareContext->m_handle : nullptr, attributes.data()); + if (m_handle) + break; + } + } + else + { + // Create OpenGL ES context + std::array supportedGLVersions = { + { + { 4, 6 }, + { 4, 5 }, + { 4, 4 }, + { 4, 3 }, + { 4, 2 }, + { 4, 1 }, + { 4, 0 }, + { 3, 3 } + } + }; + + for (const Version& version : supportedGLVersions) + { + if (m_params.glMajorVersion != 0) + { + if (version.major > m_params.glMajorVersion) + continue; + + if (m_params.glMinorVersion != 0 && version.minor > m_params.glMinorVersion) + continue; + } + + std::array attributes = { + EGL_CONTEXT_MAJOR_VERSION, int(version.major), + EGL_CONTEXT_MINOR_VERSION, int(version.minor), + + EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, + + EGL_NONE + }; + + m_handle = m_loader.eglCreateContext(m_display, config, (shareContext) ? shareContext->m_handle : nullptr, attributes.data()); + if (m_handle) + break; + } + } + + if (!m_handle) + { + NazaraError(std::string("failed to create EGL context: ") + EGLLoader::TranslateError(m_loader.eglGetError())); + return false; + } + + LoadEGLExt(); + + return true; + } + + bool EGLContextBase::InitDisplay() + { + EGLint major, minor; + if (m_loader.eglInitialize(m_display, &major, &minor) != EGL_TRUE) + { + NazaraError("failed to retrieve default EGL display"); + return false; + } + + const char* vendor = m_loader.eglQueryString(m_display, EGL_VENDOR); + NazaraNotice("Initialized EGL " + std::to_string(major) + "." + std::to_string(minor) + " display (" + vendor + ")"); + + return true; + } + + bool EGLContextBase::ImplementFallback(const std::string_view& function) + { + if (Context::ImplementFallback(function)) + return true; + + if (m_params.type == ContextType::OpenGL_ES) + return false; //< Implement fallback only for OpenGL (when emulating OpenGL ES) + + if (function == "glClearDepthf") + { + fallbacks.glClearDepth = reinterpret_cast(m_loader.LoadFunction("glClearDepth")); + if (!fallbacks.glClearDepth) + return false; + + glClearDepthf = [](GLfloat depth) + { + const EGLContextBase* context = static_cast(GetCurrentContext()); + assert(context); + context->fallbacks.glClearDepth(depth); + }; + } + + return true; + } + + bool EGLContextBase::Activate() const + { + EGLBoolean succeeded = m_loader.eglMakeCurrent(m_display, m_surface, m_surface, m_handle); + if (succeeded != EGL_TRUE) + { + NazaraError("failed to activate context"); + return false; + } + + return true; + } + + void EGLContextBase::Desactivate() const + { + assert(GetCurrentContext() == this); + EGLBoolean succeeded = m_loader.eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + if (succeeded != EGL_TRUE) + NazaraError("failed to desactivate context"); + } + + const Loader& EGLContextBase::GetLoader() + { + return m_loader; + } + + bool EGLContextBase::LoadEGLExt() + { + if (!Activate()) + return false; + + const char* extensionString = m_loader.eglQueryString(m_display, EGL_EXTENSIONS); + if (extensionString) + { + SplitString(extensionString, " ", [&](std::string_view extension) + { + m_supportedPlatformExtensions.emplace(extension); + return true; + }); + } + + return true; + } +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.cpp b/src/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.cpp new file mode 100644 index 000000000..96627433f --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/EGL/EGLLoader.cpp @@ -0,0 +1,158 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +#ifdef NAZARA_PLATFORM_LINUX +#include +#include +#endif + +#ifdef NAZARA_PLATFORM_WINDOWS +#include +#endif + +#include + +namespace Nz::GL +{ + EGLLoader::EGLLoader(DynLib& /*openglLib*/) + { + if (!m_eglLib.Load("libEGL")) + throw std::runtime_error("failed to load gdi32.dll: " + m_eglLib.GetLastError()); + + auto LoadSymbol = [](DynLib& lib, auto& func, const char* funcName) + { + func = reinterpret_cast>(lib.GetSymbol(funcName)); + if (!func) + throw std::runtime_error("failed to load core function " + std::string(funcName)); + }; + + // Load gdi32 functions +#define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext) +#define NAZARA_OPENGLRENDERER_EXT_END() +#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) //< Ignore extensions + + // Load base WGL functions +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) LoadSymbol(m_eglLib, name, #name); + NAZARA_OPENGLRENDERER_FOREACH_EGL_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_BEGIN, NAZARA_OPENGLRENDERER_EXT_END, NAZARA_OPENGLRENDERER_EXT_FUNC) +#undef NAZARA_OPENGLRENDERER_FUNC + +#undef NAZARA_OPENGLRENDERER_EXT_BEGIN +#undef NAZARA_OPENGLRENDERER_EXT_END +#undef NAZARA_OPENGLRENDERER_EXT_FUNC + + // Try to create a dummy context in order to check EGL support (FIXME: is this really necessary?) + ContextParams params; + EGLContextBase baseContext(nullptr, *this); + if (!baseContext.Create(params)) + throw std::runtime_error("failed to create load context"); + + if (!baseContext.Initialize(params)) + throw std::runtime_error("failed to load OpenGL functions"); + } + + std::unique_ptr EGLLoader::CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const + { + std::unique_ptr context; +#ifdef NAZARA_PLATFORM_WINDOWS + // On Windows context sharing seems to work only with window contexts + context = std::make_unique(device, *this); +#else + context = std::make_unique(device, *this); +#endif + + if (!context->Create(params, static_cast(shareContext))) + { + NazaraError("failed to create context"); + return {}; + } + + if (!context->Initialize(params)) + { + NazaraError("failed to initialize context"); + return {}; + } + + return context; + } + + std::unique_ptr EGLLoader::CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const + { + std::unique_ptr context; + switch (handle.type) + { + case WindowManager::Invalid: + break; + + case WindowManager::X11: +#ifdef NAZARA_PLATFORM_LINUX + context = std::make_unique(device, *this); +#endif + break; + + case WindowManager::Windows: +#ifdef NAZARA_PLATFORM_WINDOWS + context = std::make_unique(device, *this); +#endif + break; + + case WindowManager::Wayland: +#ifdef NAZARA_PLATFORM_LINUX + context = std::make_unique(device, *this); +#endif + break; + } + + if (!context) + { + NazaraError("unsupported window type"); + return {}; + } + + if (!context->Create(params, handle, /*static_cast(shareContext)*/nullptr)) + { + NazaraError("failed to create context"); + return {}; + } + + if (!context->Initialize(params)) + { + NazaraError("failed to initialize context"); + return {}; + } + + return context; + } + + GLFunction EGLLoader::LoadFunction(const char* name) const + { + return eglGetProcAddress(name); + } + + const char* EGLLoader::TranslateError(EGLint errorId) + { + switch (errorId) + { + case EGL_SUCCESS: return "The last function succeeded without error."; + case EGL_NOT_INITIALIZED: return "EGL is not initialized, or could not be initialized, for the specified EGL display connection."; + case EGL_BAD_ACCESS: return "EGL cannot access a requested resource."; + case EGL_BAD_ALLOC: return "EGL failed to allocate resources for the requested operation."; + case EGL_BAD_ATTRIBUTE: return "An unrecognized attribute or attribute value was passed in the attribute list."; + case EGL_BAD_CONTEXT: return "An EGLContext argument does not name a valid EGL rendering context."; + case EGL_BAD_CONFIG: return "An EGLConfig argument does not name a valid EGL frame buffer configuration."; + case EGL_BAD_CURRENT_SURFACE: return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid."; + case EGL_BAD_DISPLAY: return "An EGLDisplay argument does not name a valid EGL display connection."; + case EGL_BAD_SURFACE: return "An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering."; + case EGL_BAD_MATCH: return "Arguments are inconsistent."; + case EGL_BAD_PARAMETER: return "One or more argument values are invalid."; + case EGL_BAD_NATIVE_PIXMAP: return "A NativePixmapType argument does not refer to a valid native pixmap."; + case EGL_BAD_NATIVE_WINDOW: return "A NativeWindowType argument does not refer to a valid native window."; + case EGL_CONTEXT_LOST: return "A power management event has occurred."; + default: return "Invalid or unknown error."; + } + } +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.cpp new file mode 100644 index 000000000..519792c7b --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextWayland.cpp @@ -0,0 +1,23 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz::GL +{ + bool EGLContextWayland::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext) + { + assert(window.type == WindowManager::Wayland); + + NazaraError("Wayland is not yet supported"); + return false; + } + + void EGLContextWayland::Destroy() + { + EGLContextBase::Destroy(); + } +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.cpp new file mode 100644 index 000000000..85dc9d958 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/Linux/EGLContextX11.cpp @@ -0,0 +1,23 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz::GL +{ + bool EGLContextX11::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext) + { + assert(window.type == WindowManager::X11); + + NazaraError("X11 is not yet supported"); + return false; + } + + void EGLContextX11::Destroy() + { + EGLContextBase::Destroy(); + } +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.cpp index 39be657eb..378ece173 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.cpp @@ -20,23 +20,27 @@ namespace Nz::GL bool WGLContext::Create(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext) { // Creating a context requires a device context, create window to get one - m_window.reset(::CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr)); - if (!m_window) + HWNDHandle window(::CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr)); + if (!window) { NazaraError("failed to create dummy window: " + Error::GetLastSystemError()); return false; } - ::ShowWindow(m_window.get(), FALSE); + ::ShowWindow(window.get(), FALSE); - m_deviceContext = ::GetDC(m_window.get()); + m_deviceContext = ::GetDC(window.get()); if (!m_deviceContext) { NazaraError("failed to retrieve dummy window device context: " + Error::GetLastSystemError()); return false; } - return CreateInternal(baseContext, params, shareContext); + if (!CreateInternal(baseContext, params, shareContext)) + return false; + + m_window = std::move(window); + return true; } bool WGLContext::Create(const WGLContext* baseContext, const ContextParams& params, WindowHandle window, const WGLContext* shareContext) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.cpp new file mode 100644 index 000000000..b14afc3ab --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.cpp @@ -0,0 +1,83 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz::GL +{ + bool EGLContextWin32::Create(const ContextParams& params, const EGLContextBase* shareContext) + { + // It seems context sharing between pbuffer context and window context doesn't work, create an hidden window to handle this + HWNDHandle window(::CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr)); + if (!window) + { + NazaraError("failed to create dummy window: " + Error::GetLastSystemError()); + return false; + } + + ::ShowWindow(window.get(), FALSE); + + WindowHandle windowHandle; + windowHandle.type = WindowManager::Windows; + windowHandle.windows.window = window.get(); + + if (!Create(params, windowHandle, shareContext)) + return false; + + m_ownedWindow = std::move(window); + + return true; + } + + bool EGLContextWin32::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext) + { + assert(window.type == WindowManager::Windows); + + Destroy(); //< In case a previous display or surface hasn't been released + + m_params = params; + + if (!BindAPI()) + return false; + + HWND windowHandle = static_cast(window.windows.window); + HDC deviceContext = ::GetDC(windowHandle); + if (!deviceContext) + { + NazaraError("failed to retrieve window device context: " + Error::GetLastSystemError()); + return false; + } + + m_display = m_loader.eglGetDisplay(deviceContext); + if (!InitDisplay()) + return false; + + std::size_t configCount; + std::array configs; + if (!ChooseConfig(configs.data(), configs.size(), &configCount)) + return false; + + EGLint surfaceAttributes[] = { + EGL_NONE + }; + + std::size_t configIndex = 0; + for (; configIndex < configCount; ++configIndex) + { + m_surface = m_loader.eglCreateWindowSurface(m_display, configs[configIndex], windowHandle, surfaceAttributes); + if (m_surface) + break; + } + + return CreateInternal(configs[configIndex], shareContext); + } + + void EGLContextWin32::Destroy() + { + EGLContextBase::Destroy(); + m_ownedWindow.reset(); + } +} diff --git a/thirdparty/include/EGL/egl.h b/thirdparty/include/EGL/egl.h index 959f175d7..00c571ef6 100644 --- a/thirdparty/include/EGL/egl.h +++ b/thirdparty/include/EGL/egl.h @@ -6,34 +6,15 @@ extern "C" { #endif /* -** Copyright (c) 2013-2017 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 /* ** This header is generated from the Khronos EGL XML API Registry. ** The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** http://www.khronos.org/registry/egl ** -** Khronos $Git commit SHA1: b5409265f3 $ on $Git commit date: 2020-02-20 08:24:34 -0800 $ +** Khronos $Git commit SHA1: 50f5da047a $ on $Git commit date: 2020-08-13 03:59:02 -0700 $ */ #include @@ -42,7 +23,7 @@ extern "C" { #define EGL_EGL_PROTOTYPES 1 #endif -/* Generated on date 20200220 */ +/* Generated on date 20200813 */ /* Generated C header for: * API: egl diff --git a/thirdparty/include/EGL/eglext.h b/thirdparty/include/EGL/eglext.h index a1e5e9468..823e22ce4 100644 --- a/thirdparty/include/EGL/eglext.h +++ b/thirdparty/include/EGL/eglext.h @@ -6,39 +6,20 @@ extern "C" { #endif /* -** Copyright (c) 2013-2017 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 /* ** This header is generated from the Khronos EGL XML API Registry. ** The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** http://www.khronos.org/registry/egl ** -** Khronos $Git commit SHA1: b5409265f3 $ on $Git commit date: 2020-02-20 08:24:34 -0800 $ +** Khronos $Git commit SHA1: 50f5da047a $ on $Git commit date: 2020-08-13 03:59:02 -0700 $ */ #include -#define EGL_EGLEXT_VERSION 20200220 +#define EGL_EGLEXT_VERSION 20200813 /* Generated C header for: * API: egl @@ -707,6 +688,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a #define EGL_EXT_device_query 1 #endif /* EGL_EXT_device_query */ +#ifndef EGL_EXT_device_query_name +#define EGL_EXT_device_query_name 1 +#define EGL_RENDERER_EXT 0x335F +#endif /* EGL_EXT_device_query_name */ + #ifndef EGL_EXT_gl_colorspace_bt2020_linear #define EGL_EXT_gl_colorspace_bt2020_linear 1 #define EGL_GL_COLORSPACE_BT2020_LINEAR_EXT 0x333F @@ -1149,6 +1135,24 @@ EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface sur #define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C #endif /* EGL_NV_robustness_video_memory_purge */ +#ifndef EGL_NV_stream_consumer_eglimage +#define EGL_NV_stream_consumer_eglimage 1 +#define EGL_STREAM_CONSUMER_IMAGE_NV 0x3373 +#define EGL_STREAM_IMAGE_ADD_NV 0x3374 +#define EGL_STREAM_IMAGE_REMOVE_NV 0x3375 +#define EGL_STREAM_IMAGE_AVAILABLE_NV 0x3376 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMIMAGECONSUMERCONNECTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, EGLuint64KHR *modifiers, EGLAttrib *attrib_list); +typedef EGLint (EGLAPIENTRYP PFNEGLQUERYSTREAMCONSUMEREVENTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMACQUIREIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMRELEASEIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamImageConsumerConnectNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, EGLuint64KHR *modifiers, EGLAttrib *attrib_list); +EGLAPI EGLint EGLAPIENTRY eglQueryStreamConsumerEventNV (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAcquireImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamReleaseImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync); +#endif +#endif /* EGL_NV_stream_consumer_eglimage */ + #ifndef EGL_NV_stream_consumer_gltexture_yuv #define EGL_NV_stream_consumer_gltexture_yuv 1 #define EGL_YUV_PLANE0_TEXTURE_UNIT_NV 0x332C diff --git a/thirdparty/include/EGL/eglplatform.h b/thirdparty/include/EGL/eglplatform.h index eaac469f3..af5bbfb0f 100644 --- a/thirdparty/include/EGL/eglplatform.h +++ b/thirdparty/include/EGL/eglplatform.h @@ -2,36 +2,17 @@ #define __eglplatform_h_ /* -** Copyright (c) 2007-2016 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +** Copyright 2007-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 */ /* Platform-specific types and definitions for egl.h - * $Revision: 30994 $ on $Date: 2015-04-30 13:36:48 -0700 (Thu, 30 Apr 2015) $ * * Adopters may modify khrplatform.h and this file to suit their platform. * You are encouraged to submit all modifications to the Khronos group so that * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "EGL" component "Registry". + * by filing an issue or pull request on the public Khronos EGL Registry, at + * https://www.github.com/KhronosGroup/EGL-Registry/ */ #include