TextureUnit.cpp 843 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGL/GL/gl.h>
  7. #include <LibGL/Tex/TextureUnit.h>
  8. namespace GL {
  9. void TextureUnit::bind_texture_to_target(GLenum texture_target, const RefPtr<Texture>& texture)
  10. {
  11. switch (texture_target) {
  12. case GL_TEXTURE_2D:
  13. m_texture_target_2d = texture;
  14. m_currently_bound_texture = texture;
  15. m_currently_bound_target = GL_TEXTURE_2D;
  16. break;
  17. default:
  18. VERIFY_NOT_REACHED();
  19. }
  20. }
  21. void TextureUnit::unbind_texture(GLenum texture_target)
  22. {
  23. switch (texture_target) {
  24. case GL_TEXTURE_2D:
  25. m_texture_target_2d = nullptr;
  26. m_currently_bound_target = 0;
  27. break;
  28. default:
  29. VERIFY_NOT_REACHED();
  30. }
  31. m_currently_bound_texture = nullptr;
  32. }
  33. }