Browse Source

Removed support for setting texture data directly.

Texture data can be now set only using image classes (Image,
BufferedImage, Trade::ImageData).
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
11f4f0a500
  1. 72
      src/AbstractTexture.h
  2. 20
      src/CubeMapTexture.h
  3. 33
      src/Texture.h

72
src/AbstractTexture.h

@ -472,25 +472,11 @@ class MAGNUM_EXPORT AbstractTexture {
* @param target %Target
* @param mipLevel Mip level
* @param internalFormat Internal texture format
* @param dimensions %Texture dimensions
* @param colorFormat Color format of passed data
* @param type Data type
* @param data %Texture data
*
* Calls `glTexImage1D`, `glTexImage2D`, `glTexImage3D` depending
* on dimension count.
*/
inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector<GLsizei, textureDimensions>& dimensions, ColorFormat colorFormat, Type type, const void* data);
/**
* @brief Set texture data from image
* @param target %Target
* @param mipLevel Mip level
* @param internalFormat Internal texture format
* @param image Image, BufferedImage or for example
* Trade::ImageData of the same dimension count
*
* Calls set() with image data.
* Calls `glTexImage1D`, `glTexImage2D`, `glTexImage3D` depending
* on dimension count.
*/
template<class T> inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, T* image);
@ -499,25 +485,11 @@ class MAGNUM_EXPORT AbstractTexture {
* @param target %Target
* @param mipLevel Mip level
* @param offset Offset where to put data in the texture
* @param dimensions %Texture dimensions
* @param colorFormat Color format of passed data
* @param type Data type
* @param data %Texture data
*
* Calls `glTexSubImage1D`, `glTexSubImage2D`, `glTexSubImage3D`
* depending on dimension count.
*/
inline static void setSub(SubTarget target, GLint mipLevel, const Math::Vector<GLint, textureDimensions>& offset, const Math::Vector<GLsizei, textureDimensions>& dimensions, ColorFormat colorFormat, Type type, const void* data);
/**
* @brief Set texture subdata from image
* @param target %Target
* @param mipLevel Mip level
* @param offset Offset where to put data in the texture
* @param image Image, BufferedImage or for example
* Trade::ImageData of the same dimension count
*
* Calls setSub() with image data.
* Calls `glTexSubImage1D`, `glTexSubImage2D`, `glTexSubImage3D`
* depending on dimension count.
*/
template<class T> inline static void setSub(Target target, GLint mipLevel, const Math::Vector<GLint, textureDimensions>& offset, T* image);
#endif
@ -581,20 +553,12 @@ template<> struct AbstractTexture::DataHelper<1> {
glTexParameteri(static_cast<GLenum>(target), GL_TEXTURE_WRAP_S, static_cast<GLint>(wrapping.at(0)));
}
inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector<GLsizei, 1>& dimensions, ColorFormat colorFormat, Type type, const void* data) {
glTexImage1D(static_cast<GLenum>(target), mipLevel, internalFormat, dimensions.at(0), 0, static_cast<GLenum>(colorFormat), static_cast<GLenum>(type), data);
}
template<class T> inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, T* image) {
set(target, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data());
}
inline static void setSub(Target target, GLint mipLevel, const Math::Vector<GLint, 1>& offset, const Math::Vector<GLsizei, 1>& dimensions, ColorFormat colorFormat, Type type, const void* data) {
glTexSubImage1D(static_cast<GLenum>(target), mipLevel, offset.at(0), dimensions.at(0), static_cast<GLenum>(colorFormat), static_cast<GLenum>(type), data);
glTexImage1D(static_cast<GLenum>(target), mipLevel, internalFormat, image->dimensions().at(0), 0, static_cast<GLenum>(image->colorFormat()), static_cast<GLenum>(image->type()), image->data());
}
template<class T> inline static void setSub(Target target, GLint mipLevel, const Math::Vector<GLint, 1>& offset, T* image) {
setSub(target, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data());
glTexSubImage1D(static_cast<GLenum>(target), mipLevel, offset.at(0), image->dimensions().at(0), static_cast<GLenum>(image->colorFormat()), static_cast<GLenum>(image->type()), image->data());
}
};
template<> struct AbstractTexture::DataHelper<2> {
@ -618,20 +582,12 @@ template<> struct AbstractTexture::DataHelper<2> {
glTexParameteri(static_cast<GLenum>(target), GL_TEXTURE_WRAP_T, static_cast<GLint>(wrapping.at(1)));
}
inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector<GLsizei, 2>& dimensions, ColorFormat colorFormat, Type type, const void* data) {
glTexImage2D(static_cast<GLenum>(target), mipLevel, internalFormat, dimensions.at(0), dimensions.at(1), 0, static_cast<GLenum>(colorFormat), static_cast<GLenum>(type), data);
}
template<class T> inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, T* image) {
set(target, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data());
}
inline static void setSub(Target target, GLint mipLevel, const Math::Vector<GLint, 2>& offset, const Math::Vector<GLsizei, 2>& dimensions, ColorFormat colorFormat, Type type, const void* data) {
glTexSubImage2D(static_cast<GLenum>(target), mipLevel, offset.at(0), offset.at(1), dimensions.at(0), dimensions.at(1), static_cast<GLenum>(colorFormat), static_cast<GLenum>(type), data);
glTexImage2D(static_cast<GLenum>(target), mipLevel, internalFormat, image->dimensions().at(0), image->dimensions().at(1), 0, static_cast<GLenum>(image->colorFormat()), static_cast<GLenum>(image->type()), image->data());
}
template<class T> inline static void setSub(Target target, GLint mipLevel, const Math::Vector<GLint, 2>& offset, T* image) {
setSub(target, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data());
glTexSubImage2D(static_cast<GLenum>(target), mipLevel, offset.at(0), offset.at(1), image->dimensions().at(0), image->dimensions().at(1), static_cast<GLenum>(image->colorFormat()), static_cast<GLenum>(image->type()), image->data());
}
};
template<> struct AbstractTexture::DataHelper<3> {
@ -648,20 +604,12 @@ template<> struct AbstractTexture::DataHelper<3> {
glTexParameteri(static_cast<GLenum>(target), GL_TEXTURE_WRAP_R, static_cast<GLint>(wrapping.at(2)));
}
inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector<GLsizei, 3>& dimensions, ColorFormat colorFormat, Type type, const void* data) {
glTexImage3D(static_cast<GLenum>(target), mipLevel, internalFormat, dimensions.at(0), dimensions.at(1), dimensions.at(2), 0, static_cast<GLenum>(colorFormat), static_cast<GLenum>(type), data);
}
template<class T> inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, T* image) {
set(target, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data());
}
inline static void setSub(Target target, GLint mipLevel, const Math::Vector<GLint, 3>& offset, const Math::Vector<GLsizei, 3>& dimensions, ColorFormat colorFormat, Type type, const void* data) {
glTexSubImage3D(static_cast<GLenum>(target), mipLevel, offset.at(0), offset.at(1), offset.at(2), dimensions.at(0), dimensions.at(1), dimensions.at(2), static_cast<GLenum>(colorFormat), static_cast<GLenum>(type), data);
glTexImage3D(static_cast<GLenum>(target), mipLevel, internalFormat, image->dimensions().at(0), image->dimensions().at(1), image->dimensions().at(2), 0, static_cast<GLenum>(image->colorFormat()), static_cast<GLenum>(image->type()), image->data());
}
template<class T> inline static void setSub(Target target, GLint mipLevel, const Math::Vector<GLint, 3>& offset, T* image) {
setSub(target, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data());
glTexSubImage3D(static_cast<GLenum>(target), mipLevel, offset.at(0), offset.at(1), offset.at(2), image->dimensions().at(0), image->dimensions().at(1), image->dimensions().at(2), static_cast<GLenum>(image->colorFormat()), static_cast<GLenum>(image->type()), image->data());
}
};
#endif

20
src/CubeMapTexture.h

@ -64,20 +64,9 @@ class CubeMapTexture: public Texture2D {
*/
inline CubeMapTexture(GLint layer = 0): Texture(layer, Target::CubeMap) {}
template<class T> inline void setData(GLint mipLevel, InternalFormat internalFormat, const Math::Vector<GLsizei, Dimensions>& dimensions, ColorFormat colorFormat, const T* data) = delete;
template<class T> void setData(GLint mipLevel, InternalFormat internalFormat, T* image) = delete;
template<class T> inline void setSubData(GLint mipLevel, const Math::Vector<GLint, Dimensions>& offset, const Math::Vector<GLsizei, Dimensions>& dimensions, ColorFormat colorFormat, const T* data) = delete;
template<class T> void setSubData(GLint mipLevel, const Math::Vector<GLint, Dimensions>& offset, T* image) = delete;
/**
* @copydoc Texture::setData(GLint, InternalFormat, const Math::Vector<GLsizei, Dimensions>&, ColorFormat, const T*)
* @param coordinate Coordinate
*/
template<class T> inline void setData(Coordinate coordinate, GLint mipLevel, InternalFormat internalFormat, const Math::Vector<GLsizei, Dimensions>& dimensions, ColorFormat colorFormat, const T* data) {
bind();
DataHelper<Dimensions>::set(static_cast<Target>(coordinate), mipLevel, internalFormat, dimensions, colorFormat, TypeTraits<typename TypeTraits<T>::TextureType>::glType(), data);
}
/**
* @copydetails Texture::setData(GLint, InternalFormat, T*)
* @param coordinate Coordinate
@ -87,15 +76,6 @@ class CubeMapTexture: public Texture2D {
DataHelper<Dimensions>::set(static_cast<Target>(coordinate), mipLevel, internalFormat, image);
}
/**
* @copydoc Texture::setSubData(GLint, const Math::Vector<GLint, Dimensions>&, const Math::Vector<GLsizei, Dimensions>&, ColorFormat, const T*)
* @param coordinate Coordinate
*/
template<class T> inline void setSubData(Coordinate coordinate, GLint mipLevel, const Math::Vector<GLint, Dimensions>& offset, const Math::Vector<GLsizei, Dimensions>& dimensions, ColorFormat colorFormat, const T* data) {
bind();
DataHelper<Dimensions>::setSub(static_cast<Target>(coordinate), mipLevel, offset, dimensions, colorFormat, TypeTraits<typename TypeTraits<T>::TextureType>::glType(), data);
}
/**
* @copydoc Texture::setSubData(GLint, const Math::Vector<GLint, Dimensions>&, T*)
* @param coordinate Coordinate

33
src/Texture.h

@ -82,22 +82,6 @@ template<size_t textureDimensions> class Texture: public AbstractTexture {
* @brief Set texture data
* @param mipLevel Mip level
* @param internalFormat Internal texture format
* @param dimensions %Texture dimensions
* @param colorFormat Color format of passed data. Data size per
* color channel is detected from format of passed data array.
* @param data %Texture data
*
* Sets texture from given data. The data are not deleted afterwards.
*/
template<class T> inline void setData(GLint mipLevel, InternalFormat internalFormat, const Math::Vector<GLsizei, Dimensions>& dimensions, ColorFormat colorFormat, const T* data) {
bind();
DataHelper<Dimensions>::set(_target, mipLevel, internalFormat, dimensions, colorFormat, TypeTraits<typename TypeTraits<T>::TextureType>::glType(), data);
}
/**
* @brief Set texture data from image
* @param mipLevel Mip level
* @param internalFormat Internal texture format
* @param image Image, BufferedImage or for example
* Trade::ImageData of the same dimension count
*
@ -113,23 +97,6 @@ template<size_t textureDimensions> class Texture: public AbstractTexture {
* @brief Set texture subdata
* @param mipLevel Mip level
* @param offset Offset where to put data in the texture
* @param dimensions %Texture dimensions
* @param colorFormat Color format of passed data. Data size per
* color channel is detected from format of passed data array.
* @param data %Texture data
*
* Sets texture subdata from given data. The data are not deleted
* afterwards.
*/
template<class T> inline void setSubData(GLint mipLevel, const Math::Vector<GLint, Dimensions>& offset, const Math::Vector<GLsizei, Dimensions>& dimensions, ColorFormat colorFormat, const T* data) {
bind();
DataHelper<Dimensions>::setSub(_target, mipLevel, offset, dimensions, colorFormat, TypeTraits<typename TypeTraits<T>::TextureType>::glType(), data);
}
/**
* @brief Set texture subdata from image
* @param mipLevel Mip level
* @param offset Offset where to put data in the texture
* @param image Image, BufferedImage or for example
* Trade::ImageData of the same dimension count
*

Loading…
Cancel
Save