mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15:17:46 +00:00
LibGL: Refactor TextureNameAllocator to a more general NameAllocator
This functionality can also be used for other types of objects.
This commit is contained in:
parent
9a0bb8212a
commit
892006218a
7 changed files with 67 additions and 61 deletions
27
Userland/Libraries/LibGL/NameAllocator.h
Normal file
27
Userland/Libraries/LibGL/NameAllocator.h
Normal file
|
@ -0,0 +1,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 };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue