41 lines
989 B
C++
41 lines
989 B
C++
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
|
// This file is part of the "Nazara Engine - OpenGL renderer"
|
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
|
|
|
#include <stdexcept>
|
|
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
|
|
|
namespace Nz::GL
|
|
{
|
|
template<typename F>
|
|
VertexArray VertexArray::Build(const Context& context, F&& callback)
|
|
{
|
|
VertexArray vao;
|
|
if (!vao.Create(context))
|
|
throw std::runtime_error("failed to create vao");
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|