Browse Source

Add setting texture unit in bind()

master
Riyyi 3 years ago
parent
commit
b0d2ef2b93
  1. 8
      inferno/src/inferno/render/texture.cpp
  2. 2
      inferno/src/inferno/render/texture.h

8
inferno/src/inferno/render/texture.cpp

@ -45,9 +45,15 @@ namespace Inferno {
glDeleteTextures(1, &m_id);
}
void Texture::bind() const
void Texture::bind(uint32_t unit) const
{
// Set active unit
glActiveTexture(GL_TEXTURE0 + unit);
glBindTexture(GL_TEXTURE_2D, m_id);
// Reset unit
glActiveTexture(GL_TEXTURE0);
}
void Texture::unbind() const

2
inferno/src/inferno/render/texture.h

@ -13,7 +13,7 @@ namespace Inferno {
Texture(const std::string& path);
virtual ~Texture();
void bind() const;
void bind(uint32_t unit = 0) const;
void unbind() const;
inline std::string path() const { return m_path; }

Loading…
Cancel
Save