Add basic EGL support

This commit is contained in:
Jérôme Leclercq
2020-09-01 18:46:35 +02:00
parent 07a02ecfcd
commit ef737a8ecd
29 changed files with 1122 additions and 94 deletions

View File

@@ -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 <Nazara/Prerequisites.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/EGL/EGLContextBase.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp>
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 <Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.inl>
#endif

View File

@@ -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 <Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp>
#include <Nazara/OpenGLRenderer/Debug.hpp>
namespace Nz::GL
{
}
#include <Nazara/OpenGLRenderer/DebugOff.hpp>

View File

@@ -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 <GLES3/gl3.h>
#include <GL/wgl.h>
#include <GL/wglext.h>
#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

View File

@@ -0,0 +1,28 @@
// 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_WIN32HELPER_HPP
#define NAZARA_OPENGLRENDERER_WIN32HELPER_HPP
#include <Nazara/Prerequisites.hpp>
#include <memory>
#include <type_traits>
#include <windows.h>
namespace Nz::GL
{
struct WindowDeleter
{
void operator()(HWND handle) const
{
DestroyWindow(handle);
}
};
using HWNDHandle = std::unique_ptr<std::remove_pointer_t<HWND>, WindowDeleter>;
}
#endif