summaryrefslogtreecommitdiff
path: root/gfx/gl/glBuffer.h
blob: 275276f1b0c660fe580b866bb5375bbfe9257477 (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
#pragma once

#include "glArrays.h"

namespace Impl {
	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);
		}
	};
}

template<size_t N> using glBuffers = glManagedArray<Impl::glBuffer, N, &glCreateBuffers, &glDeleteBuffers>;
using glBuffer = glManagedSingle<Impl::glBuffer, &glCreateBuffers, &glDeleteBuffers>;