summaryrefslogtreecommitdiff
path: root/gfx/gl/glBuffer.h
blob: f43c22356a9e2530ea75f143f1071b6dae0b3031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#include "glArrays.h"

namespace Impl {
	// NOLINTNEXTLINE(readability-identifier-naming)
	struct glBuffer : Detail::glNamed {
		void
		storage(const std::ranges::contiguous_range auto & data, GLenum flags)
		{
			glNamedBufferStorage(
					name, static_cast<GLsizeiptr>(data.size() * sizeof(decltype(*data.data()))), data.data(), flags);
		}

		void
		data(const std::ranges::contiguous_range auto & data, GLenum flags)
		{
			glNamedBufferData(
					name, static_cast<GLsizeiptr>(data.size() * sizeof(decltype(*data.data()))), data.data(), flags);
		}
	};
}

// NOLINTBEGIN(readability-identifier-naming)
template<size_t N> using glBuffers = glManagedArray<Impl::glBuffer, N, &glCreateBuffers, &glDeleteBuffers>;
using glBuffer = glManagedSingle<Impl::glBuffer, &glCreateBuffers, &glDeleteBuffers>;
// NOLINTEND(readability-identifier-naming)