summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL/NameAllocator.h
blob: 186f211b3fde418fe09db720d00a16e2d034fcda (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
/*
 * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Stack.h>
#include <LibGL/GL/gl.h>

namespace GL {

class NameAllocator {
public:
    NameAllocator() = default;

    void allocate(GLsizei count, GLuint* names);
    void free(GLuint name);
    bool has_allocated_name(GLuint name) const;

private:
    Stack<GLuint, 512> m_free_names;
    GLuint m_last_id { 1 };
};

}