From b8bf80e84e70f64fe9e2ab8ba7769b60f1d9b708 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Fri, 4 Jun 2021 13:58:22 +0300 Subject: [PATCH] Support binding a texture to a specific texture unit --- libs/gfx/include/psemek/gfx/texture.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/gfx/include/psemek/gfx/texture.hpp b/libs/gfx/include/psemek/gfx/texture.hpp index 31e553f0..ff727ce7 100644 --- a/libs/gfx/include/psemek/gfx/texture.hpp +++ b/libs/gfx/include/psemek/gfx/texture.hpp @@ -34,6 +34,7 @@ namespace psemek::gfx void reset(); void bind() const; + void bind(int texture_unit) const; geom::vector size() const { return size_; } @@ -208,6 +209,13 @@ namespace psemek::gfx gl::BindTexture(Target, id()); } + template + void basic_texture::bind(int texture_unit) const + { + gl::ActiveTexture(gl::TEXTURE0 + texture_unit); + gl::BindTexture(Target, id()); + } + template std::size_t basic_texture::width() const {