OpenGL: Implement VAOs

This commit is contained in:
Lynix
2020-05-11 14:10:36 +02:00
parent 332278dded
commit fe5b70ae1c
8 changed files with 422 additions and 33 deletions

View File

@@ -2,22 +2,39 @@
// 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/Wrapper/VertexArray.hpp>
#include <stdexcept>
#include <Nazara/OpenGLRenderer/Debug.hpp>
namespace Nz
namespace Nz::GL
{
namespace Vk
template<typename F>
static VertexArray VertexArray::Build(const Context& context, F&& callback)
{
inline VkResult ImageView::CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle)
{
return device.vkCreateImageView(device, createInfo, allocator, handle);
}
VertexArray vao;
if (!vao.Create(context))
throw std::runtime_error("failed to create vao");
inline void ImageView::DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator)
{
return device.vkDestroyImageView(device, handle, allocator);
}
context.BindVertexArray(vao.GetObjectId(), true);
callback();
context.BindVertexArray(0, true);
return vao;
}
inline GLuint VertexArray::CreateHelper(const Context& context)
{
GLuint vao = 0;
context.glGenVertexArrays(1U, &vao);
return vao;
}
inline void VertexArray::DestroyHelper(const Context& context, GLuint objectId)
{
context.glDeleteVertexArrays(1U, &objectId);
context.NotifyVertexArrayDestruction(objectId);
}
}