Add OpenGLRenderer (WIP)
This commit is contained in:
39
include/Nazara/OpenGLRenderer/Wrapper/.hpp
Normal file
39
include/Nazara/OpenGLRenderer/Wrapper/.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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_GLCONTEXT_HPP
|
||||
#define NAZARA_OPENGLRENDERER_GLCONTEXT_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
struct ContextParams
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class GLContext
|
||||
{
|
||||
public:
|
||||
GLContext() = default;
|
||||
virtual ~GLContext();
|
||||
|
||||
virtual bool Activate() = 0;
|
||||
|
||||
virtual bool Create(const ContextParams& params) = 0;
|
||||
|
||||
virtual void EnableVerticalSync(bool enabled) = 0;
|
||||
|
||||
virtual void SwapBuffers() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/GLContext.inl>
|
||||
|
||||
#endif
|
||||
12
include/Nazara/OpenGLRenderer/Wrapper/.inl
Normal file
12
include/Nazara/OpenGLRenderer/Wrapper/.inl
Normal 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/GLContext.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz::Vk
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
46
include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp
Normal file
46
include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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_VKBUFFER_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class Buffer : public DeviceObject<Buffer, VkBuffer, VkBufferCreateInfo, VK_OBJECT_TYPE_BUFFER>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
Buffer() = default;
|
||||
Buffer(const Buffer&) = delete;
|
||||
Buffer(Buffer&&) noexcept = default;
|
||||
~Buffer() = default;
|
||||
|
||||
bool BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset = 0);
|
||||
|
||||
using DeviceObject::Create;
|
||||
inline bool Create(Device& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr);
|
||||
|
||||
VkMemoryRequirements GetMemoryRequirements() const;
|
||||
|
||||
Buffer& operator=(const Buffer&) = delete;
|
||||
Buffer& operator=(Buffer&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle);
|
||||
static inline void DestroyHelper(Device& device, VkBuffer handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Buffer.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKBUFFER_HPP
|
||||
62
include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl
Normal file
62
include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl
Normal file
@@ -0,0 +1,62 @@
|
||||
// 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/Buffer.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline bool Buffer::BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset)
|
||||
{
|
||||
m_lastErrorCode = m_device->vkBindBufferMemory(*m_device, m_handle, memory, offset);
|
||||
if (m_lastErrorCode != VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to bind buffer memory");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Buffer::Create(Device& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
VkBufferCreateInfo createInfo = {
|
||||
VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
|
||||
nullptr, // const void* pNext;
|
||||
flags, // VkBufferCreateFlags flags;
|
||||
size, // VkDeviceSize size;
|
||||
usage, // VkBufferUsageFlags usage;
|
||||
VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
|
||||
0, // uint32_t queueFamilyIndexCount;
|
||||
nullptr // const uint32_t* pQueueFamilyIndices;
|
||||
};
|
||||
|
||||
return Create(device, createInfo, allocator);
|
||||
}
|
||||
|
||||
inline VkMemoryRequirements Buffer::GetMemoryRequirements() const
|
||||
{
|
||||
NazaraAssert(IsValid(), "Invalid buffer");
|
||||
|
||||
VkMemoryRequirements memoryRequirements;
|
||||
m_device->vkGetBufferMemoryRequirements(*m_device, m_handle, &memoryRequirements);
|
||||
|
||||
return memoryRequirements;
|
||||
}
|
||||
|
||||
inline VkResult Buffer::CreateHelper(Device& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle)
|
||||
{
|
||||
return device.vkCreateBuffer(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void Buffer::DestroyHelper(Device& device, VkBuffer handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroyBuffer(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
34
include/Nazara/OpenGLRenderer/Wrapper/Context.hpp
Normal file
34
include/Nazara/OpenGLRenderer/Wrapper/Context.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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_CONTEXT_HPP
|
||||
#define NAZARA_OPENGLRENDERER_CONTEXT_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/GLContext.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
class Context
|
||||
{
|
||||
public:
|
||||
Context() = default;
|
||||
Context(const Context&) = delete;
|
||||
Context(Context&& object) noexcept = default;
|
||||
~Context() = default;
|
||||
|
||||
Context& operator=(const Context&) = delete;
|
||||
Context& operator=(Context&& object) noexcept = default;
|
||||
|
||||
private:
|
||||
std::unique_ptr<GLContext> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Context.inl>
|
||||
|
||||
#endif
|
||||
12
include/Nazara/OpenGLRenderer/Wrapper/Context.inl
Normal file
12
include/Nazara/OpenGLRenderer/Wrapper/Context.inl
Normal 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/Context.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
56
include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp
Normal file
56
include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
// 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_VKDEVICEOBJECT_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Device.hpp>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <string>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
class DeviceObject
|
||||
{
|
||||
public:
|
||||
DeviceObject();
|
||||
DeviceObject(const DeviceObject&) = delete;
|
||||
DeviceObject(DeviceObject&& object) noexcept;
|
||||
~DeviceObject();
|
||||
|
||||
bool Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr);
|
||||
void Destroy();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
Device* GetDevice() const;
|
||||
VkResult GetLastErrorCode() const;
|
||||
|
||||
void SetDebugName(const char* name);
|
||||
void SetDebugName(const std::string& name);
|
||||
|
||||
DeviceObject& operator=(const DeviceObject&) = delete;
|
||||
DeviceObject& operator=(DeviceObject&& object) noexcept;
|
||||
|
||||
operator VkType() const;
|
||||
|
||||
protected:
|
||||
MovablePtr<Device> m_device;
|
||||
VkAllocationCallbacks m_allocator;
|
||||
VkType m_handle;
|
||||
mutable VkResult m_lastErrorCode;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP
|
||||
123
include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl
Normal file
123
include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl
Normal file
@@ -0,0 +1,123 @@
|
||||
// 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/DeviceObject.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Utils.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
DeviceObject<C, VkType, CreateInfo, ObjectType>::DeviceObject() :
|
||||
m_handle(VK_NULL_HANDLE)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
DeviceObject<C, VkType, CreateInfo, ObjectType>::DeviceObject(DeviceObject&& object) noexcept :
|
||||
m_device(std::move(object.m_device)),
|
||||
m_allocator(object.m_allocator),
|
||||
m_handle(object.m_handle),
|
||||
m_lastErrorCode(object.m_lastErrorCode)
|
||||
{
|
||||
object.m_handle = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
DeviceObject<C, VkType, CreateInfo, ObjectType>::~DeviceObject()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
bool DeviceObject<C, VkType, CreateInfo, ObjectType>::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
m_device = &device;
|
||||
m_lastErrorCode = C::CreateHelper(*m_device, &createInfo, allocator, &m_handle);
|
||||
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to create OpenGL object: " + TranslateOpenGLError(m_lastErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the allocator to access them when needed
|
||||
if (allocator)
|
||||
m_allocator = *allocator;
|
||||
else
|
||||
m_allocator.pfnAllocation = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
void DeviceObject<C, VkType, CreateInfo, ObjectType>::Destroy()
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
C::DestroyHelper(*m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr);
|
||||
m_handle = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
bool DeviceObject<C, VkType, CreateInfo, ObjectType>::IsValid() const
|
||||
{
|
||||
return m_handle != VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
Device* DeviceObject<C, VkType, CreateInfo, ObjectType>::GetDevice() const
|
||||
{
|
||||
return m_device;
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
VkResult DeviceObject<C, VkType, CreateInfo, ObjectType>::GetLastErrorCode() const
|
||||
{
|
||||
return m_lastErrorCode;
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
void DeviceObject<C, VkType, CreateInfo, ObjectType>::SetDebugName(const char* name)
|
||||
{
|
||||
if (m_device->vkSetDebugUtilsObjectNameEXT)
|
||||
{
|
||||
VkDebugUtilsObjectNameInfoEXT debugName = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT };
|
||||
debugName.objectType = ObjectType;
|
||||
debugName.objectHandle = static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_handle));
|
||||
debugName.pObjectName = name;
|
||||
|
||||
m_device->vkSetDebugUtilsObjectNameEXT(*m_device, &debugName);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
void DeviceObject<C, VkType, CreateInfo, ObjectType>::SetDebugName(const std::string& name)
|
||||
{
|
||||
return SetDebugName(name.data());
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
auto DeviceObject<C, VkType, CreateInfo, ObjectType>::operator=(DeviceObject&& object) noexcept -> DeviceObject&
|
||||
{
|
||||
std::swap(m_allocator, object.m_allocator);
|
||||
std::swap(m_device, object.m_device);
|
||||
std::swap(m_handle, object.m_handle);
|
||||
std::swap(m_lastErrorCode, object.m_lastErrorCode);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
DeviceObject<C, VkType, CreateInfo, ObjectType>::operator VkType() const
|
||||
{
|
||||
return m_handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
140
include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp
Normal file
140
include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp
Normal file
@@ -0,0 +1,140 @@
|
||||
// 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_COREFUNCTIONS_HPP
|
||||
#define NAZARA_OPENGLRENDERER_COREFUNCTIONS_HPP
|
||||
|
||||
#include <GLES3/gl3.h>
|
||||
|
||||
// OpenGL core
|
||||
#define NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(cb) \
|
||||
cb(glActiveTexture, PFNGLACTIVETEXTUREPROC) \
|
||||
cb(glAttachShader, PFNGLATTACHSHADERPROC) \
|
||||
cb(glBeginQuery, PFNGLBEGINQUERYPROC) \
|
||||
cb(glBindAttribLocation, PFNGLBINDATTRIBLOCATIONPROC) \
|
||||
cb(glBindBuffer, PFNGLBINDBUFFERPROC) \
|
||||
cb(glBindFramebuffer, PFNGLBINDFRAMEBUFFERPROC) \
|
||||
cb(glBindRenderbuffer, PFNGLBINDRENDERBUFFERPROC) \
|
||||
cb(glBindSampler, PFNGLBINDSAMPLERPROC) \
|
||||
cb(glBindTexture, PFNGLBINDTEXTUREPROC) \
|
||||
cb(glBindVertexArray, PFNGLBINDVERTEXARRAYPROC) \
|
||||
cb(glBlendFunc, PFNGLBLENDFUNCPROC) \
|
||||
cb(glBlendFuncSeparate, PFNGLBLENDFUNCSEPARATEPROC) \
|
||||
cb(glBlitFramebuffer, PFNGLBLITFRAMEBUFFERPROC) \
|
||||
cb(glBufferData, PFNGLBUFFERDATAPROC) \
|
||||
cb(glBufferSubData, PFNGLBUFFERSUBDATAPROC) \
|
||||
cb(glClear, PFNGLCLEARPROC) \
|
||||
cb(glClearColor, PFNGLCLEARCOLORPROC) \
|
||||
cb(glClearStencil, PFNGLCLEARSTENCILPROC) \
|
||||
cb(glCreateProgram, PFNGLCREATEPROGRAMPROC) \
|
||||
cb(glCreateShader, PFNGLCREATESHADERPROC) \
|
||||
cb(glCheckFramebufferStatus, PFNGLCHECKFRAMEBUFFERSTATUSPROC) \
|
||||
cb(glColorMask, PFNGLCOLORMASKPROC) \
|
||||
cb(glCompressedTexSubImage2D, PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) \
|
||||
cb(glCompressedTexSubImage3D, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) \
|
||||
cb(glCullFace, PFNGLCULLFACEPROC) \
|
||||
cb(glCompileShader, PFNGLCOMPILESHADERPROC) \
|
||||
cb(glCopyTexSubImage2D, PFNGLCOPYTEXSUBIMAGE2DPROC) \
|
||||
cb(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \
|
||||
cb(glDeleteFramebuffers, PFNGLDELETEFRAMEBUFFERSPROC) \
|
||||
cb(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \
|
||||
cb(glDeleteQueries, PFNGLDELETEQUERIESPROC) \
|
||||
cb(glDeleteRenderbuffers, PFNGLDELETERENDERBUFFERSPROC) \
|
||||
cb(glDeleteSamplers, PFNGLDELETESAMPLERSPROC) \
|
||||
cb(glDeleteShader, PFNGLDELETESHADERPROC) \
|
||||
cb(glDeleteTextures, PFNGLDELETETEXTURESPROC) \
|
||||
cb(glDeleteVertexArrays, PFNGLDELETEVERTEXARRAYSPROC) \
|
||||
cb(glDepthFunc, PFNGLDEPTHFUNCPROC) \
|
||||
cb(glDepthMask, PFNGLDEPTHMASKPROC) \
|
||||
cb(glDisable, PFNGLDISABLEPROC) \
|
||||
cb(glDisableVertexAttribArray, PFNGLDISABLEVERTEXATTRIBARRAYPROC) \
|
||||
cb(glDrawArrays, PFNGLDRAWARRAYSPROC) \
|
||||
cb(glDrawArraysInstanced, PFNGLDRAWARRAYSINSTANCEDPROC) \
|
||||
cb(glDrawBuffers, PFNGLDRAWBUFFERSPROC) \
|
||||
cb(glDrawElements, PFNGLDRAWELEMENTSPROC) \
|
||||
cb(glDrawElementsInstanced, PFNGLDRAWELEMENTSINSTANCEDPROC) \
|
||||
cb(glEnable, PFNGLENABLEPROC) \
|
||||
cb(glEnableVertexAttribArray, PFNGLENABLEVERTEXATTRIBARRAYPROC) \
|
||||
cb(glEndQuery, PFNGLENDQUERYPROC) \
|
||||
cb(glFlush, PFNGLFLUSHPROC) \
|
||||
cb(glFramebufferRenderbuffer, PFNGLFRAMEBUFFERRENDERBUFFERPROC) \
|
||||
cb(glFramebufferTexture2D, PFNGLFRAMEBUFFERTEXTURE2DPROC) \
|
||||
cb(glFramebufferTextureLayer, PFNGLFRAMEBUFFERTEXTURELAYERPROC) \
|
||||
cb(glGenerateMipmap, PFNGLGENERATEMIPMAPPROC) \
|
||||
cb(glGenBuffers, PFNGLGENBUFFERSPROC) \
|
||||
cb(glGenFramebuffers, PFNGLGENFRAMEBUFFERSPROC) \
|
||||
cb(glGenRenderbuffers, PFNGLGENRENDERBUFFERSPROC) \
|
||||
cb(glGenQueries, PFNGLGENQUERIESPROC) \
|
||||
cb(glGenSamplers, PFNGLGENSAMPLERSPROC) \
|
||||
cb(glGenTextures, PFNGLGENTEXTURESPROC) \
|
||||
cb(glGenVertexArrays, PFNGLGENVERTEXARRAYSPROC) \
|
||||
cb(glGetActiveUniform, PFNGLGETACTIVEUNIFORMPROC) \
|
||||
cb(glGetBooleanv, PFNGLGETBOOLEANVPROC) \
|
||||
cb(glGetBufferParameteriv, PFNGLGETBUFFERPARAMETERIVPROC) \
|
||||
cb(glGetError, PFNGLGETERRORPROC) \
|
||||
cb(glGetFloatv, PFNGLGETFLOATVPROC) \
|
||||
cb(glGetIntegerv, PFNGLGETINTEGERVPROC) \
|
||||
cb(glGetProgramBinary, PFNGLGETPROGRAMBINARYPROC) \
|
||||
cb(glGetProgramiv, PFNGLGETPROGRAMIVPROC) \
|
||||
cb(glGetProgramInfoLog, PFNGLGETPROGRAMINFOLOGPROC) \
|
||||
cb(glGetQueryiv, PFNGLGETQUERYIVPROC) \
|
||||
cb(glGetQueryObjectuiv, PFNGLGETQUERYOBJECTUIVPROC) \
|
||||
cb(glGetShaderInfoLog, PFNGLGETSHADERINFOLOGPROC) \
|
||||
cb(glGetShaderiv, PFNGLGETSHADERIVPROC) \
|
||||
cb(glGetShaderSource, PFNGLGETSHADERSOURCEPROC) \
|
||||
cb(glGetString, PFNGLGETSTRINGPROC) \
|
||||
cb(glGetStringi, PFNGLGETSTRINGIPROC) \
|
||||
cb(glGetTexParameterfv, PFNGLGETTEXPARAMETERFVPROC) \
|
||||
cb(glGetTexParameteriv, PFNGLGETTEXPARAMETERIVPROC) \
|
||||
cb(glGetUniformfv, PFNGLGETUNIFORMFVPROC) \
|
||||
cb(glGetUniformiv, PFNGLGETUNIFORMIVPROC) \
|
||||
cb(glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC) \
|
||||
cb(glIsEnabled, PFNGLISENABLEDPROC) \
|
||||
cb(glLineWidth, PFNGLLINEWIDTHPROC) \
|
||||
cb(glLinkProgram, PFNGLLINKPROGRAMPROC) \
|
||||
cb(glMapBufferRange, PFNGLMAPBUFFERRANGEPROC) \
|
||||
cb(glPixelStorei, PFNGLPIXELSTOREIPROC) \
|
||||
cb(glProgramBinary, PFNGLPROGRAMBINARYPROC) \
|
||||
cb(glProgramParameteri, PFNGLPROGRAMPARAMETERIPROC) \
|
||||
cb(glReadPixels, PFNGLREADPIXELSPROC) \
|
||||
cb(glRenderbufferStorage, PFNGLRENDERBUFFERSTORAGEPROC) \
|
||||
cb(glSamplerParameterf, PFNGLSAMPLERPARAMETERFPROC) \
|
||||
cb(glSamplerParameteri, PFNGLSAMPLERPARAMETERIPROC) \
|
||||
cb(glScissor, PFNGLSCISSORPROC) \
|
||||
cb(glShaderSource, PFNGLSHADERSOURCEPROC) \
|
||||
cb(glStencilFunc, PFNGLSTENCILFUNCPROC) \
|
||||
cb(glStencilFuncSeparate, PFNGLSTENCILFUNCSEPARATEPROC) \
|
||||
cb(glStencilOp, PFNGLSTENCILOPPROC) \
|
||||
cb(glStencilOpSeparate, PFNGLSTENCILOPSEPARATEPROC) \
|
||||
cb(glTexImage2D, PFNGLTEXIMAGE2DPROC) \
|
||||
cb(glTexImage3D, PFNGLTEXIMAGE3DPROC) \
|
||||
cb(glTexParameterf, PFNGLTEXPARAMETERFPROC) \
|
||||
cb(glTexParameteri, PFNGLTEXPARAMETERIPROC) \
|
||||
cb(glTexStorage2D, PFNGLTEXSTORAGE2DPROC) \
|
||||
cb(glTexStorage3D, PFNGLTEXSTORAGE3DPROC) \
|
||||
cb(glTexSubImage2D, PFNGLTEXSUBIMAGE2DPROC) \
|
||||
cb(glTexSubImage3D, PFNGLTEXSUBIMAGE3DPROC) \
|
||||
cb(glUniform1f, PFNGLUNIFORM1FPROC) \
|
||||
cb(glUniform1i, PFNGLUNIFORM1IPROC) \
|
||||
cb(glUniform1fv, PFNGLUNIFORM1FVPROC) \
|
||||
cb(glUniform1iv, PFNGLUNIFORM1IVPROC) \
|
||||
cb(glUniform2fv, PFNGLUNIFORM2FVPROC) \
|
||||
cb(glUniform2iv, PFNGLUNIFORM2IVPROC) \
|
||||
cb(glUniform3fv, PFNGLUNIFORM3FVPROC) \
|
||||
cb(glUniform3iv, PFNGLUNIFORM3IVPROC) \
|
||||
cb(glUniform4fv, PFNGLUNIFORM4FVPROC) \
|
||||
cb(glUniform4iv, PFNGLUNIFORM4IVPROC) \
|
||||
cb(glUniformMatrix4fv, PFNGLUNIFORMMATRIX4FVPROC) \
|
||||
cb(glUnmapBuffer, PFNGLUNMAPBUFFERPROC) \
|
||||
cb(glUseProgram, PFNGLUSEPROGRAMPROC) \
|
||||
cb(glValidateProgram, PFNGLVALIDATEPROGRAMPROC) \
|
||||
cb(glVertexAttrib4f, PFNGLVERTEXATTRIB4FPROC) \
|
||||
cb(glVertexAttribDivisor, PFNGLVERTEXATTRIBDIVISORPROC) \
|
||||
cb(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \
|
||||
cb(glVertexAttribIPointer, PFNGLVERTEXATTRIBIPOINTERPROC) \
|
||||
cb(glViewport, PFNGLVIEWPORTPROC) \
|
||||
|
||||
#endif
|
||||
39
include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.hpp
Normal file
39
include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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_VKFRAMEBUFFER_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKFRAMEBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class Framebuffer : public DeviceObject<Framebuffer, VkFramebuffer, VkFramebufferCreateInfo, VK_OBJECT_TYPE_FRAMEBUFFER>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
Framebuffer() = default;
|
||||
Framebuffer(const Framebuffer&) = delete;
|
||||
Framebuffer(Framebuffer&&) = default;
|
||||
~Framebuffer() = default;
|
||||
|
||||
Framebuffer& operator=(const Framebuffer&) = delete;
|
||||
Framebuffer& operator=(Framebuffer&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle);
|
||||
static inline void DestroyHelper(Device& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Framebuffer.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKFRAMEBUFFER_HPP
|
||||
24
include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.inl
Normal file
24
include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.inl
Normal file
@@ -0,0 +1,24 @@
|
||||
// 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/Framebuffer.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline VkResult Framebuffer::CreateHelper(Device& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle)
|
||||
{
|
||||
return device.vkCreateFramebuffer(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void Framebuffer::DestroyHelper(Device& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroyFramebuffer(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
52
include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp
Normal file
52
include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// 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_CONTEXTIMPL_HPP
|
||||
#define NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
struct ContextParams
|
||||
{
|
||||
bool doubleBuffering = true;
|
||||
unsigned int sampleCount = 1;
|
||||
unsigned int bitsPerPixel = 32;
|
||||
unsigned int depthBits = 24;
|
||||
unsigned int stencilBits = 8;
|
||||
};
|
||||
|
||||
class Loader;
|
||||
|
||||
class GLContext
|
||||
{
|
||||
public:
|
||||
GLContext() = default;
|
||||
virtual ~GLContext();
|
||||
|
||||
virtual bool Activate() = 0;
|
||||
|
||||
virtual bool Create(const ContextParams& params) = 0;
|
||||
|
||||
virtual void EnableVerticalSync(bool enabled) = 0;
|
||||
|
||||
bool LoadCoreFunctions(Loader& loader);
|
||||
|
||||
virtual void SwapBuffers() = 0;
|
||||
|
||||
private:
|
||||
#define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr;
|
||||
NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC)
|
||||
#undef NAZARA_OPENGLRENDERER_FUNC
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/GLContext.inl>
|
||||
|
||||
#endif
|
||||
12
include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl
Normal file
12
include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl
Normal 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/GLContext.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz::Vk
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
34
include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp
Normal file
34
include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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_LOADER_HPP
|
||||
#define NAZARA_OPENGLRENDERER_LOADER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Config.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
class GLContext;
|
||||
|
||||
using GLFunction = int(*)();
|
||||
|
||||
class NAZARA_OPENGLRENDERER_API Loader
|
||||
{
|
||||
public:
|
||||
Loader() = default;
|
||||
virtual ~Loader();
|
||||
|
||||
virtual std::unique_ptr<GLContext> CreateContext() = 0;
|
||||
|
||||
virtual GLFunction LoadFunction(const char* name) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Loader.inl>
|
||||
|
||||
#endif
|
||||
12
include/Nazara/OpenGLRenderer/Wrapper/Loader.inl
Normal file
12
include/Nazara/OpenGLRenderer/Wrapper/Loader.inl
Normal 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/Loader.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
43
include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp
Normal file
43
include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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_VKIMAGE_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKIMAGE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class Image : public DeviceObject<Image, VkImage, VkImageCreateInfo, VK_OBJECT_TYPE_IMAGE>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
Image() = default;
|
||||
Image(const Image&) = delete;
|
||||
Image(Image&&) = default;
|
||||
~Image() = default;
|
||||
|
||||
bool BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset = 0);
|
||||
|
||||
VkMemoryRequirements GetMemoryRequirements() const;
|
||||
|
||||
Image& operator=(const Image&) = delete;
|
||||
Image& operator=(Image&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle);
|
||||
static inline void DestroyHelper(Device& device, VkImage handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Image.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKIMAGE_HPP
|
||||
47
include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl
Normal file
47
include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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/Image.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Utils.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline bool Image::BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset)
|
||||
{
|
||||
m_lastErrorCode = m_device->vkBindImageMemory(*m_device, m_handle, memory, offset);
|
||||
if (m_lastErrorCode != VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to bind image memory: " + TranslateOpenGLError(m_lastErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline VkMemoryRequirements Image::GetMemoryRequirements() const
|
||||
{
|
||||
NazaraAssert(IsValid(), "Invalid image");
|
||||
|
||||
VkMemoryRequirements memoryRequirements;
|
||||
m_device->vkGetImageMemoryRequirements(*m_device, m_handle, &memoryRequirements);
|
||||
|
||||
return memoryRequirements;
|
||||
}
|
||||
|
||||
inline VkResult Image::CreateHelper(Device& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle)
|
||||
{
|
||||
return device.vkCreateImage(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void Image::DestroyHelper(Device& device, VkImage handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroyImage(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
47
include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.hpp
Normal file
47
include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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_VKFENCE_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKFENCE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class Fence : public DeviceObject<Fence, VkFence, VkFenceCreateInfo, VK_OBJECT_TYPE_FENCE>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
Fence() = default;
|
||||
Fence(const Fence&) = delete;
|
||||
Fence(Fence&&) = default;
|
||||
~Fence() = default;
|
||||
|
||||
using DeviceObject::Create;
|
||||
inline bool Create(Device& device, VkFenceCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr);
|
||||
|
||||
inline bool Reset();
|
||||
|
||||
inline bool Wait();
|
||||
inline bool Wait(UInt64 timeout, bool* didTimeout = nullptr);
|
||||
|
||||
Fence& operator=(const Fence&) = delete;
|
||||
Fence& operator=(Fence&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle);
|
||||
static inline void DestroyHelper(Device& device, VkFence handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Fence.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKFENCE_HPP
|
||||
68
include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.inl
Normal file
68
include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.inl
Normal file
@@ -0,0 +1,68 @@
|
||||
// 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/Fence.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline bool Fence::Create(Device& device, VkFenceCreateFlags flags, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
VkFenceCreateInfo createInfo =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
|
||||
nullptr,
|
||||
flags
|
||||
};
|
||||
|
||||
return Create(device, createInfo, allocator);
|
||||
}
|
||||
|
||||
inline bool Fence::Reset()
|
||||
{
|
||||
m_lastErrorCode = m_device->vkResetFences(*m_device, 1U, &m_handle);
|
||||
if (m_lastErrorCode != VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to reset fence: " + TranslateOpenGLError(m_lastErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Fence::Wait()
|
||||
{
|
||||
return Wait(std::numeric_limits<UInt64>::max());
|
||||
}
|
||||
|
||||
inline bool Fence::Wait(UInt64 timeout, bool* didTimeout)
|
||||
{
|
||||
m_lastErrorCode = m_device->vkWaitForFences(*m_device, 1U, &m_handle, VK_TRUE, timeout);
|
||||
if (m_lastErrorCode != VK_SUCCESS && m_lastErrorCode != VK_TIMEOUT)
|
||||
{
|
||||
NazaraError("Failed to wait for fence: " + TranslateOpenGLError(m_lastErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (didTimeout)
|
||||
*didTimeout = (m_lastErrorCode == VK_TIMEOUT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline VkResult Fence::CreateHelper(Device& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle)
|
||||
{
|
||||
return device.vkCreateFence(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void Fence::DestroyHelper(Device& device, VkFence handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroyFence(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
39
include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp
Normal file
39
include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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_VKSAMPLER_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKSAMPLER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class Sampler : public DeviceObject<Sampler, VkSampler, VkSamplerCreateInfo, VK_OBJECT_TYPE_SAMPLER>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
Sampler() = default;
|
||||
Sampler(const Sampler&) = delete;
|
||||
Sampler(Sampler&&) = default;
|
||||
~Sampler() = default;
|
||||
|
||||
Sampler& operator=(const Sampler&) = delete;
|
||||
Sampler& operator=(Sampler&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle);
|
||||
static inline void DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Sampler.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKSAMPLER_HPP
|
||||
24
include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl
Normal file
24
include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl
Normal file
@@ -0,0 +1,24 @@
|
||||
// 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/Sampler.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline VkResult Sampler::CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle)
|
||||
{
|
||||
return device.vkCreateSampler(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void Sampler::DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroySampler(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
42
include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp
Normal file
42
include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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_VKSHADERMODULE_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKSHADERMODULE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class ShaderModule : public DeviceObject<ShaderModule, VkShaderModule, VkShaderModuleCreateInfo, VK_OBJECT_TYPE_SHADER_MODULE>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
ShaderModule() = default;
|
||||
ShaderModule(const ShaderModule&) = delete;
|
||||
ShaderModule(ShaderModule&&) = default;
|
||||
~ShaderModule() = default;
|
||||
|
||||
using DeviceObject::Create;
|
||||
inline bool Create(Device& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr);
|
||||
|
||||
ShaderModule& operator=(const ShaderModule&) = delete;
|
||||
ShaderModule& operator=(ShaderModule&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle);
|
||||
static inline void DestroyHelper(Device& device, VkShaderModule handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/ShaderModule.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKSHADERMODULE_HPP
|
||||
38
include/Nazara/OpenGLRenderer/Wrapper/Shader.inl
Normal file
38
include/Nazara/OpenGLRenderer/Wrapper/Shader.inl
Normal 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
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/ShaderModule.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline bool ShaderModule::Create(Device& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
VkShaderModuleCreateInfo createInfo =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
||||
nullptr,
|
||||
flags,
|
||||
size,
|
||||
code
|
||||
};
|
||||
|
||||
return Create(device, createInfo, allocator);
|
||||
}
|
||||
|
||||
inline VkResult ShaderModule::CreateHelper(Device& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle)
|
||||
{
|
||||
return device.vkCreateShaderModule(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void ShaderModule::DestroyHelper(Device& device, VkShaderModule handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroyShaderModule(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
43
include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp
Normal file
43
include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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_VKPIPELINELAYOUT_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKPIPELINELAYOUT_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class PipelineLayout : public DeviceObject<PipelineLayout, VkPipelineLayout, VkPipelineLayoutCreateInfo, VK_OBJECT_TYPE_PIPELINE_LAYOUT>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
PipelineLayout() = default;
|
||||
PipelineLayout(const PipelineLayout&) = delete;
|
||||
PipelineLayout(PipelineLayout&&) = default;
|
||||
~PipelineLayout() = default;
|
||||
|
||||
using DeviceObject::Create;
|
||||
bool Create(Device& device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags = 0);
|
||||
bool Create(Device& device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags = 0);
|
||||
|
||||
PipelineLayout& operator=(const PipelineLayout&) = delete;
|
||||
PipelineLayout& operator=(PipelineLayout&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle);
|
||||
static inline void DestroyHelper(Device& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/PipelineLayout.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKPIPELINELAYOUT_HPP
|
||||
44
include/Nazara/OpenGLRenderer/Wrapper/Texture.inl
Normal file
44
include/Nazara/OpenGLRenderer/Wrapper/Texture.inl
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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/PipelineLayout.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline bool PipelineLayout::Create(Device& device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags)
|
||||
{
|
||||
return Create(device, 1U, &layout, flags);
|
||||
}
|
||||
|
||||
inline bool PipelineLayout::Create(Device& device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags)
|
||||
{
|
||||
VkPipelineLayoutCreateInfo createInfo = {
|
||||
VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
nullptr,
|
||||
flags,
|
||||
layoutCount,
|
||||
layouts,
|
||||
0U,
|
||||
nullptr
|
||||
};
|
||||
|
||||
return Create(device, createInfo);
|
||||
}
|
||||
|
||||
inline VkResult PipelineLayout::CreateHelper(Device& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle)
|
||||
{
|
||||
return device.vkCreatePipelineLayout(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void PipelineLayout::DestroyHelper(Device& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroyPipelineLayout(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
39
include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp
Normal file
39
include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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_VKIMAGEVIEW_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKIMAGEVIEW_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class ImageView : public DeviceObject<ImageView, VkImageView, VkImageViewCreateInfo, VK_OBJECT_TYPE_IMAGE_VIEW>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
ImageView() = default;
|
||||
ImageView(const ImageView&) = delete;
|
||||
ImageView(ImageView&&) = default;
|
||||
~ImageView() = default;
|
||||
|
||||
ImageView& operator=(const ImageView&) = delete;
|
||||
ImageView& operator=(ImageView&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle);
|
||||
static inline void DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/ImageView.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKIMAGEVIEW_HPP
|
||||
24
include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl
Normal file
24
include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl
Normal file
@@ -0,0 +1,24 @@
|
||||
// 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/ImageView.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline VkResult ImageView::CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle)
|
||||
{
|
||||
return device.vkCreateImageView(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void ImageView::DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroyImageView(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
71
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp
Normal file
71
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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_WGLCONTEXT_HPP
|
||||
#define NAZARA_OPENGLRENDERER_WGLCONTEXT_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/DynLib.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/GLContext.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_set>
|
||||
|
||||
#undef WIN32_LEAN_AND_MEAN //< Redefined by OpenGL header (ty Khronos)
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
class WGLLoader;
|
||||
|
||||
class WGLContext : public GLContext
|
||||
{
|
||||
public:
|
||||
WGLContext(WGLLoader& loader);
|
||||
WGLContext(const WGLContext&) = delete;
|
||||
WGLContext(WGLContext&&) = delete;
|
||||
~WGLContext();
|
||||
|
||||
bool Activate() override;
|
||||
|
||||
bool Create(const ContextParams& params) override;
|
||||
void Destroy();
|
||||
|
||||
void EnableVerticalSync(bool enabled) override;
|
||||
|
||||
void SwapBuffers() override;
|
||||
|
||||
WGLContext& operator=(const WGLContext&) = delete;
|
||||
WGLContext& operator=(WGLContext&&) = delete;
|
||||
|
||||
private:
|
||||
void Desactivate();
|
||||
bool LoadWGLExt();
|
||||
bool SetPixelFormat(const ContextParams& params);
|
||||
|
||||
#define NAZARA_OPENGLRENDERER_FUNC(name, sig)
|
||||
#define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext)
|
||||
#define NAZARA_OPENGLRENDERER_EXT_END()
|
||||
#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) sig name = nullptr;
|
||||
NAZARA_OPENGLRENDERER_FOREACH_WGL_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
|
||||
|
||||
std::unordered_set<std::string> m_supportedExtensions;
|
||||
WGLLoader& m_loader;
|
||||
HDC m_deviceContext;
|
||||
HGLRC m_handle;
|
||||
HWNDHandle m_window;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl>
|
||||
|
||||
#endif
|
||||
12
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl
Normal file
12
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl
Normal 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/WGLContext.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz::Vk
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
48
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp
Normal file
48
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// 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
|
||||
|
||||
#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() \
|
||||
|
||||
#define NAZARA_OPENGLRENDERER_FOREACH_GDI32_FUNC(func) \
|
||||
func(ChoosePixelFormat, PFNCHOOSEPIXELFORMATPROC) \
|
||||
func(DescribePixelFormat, PFNDESCRIBEPIXELFORMATPROC) \
|
||||
func(SetPixelFormat, PFNSETPIXELFORMATPROC) \
|
||||
func(SwapBuffers, PFNSWAPBUFFERSPROC) \
|
||||
|
||||
#endif
|
||||
49
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp
Normal file
49
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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_WGLLOADER_HPP
|
||||
#define NAZARA_OPENGLRENDERER_WGLLOADER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/DynLib.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
|
||||
#include <string>
|
||||
|
||||
#undef WIN32_LEAN_AND_MEAN //< Redefined by OpenGL header (ty Khronos)
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
class WGLLoader : public Loader
|
||||
{
|
||||
public:
|
||||
WGLLoader(DynLib& openglLib);
|
||||
~WGLLoader() = default;
|
||||
|
||||
std::unique_ptr<GLContext> CreateContext() override;
|
||||
|
||||
GLFunction LoadFunction(const char* name) 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_GDI32_FUNC(NAZARA_OPENGLRENDERER_FUNC)
|
||||
NAZARA_OPENGLRENDERER_FOREACH_WGL_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
|
||||
|
||||
private:
|
||||
DynLib m_gdi32Lib;
|
||||
DynLib& m_opengl32Lib;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.inl>
|
||||
|
||||
#endif
|
||||
12
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.inl
Normal file
12
include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.inl
Normal 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/WGLLoader.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz::Vk
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
26
include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp
Normal file
26
include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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 <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
|
||||
Reference in New Issue
Block a user