NameAllocator.h 459 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Stack.h>
  8. #include <LibGL/GL/gl.h>
  9. namespace GL {
  10. class NameAllocator {
  11. public:
  12. NameAllocator() = default;
  13. void allocate(GLsizei count, GLuint* names);
  14. void free(GLuint name);
  15. bool has_allocated_name(GLuint name) const;
  16. private:
  17. Stack<GLuint, 512> m_free_names;
  18. GLuint m_last_id { 1 };
  19. };
  20. }