TextureUnit.h 894 B

123456789101112131415161718192021222324252627282930313233
  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/OwnPtr.h>
  8. #include <LibGL/Tex/Texture2D.h>
  9. namespace GL {
  10. class TextureUnit {
  11. public:
  12. TextureUnit() = default;
  13. void bind_texture_to_target(GLenum texture_target, const RefPtr<Texture>& texture);
  14. void unbind_texture(GLenum texture_target);
  15. RefPtr<Texture2D>& bound_texture_2d() const { return m_texture_target_2d; }
  16. RefPtr<Texture>& bound_texture() const { return m_currently_bound_texture; }
  17. GLenum currently_bound_target() const { return m_currently_bound_target; }
  18. bool is_bound() const { return !m_currently_bound_texture.is_null(); }
  19. private:
  20. mutable RefPtr<Texture2D> m_texture_target_2d { nullptr };
  21. mutable RefPtr<Texture> m_currently_bound_texture { nullptr };
  22. GLenum m_currently_bound_target;
  23. };
  24. }