From 70fa53b949d607f03807922a2f8bee09ad4a4606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 19 Feb 2012 10:29:49 +0100 Subject: [PATCH] Removed unbind() from buffers and textures. It doesn't help with any safety, but just complicates everything and makes unnecessary GL calls. --- src/AbstractTexture.cpp | 2 -- src/AbstractTexture.h | 13 ------------- src/Buffer.h | 6 ------ src/CubeMapTexture.h | 2 -- src/IndexedMesh.cpp | 4 ---- src/Mesh.cpp | 3 --- src/Texture.cpp | 1 - src/Texture.h | 4 ---- 8 files changed, 35 deletions(-) diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index f64d18018..41291b6a8 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -53,7 +53,6 @@ void AbstractTexture::setMinificationFilter(Filter filter, Mipmap mipmap) { bind(); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, static_cast(filter)|static_cast(mipmap)); - unbind(); } void AbstractTexture::generateMipmap() { @@ -61,7 +60,6 @@ void AbstractTexture::generateMipmap() { bind(); glGenerateMipmap(target); - unbind(); } } diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 574212b6f..69e930316 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -147,17 +147,6 @@ class MAGNUM_EXPORT AbstractTexture { glBindTexture(target, texture); } - /** - * @brief Unbind texture - * - * @note Unbinds any texture from given dimension, not only this - * particular one. - */ - inline void unbind() const { - glActiveTexture(GL_TEXTURE0 + _layer); - glBindTexture(target, 0); - } - /** * @brief Set minification filter * @param filter Filter @@ -187,7 +176,6 @@ class MAGNUM_EXPORT AbstractTexture { inline void setMagnificationFilter(Filter filter) { bind(); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, static_cast(filter)); - unbind(); } /** @@ -199,7 +187,6 @@ class MAGNUM_EXPORT AbstractTexture { inline void setBorderColor(const Vector4& color) { bind(); glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, color.data()); - unbind(); } /** diff --git a/src/Buffer.h b/src/Buffer.h index cdf9a62bb..3d473cba7 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -128,11 +128,6 @@ class Buffer { glBindBuffer(_type, buffer); } - /** @brief Unbind buffer */ - inline void unbind() const { - glBindBuffer(_type, 0); - } - /** * @brief Set buffer data * @param size Data size @@ -142,7 +137,6 @@ class Buffer { inline void setData(GLsizeiptr size, const GLvoid* data, Usage usage) { bind(); glBufferData(_type, size, data, usage); - unbind(); } private: diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index a2ce45c90..8f9279a81 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -286,13 +286,11 @@ class CubeMapTexture: public Texture2D { void setData(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, GLenum type, const void* data) { bind(); DataHelper::set(target, mipLevel, internalFormat, _dimensions, colorFormat, type, data); - unbind(); } void setSubData(GLenum target, GLint mipLevel, const Math::Vector& offset, const Math::Vector& dimensions, ColorFormat colorFormat, GLenum type, const void* data) { bind(); DataHelper::setSub(target, mipLevel, offset, dimensions, colorFormat, type, data); - unbind(); } }; diff --git a/src/IndexedMesh.cpp b/src/IndexedMesh.cpp index 6306045f3..98692e83a 100644 --- a/src/IndexedMesh.cpp +++ b/src/IndexedMesh.cpp @@ -46,15 +46,11 @@ void IndexedMesh::draw() { default: glVertexAttribPointer(ait->attribute, ait->size, ait->type, GL_FALSE, ait->stride, ait->pointer); } - - /* Unbind buffer */ - it->first->unbind(); } /* Bind index array, draw the elements and unbind */ _indexBuffer.bind(); glDrawElements(primitive(), _indexCount, _indexType, nullptr); - _indexBuffer.unbind(); /* Disable vertex arrays for all attributes */ for(set::const_iterator it = attributes().begin(); it != attributes().end(); ++it) diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 234e17239..d13ce064d 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -64,9 +64,6 @@ void Mesh::draw() { default: glVertexAttribPointer(ait->attribute, ait->size, ait->type, GL_FALSE, ait->stride, ait->pointer); } - - /* Unbind buffer */ - it->first->unbind(); } glDrawArrays(_primitive, 0, _vertexCount); diff --git a/src/Texture.cpp b/src/Texture.cpp index 18bd57489..358ae7384 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -36,7 +36,6 @@ template void Texture::setWrapping(const Math::Ve break; } } - unbind(); } /* Instantiate all textures */ diff --git a/src/Texture.h b/src/Texture.h index 888d407e2..db6ab1601 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -88,7 +88,6 @@ template class MAGNUM_EXPORT Texture: public AbstractTexture template inline void setData(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { bind(); DataHelper::set(target, mipLevel, internalFormat, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - unbind(); } /** @@ -103,7 +102,6 @@ template class MAGNUM_EXPORT Texture: public AbstractTexture inline void setData(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { bind(); DataHelper::set(target, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); - unbind(); } /** @@ -121,7 +119,6 @@ template class MAGNUM_EXPORT Texture: public AbstractTexture template inline void setSubData(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { bind(); DataHelper::setSub(target, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - unbind(); } /** @@ -136,7 +133,6 @@ template class MAGNUM_EXPORT Texture: public AbstractTexture inline void setSubData(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { bind(); DataHelper::setSub(target, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); - unbind(); } };