TextureUnit.cpp 744 B

1234567891011121314151617181920212223242526272829303132
  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. if (!texture) {
  12. m_texture_target_2d = nullptr;
  13. m_currently_bound_target = GL_NONE;
  14. m_currently_bound_texture = nullptr;
  15. return;
  16. }
  17. switch (texture_target) {
  18. case GL_TEXTURE_2D:
  19. m_texture_target_2d = static_ptr_cast<Texture2D>(texture);
  20. m_currently_bound_target = GL_TEXTURE_2D;
  21. m_currently_bound_texture = texture;
  22. break;
  23. default:
  24. VERIFY_NOT_REACHED();
  25. }
  26. }
  27. }