added fog (need to set the fog params)
[demo] / src / opengl / texture-gl.cc
index 2fbd05e..80db3ad 100644 (file)
@@ -56,8 +56,19 @@ void TextureGL::update()
        glGenerateMipmap(target);
 }
 
-void TextureGL::bind()
+void TextureGL::bind(int texture_unit)
 {
+       glActiveTexture(GL_TEXTURE0 + texture_unit);
+
        unsigned int target = is_cubemap() ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
        glBindTexture(target, tex);
+
+       //TODO: (not needed for now) if I ever use textures outside the Texture class
+       //glActiveTexture(GL_TEXTURE0);
+}
+
+void TextureGL::unbind()
+{
+       unsigned int target = is_cubemap() ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
+       glBindTexture(target, 0);
 }
\ No newline at end of file