Browse Source

Get rid of pointers in internal texture implementation.

pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
11522ac0cf
  1. 114
      src/Magnum/AbstractTexture.cpp
  2. 48
      src/Magnum/AbstractTexture.h
  3. 18
      src/Magnum/CubeMapTexture.h
  4. 16
      src/Magnum/CubeMapTextureArray.h
  5. 16
      src/Magnum/Texture.h

114
src/Magnum/AbstractTexture.cpp

@ -906,7 +906,7 @@ void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vec
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, Image<dimensions>& image) { template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, Image<dimensions>& image) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(this, target, level); const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, target, level);
const std::size_t dataSize = size.product()*image.pixelSize(); const std::size_t dataSize = size.product()*image.pixelSize();
char* data = new char[dataSize]; char* data = new char[dataSize];
(this->*Context::current()->state().texture->getImageImplementation)(target, level, image.format(), image.type(), dataSize, data); (this->*Context::current()->state().texture->getImageImplementation)(target, level, image.format(), image.type(), dataSize, data);
@ -918,7 +918,7 @@ template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, Image<2>&);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, Image<3>&); template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, Image<3>&);
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, BufferImage<dimensions>& image, BufferUsage usage) { template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, BufferImage<dimensions>& image, BufferUsage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(this, target, level); const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, target, level);
const std::size_t dataSize = size.product()*image.pixelSize(); const std::size_t dataSize = size.product()*image.pixelSize();
if(image.size() != size) if(image.size() != size)
image.setData(image.format(), image.type(), size, nullptr, usage); image.setData(image.format(), image.type(), size, nullptr, usage);
@ -935,162 +935,162 @@ template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, BufferImage
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture* texture, GLenum target, GLint level) { Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) {
Math::Vector<1, GLint> value; Math::Vector<1, GLint> value;
(texture->*Context::current()->state().texture->getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*Context::current()->state().texture->getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
return value; return value;
} }
Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture* texture, GLenum target, GLint level) { Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) {
const Implementation::TextureState& state = *Context::current()->state().texture; const Implementation::TextureState& state = *Context::current()->state().texture;
Vector2i value; Vector2i value;
(texture->*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
(texture->*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]); (texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]);
return value; return value;
} }
Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture* texture, GLenum target, GLint level) { Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) {
const Implementation::TextureState& state = *Context::current()->state().texture; const Implementation::TextureState& state = *Context::current()->state().texture;
Vector3i value; Vector3i value;
(texture->*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
(texture->*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]); (texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]);
(texture->*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_DEPTH, &value[2]); (texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_DEPTH, &value[2]);
return value; return value;
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture* const texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) { void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture& texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) {
(texture->*Context::current()->state().texture->storage1DImplementation)(target, levels, internalFormat, size); (texture.*Context::current()->state().texture->storage1DImplementation)(target, levels, internalFormat, size);
} }
#endif #endif
void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture* const texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
(texture->*Context::current()->state().texture->storage2DImplementation)(target, levels, internalFormat, size); (texture.*Context::current()->state().texture->storage2DImplementation)(target, levels, internalFormat, size);
} }
void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture* const texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) { void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) {
(texture->*Context::current()->state().texture->storage3DImplementation)(target, levels, internalFormat, size); (texture.*Context::current()->state().texture->storage3DImplementation)(target, levels, internalFormat, size);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference1D& image) { void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference1D& image) {
Buffer::unbind(Buffer::Target::PixelUnpack); Buffer::unbind(Buffer::Target::PixelUnpack);
(texture->*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); (texture.*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data());
} }
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) { void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) {
image.buffer().bind(Buffer::Target::PixelUnpack); image.buffer().bind(Buffer::Target::PixelUnpack);
(texture->*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); (texture.*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
} }
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image) { void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image) {
Buffer::unbind(Buffer::Target::PixelUnpack); Buffer::unbind(Buffer::Target::PixelUnpack);
(texture->*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); (texture.*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data());
} }
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) { void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) {
image.buffer().bind(Buffer::Target::PixelUnpack); image.buffer().bind(Buffer::Target::PixelUnpack);
(texture->*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); (texture.*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference2D& image) { void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference2D& image) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbind(Buffer::Target::PixelUnpack); Buffer::unbind(Buffer::Target::PixelUnpack);
#endif #endif
(texture->*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); (texture.*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data());
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) { void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) {
image.buffer().bind(Buffer::Target::PixelUnpack); image.buffer().bind(Buffer::Target::PixelUnpack);
(texture->*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); (texture.*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector2i& offset, const ImageReference2D& image) { void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector2i& offset, const ImageReference2D& image) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbind(Buffer::Target::PixelUnpack); Buffer::unbind(Buffer::Target::PixelUnpack);
#endif #endif
(texture->*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); (texture.*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data());
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector2i& offset, BufferImage2D& image) { void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector2i& offset, BufferImage2D& image) {
image.buffer().bind(Buffer::Target::PixelUnpack); image.buffer().bind(Buffer::Target::PixelUnpack);
(texture->*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); (texture.*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) { void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbind(Buffer::Target::PixelUnpack); Buffer::unbind(Buffer::Target::PixelUnpack);
#endif #endif
(texture->*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); (texture.*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data());
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) { void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) {
image.buffer().bind(Buffer::Target::PixelUnpack); image.buffer().bind(Buffer::Target::PixelUnpack);
(texture->*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); (texture.*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector3i& offset, const ImageReference3D& image) { void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector3i& offset, const ImageReference3D& image) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbind(Buffer::Target::PixelUnpack); Buffer::unbind(Buffer::Target::PixelUnpack);
#endif #endif
(texture->*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); (texture.*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data());
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector3i& offset, BufferImage3D& image) { void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector3i& offset, BufferImage3D& image) {
image.buffer().bind(Buffer::Target::PixelUnpack); image.buffer().bind(Buffer::Target::PixelUnpack);
(texture->*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); (texture.*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::invalidateSubImage(AbstractTexture* const texture, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) { void AbstractTexture::DataHelper<1>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) {
(texture->*Context::current()->state().texture->invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1}); (texture.*Context::current()->state().texture->invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1});
} }
#endif #endif
void AbstractTexture::DataHelper<2>::invalidateSubImage(AbstractTexture* const texture, const GLint level, const Vector2i& offset, const Vector2i& size) { void AbstractTexture::DataHelper<2>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const Vector2i& size) {
(texture->*Context::current()->state().texture->invalidateSubImageImplementation)(level, {offset, 0}, {size, 1}); (texture.*Context::current()->state().texture->invalidateSubImageImplementation)(level, {offset, 0}, {size, 1});
} }
void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture* const texture, const GLint level, const Vector3i& offset, const Vector3i& size) { void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const Vector3i& size) {
(texture->*Context::current()->state().texture->invalidateSubImageImplementation)(level, offset, size); (texture.*Context::current()->state().texture->invalidateSubImageImplementation)(level, offset, size);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture* const texture, const Array1D<Sampler::Wrapping>& wrapping) { void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Array1D<Sampler::Wrapping>& wrapping) {
(texture->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
} }
#endif #endif
void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture* texture, const Array2D<Sampler::Wrapping>& wrapping) { void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Array2D<Sampler::Wrapping>& wrapping) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_ASSERT(texture->_target != GL_TEXTURE_RECTANGLE || ((wrapping.x() == Sampler::Wrapping::ClampToEdge || wrapping.x() == Sampler::Wrapping::ClampToBorder) && (wrapping.y() == Sampler::Wrapping::ClampToEdge || wrapping.y() == Sampler::Wrapping::ClampToBorder)), "Texture2D::setWrapping(): rectangle texture must be clamped to border or to edge", ); CORRADE_ASSERT(texture._target != GL_TEXTURE_RECTANGLE || ((wrapping.x() == Sampler::Wrapping::ClampToEdge || wrapping.x() == Sampler::Wrapping::ClampToBorder) && (wrapping.y() == Sampler::Wrapping::ClampToEdge || wrapping.y() == Sampler::Wrapping::ClampToBorder)), "Texture2D::setWrapping(): rectangle texture must be clamped to border or to edge", );
#endif #endif
const Implementation::TextureState& state = *Context::current()->state().texture; const Implementation::TextureState& state = *Context::current()->state().texture;
(texture->*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
(texture->*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
} }
void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture* texture, const Array3D<Sampler::Wrapping>& wrapping) { void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Array3D<Sampler::Wrapping>& wrapping) {
const Implementation::TextureState& state = *Context::current()->state().texture; const Implementation::TextureState& state = *Context::current()->state().texture;
(texture->*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
(texture->*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
(texture->*state.parameteriImplementation)(GL_TEXTURE_WRAP_R, GLint(wrapping.z())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_R, GLint(wrapping.z()));
#endif #endif
} }
#endif #endif

48
src/Magnum/AbstractTexture.h

@ -451,19 +451,19 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> {
constexpr static Target target() { return Target::Texture1D; } constexpr static Target target() { return Target::Texture1D; }
static Math::Vector<1, GLint> imageSize(AbstractTexture* texture, GLenum target, GLint level); static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLenum target, GLint level);
static void setWrapping(AbstractTexture* texture, const Array1D<Sampler::Wrapping>& wrapping); static void setWrapping(AbstractTexture& texture, const Array1D<Sampler::Wrapping>& wrapping);
static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); static void setStorage(AbstractTexture& texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
static void setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference1D& image); static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference1D& image);
static void setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage1D& image); static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage1D& image);
static void setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image); static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image);
static void setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image); static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image);
static void invalidateSubImage(AbstractTexture* texture, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size); static void invalidateSubImage(AbstractTexture& texture, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size);
}; };
#endif #endif
template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> {
@ -479,24 +479,24 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> {
constexpr static Target target() { return Target::Texture2D; } constexpr static Target target() { return Target::Texture2D; }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
static Vector2i imageSize(AbstractTexture* texture, GLenum target, GLint level); static Vector2i imageSize(AbstractTexture& texture, GLenum target, GLint level);
#endif #endif
static void setWrapping(AbstractTexture* texture, const Array2D<Sampler::Wrapping>& wrapping); static void setWrapping(AbstractTexture& texture, const Array2D<Sampler::Wrapping>& wrapping);
static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); static void setStorage(AbstractTexture& texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
static void setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference2D& image); static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference2D& image);
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
static void setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage2D& image); static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage2D& image);
#endif #endif
static void setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector2i& offset, const ImageReference2D& image); static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Vector2i& offset, const ImageReference2D& image);
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
static void setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector2i& offset, BufferImage2D& image); static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Vector2i& offset, BufferImage2D& image);
#endif #endif
static void invalidateSubImage(AbstractTexture* texture, GLint level, const Vector2i& offset, const Vector2i& size); static void invalidateSubImage(AbstractTexture& texture, GLint level, const Vector2i& offset, const Vector2i& size);
}; };
template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> {
enum class Target: GLenum { enum class Target: GLenum {
@ -514,24 +514,24 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> {
constexpr static Target target() { return Target::Texture3D; } constexpr static Target target() { return Target::Texture3D; }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
static Vector3i imageSize(AbstractTexture* texture, GLenum target, GLint level); static Vector3i imageSize(AbstractTexture& texture, GLenum target, GLint level);
#endif #endif
static void setWrapping(AbstractTexture* texture, const Array3D<Sampler::Wrapping>& wrapping); static void setWrapping(AbstractTexture& texture, const Array3D<Sampler::Wrapping>& wrapping);
static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); static void setStorage(AbstractTexture& texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
static void setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference3D& image); static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference3D& image);
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
static void setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage3D& image); static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage3D& image);
#endif #endif
static void setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector3i& offset, const ImageReference3D& image); static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Vector3i& offset, const ImageReference3D& image);
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
static void setSubImage(AbstractTexture* texture, GLenum target, GLint level, const Vector3i& offset, BufferImage3D& image); static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Vector3i& offset, BufferImage3D& image);
#endif #endif
static void invalidateSubImage(AbstractTexture* texture, GLint level, const Vector3i& offset, const Vector3i& size); static void invalidateSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, const Vector3i& size);
}; };
#endif #endif

18
src/Magnum/CubeMapTexture.h

@ -103,7 +103,7 @@ class CubeMapTexture: public AbstractTexture {
* See @ref Texture::setWrapping() for more information. * See @ref Texture::setWrapping() for more information.
*/ */
CubeMapTexture& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) { CubeMapTexture& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) {
DataHelper<3>::setWrapping(this, wrapping); DataHelper<3>::setWrapping(*this, wrapping);
return *this; return *this;
} }
@ -117,7 +117,7 @@ class CubeMapTexture: public AbstractTexture {
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gl %Texture image queries are not available in OpenGL ES.
*/ */
Vector2i imageSize(Coordinate coordinate, Int level) { Vector2i imageSize(Coordinate coordinate, Int level) {
return DataHelper<2>::imageSize(this, GLenum(coordinate), level); return DataHelper<2>::imageSize(*this, GLenum(coordinate), level);
} }
#endif #endif
@ -127,7 +127,7 @@ class CubeMapTexture: public AbstractTexture {
* See @ref Texture::setStorage() for more information. * See @ref Texture::setStorage() for more information.
*/ */
CubeMapTexture& setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) { CubeMapTexture& setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) {
DataHelper<2>::setStorage(this, _target, levels, internalFormat, size); DataHelper<2>::setStorage(*this, _target, levels, internalFormat, size);
return *this; return *this;
} }
@ -173,14 +173,14 @@ class CubeMapTexture: public AbstractTexture {
* See @ref Texture::setImage() for more information. * See @ref Texture::setImage() for more information.
*/ */
CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageReference2D& image) { CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageReference2D& image) {
DataHelper<2>::setImage(this, GLenum(coordinate), level, internalFormat, image); DataHelper<2>::setImage(*this, GLenum(coordinate), level, internalFormat, image);
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/** @overload */ /** @overload */
CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, BufferImage2D& image) { CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, BufferImage2D& image) {
DataHelper<2>::setImage(this, GLenum(coordinate), level, internalFormat, image); DataHelper<2>::setImage(*this, GLenum(coordinate), level, internalFormat, image);
return *this; return *this;
} }
@ -202,20 +202,20 @@ class CubeMapTexture: public AbstractTexture {
* See @ref Texture::setSubImage() for more information. * See @ref Texture::setSubImage() for more information.
*/ */
CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const ImageReference2D& image) { CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const ImageReference2D& image) {
DataHelper<2>::setSubImage(this, GLenum(coordinate), level, offset, image); DataHelper<2>::setSubImage(*this, GLenum(coordinate), level, offset, image);
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/** @overload */ /** @overload */
CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D& image) { CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D& image) {
DataHelper<2>::setSubImage(this, GLenum(coordinate), level, offset, image); DataHelper<2>::setSubImage(*this, GLenum(coordinate), level, offset, image);
return *this; return *this;
} }
/** @overload */ /** @overload */
CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D&& image) { CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D&& image) {
DataHelper<2>::setSubImage(this, GLenum(coordinate), level, offset, image); DataHelper<2>::setSubImage(*this, GLenum(coordinate), level, offset, image);
return *this; return *this;
} }
#endif #endif
@ -233,7 +233,7 @@ class CubeMapTexture: public AbstractTexture {
* See @ref Texture::invalidateSubImage() for more information. * See @ref Texture::invalidateSubImage() for more information.
*/ */
void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) { void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) {
DataHelper<3>::invalidateSubImage(this, level, offset, size); DataHelper<3>::invalidateSubImage(*this, level, offset, size);
} }
/* Overloads to remove WTF-factor from method chaining order */ /* Overloads to remove WTF-factor from method chaining order */

16
src/Magnum/CubeMapTextureArray.h

@ -94,7 +94,7 @@ class CubeMapTextureArray: public AbstractTexture {
* See @ref Texture::setWrapping() for more information. * See @ref Texture::setWrapping() for more information.
*/ */
CubeMapTextureArray& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) { CubeMapTextureArray& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) {
DataHelper<3>::setWrapping(this, wrapping); DataHelper<3>::setWrapping(*this, wrapping);
return *this; return *this;
} }
@ -105,7 +105,7 @@ class CubeMapTextureArray: public AbstractTexture {
* See @ref Texture::imageSize() for more information. * See @ref Texture::imageSize() for more information.
*/ */
Vector3i imageSize(Int level) { Vector3i imageSize(Int level) {
return DataHelper<3>::imageSize(this, GL_TEXTURE_CUBE_MAP_ARRAY, level); return DataHelper<3>::imageSize(*this, GL_TEXTURE_CUBE_MAP_ARRAY, level);
} }
/** /**
@ -115,7 +115,7 @@ class CubeMapTextureArray: public AbstractTexture {
* @ref Texture::setStorage() for more information. * @ref Texture::setStorage() for more information.
*/ */
CubeMapTextureArray& setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) { CubeMapTextureArray& setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) {
DataHelper<3>::setStorage(this, _target, levels, internalFormat, size); DataHelper<3>::setStorage(*this, _target, levels, internalFormat, size);
return *this; return *this;
} }
@ -163,13 +163,13 @@ class CubeMapTextureArray: public AbstractTexture {
* See @ref Texture::setImage() for more information. * See @ref Texture::setImage() for more information.
*/ */
CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, const ImageReference3D& image) { CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, const ImageReference3D& image) {
DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image); DataHelper<3>::setImage(*this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image);
return *this; return *this;
} }
/** @overload */ /** @overload */
CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, BufferImage3D& image) { CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, BufferImage3D& image) {
DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image); DataHelper<3>::setImage(*this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image);
return *this; return *this;
} }
@ -192,13 +192,13 @@ class CubeMapTextureArray: public AbstractTexture {
* See @ref Texture::setSubImage() for more information. * See @ref Texture::setSubImage() for more information.
*/ */
CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, const ImageReference3D& image) { CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, const ImageReference3D& image) {
DataHelper<3>::setSubImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, offset, image); DataHelper<3>::setSubImage(*this, GL_TEXTURE_CUBE_MAP_ARRAY, level, offset, image);
return *this; return *this;
} }
/** @overload */ /** @overload */
CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, BufferImage3D& image) { CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, BufferImage3D& image) {
DataHelper<3>::setSubImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, offset, image); DataHelper<3>::setSubImage(*this, GL_TEXTURE_CUBE_MAP_ARRAY, level, offset, image);
return *this; return *this;
} }
@ -219,7 +219,7 @@ class CubeMapTextureArray: public AbstractTexture {
* See @ref Texture::invalidateSubImage() for more information. * See @ref Texture::invalidateSubImage() for more information.
*/ */
void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) { void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) {
DataHelper<3>::invalidateSubImage(this, level, offset, size); DataHelper<3>::invalidateSubImage(*this, level, offset, size);
} }
/* Overloads to remove WTF-factor from method chaining order */ /* Overloads to remove WTF-factor from method chaining order */

16
src/Magnum/Texture.h

@ -246,7 +246,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gl %Texture image queries are not available in OpenGL ES.
*/ */
typename DimensionTraits<Dimensions, Int>::VectorType imageSize(Int level) { typename DimensionTraits<Dimensions, Int>::VectorType imageSize(Int level) {
return DataHelper<Dimensions>::imageSize(this, _target, level); return DataHelper<Dimensions>::imageSize(*this, _target, level);
} }
#endif #endif
@ -268,7 +268,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @def_gl{TEXTURE_WRAP_R} * @def_gl{TEXTURE_WRAP_R}
*/ */
Texture<Dimensions>& setWrapping(const Array<Dimensions, Sampler::Wrapping>& wrapping) { Texture<Dimensions>& setWrapping(const Array<Dimensions, Sampler::Wrapping>& wrapping) {
DataHelper<Dimensions>::setWrapping(this, wrapping); DataHelper<Dimensions>::setWrapping(*this, wrapping);
return *this; return *this;
} }
@ -301,7 +301,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl_extension{TextureImage3D,EXT,direct_state_access}. * @fn_gl_extension{TextureImage3D,EXT,direct_state_access}.
*/ */
Texture<Dimensions>& setStorage(Int levels, TextureFormat internalFormat, const typename DimensionTraits<Dimensions, Int>::VectorType& size) { Texture<Dimensions>& setStorage(Int levels, TextureFormat internalFormat, const typename DimensionTraits<Dimensions, Int>::VectorType& size) {
DataHelper<Dimensions>::setStorage(this, _target, levels, internalFormat, size); DataHelper<Dimensions>::setStorage(*this, _target, levels, internalFormat, size);
return *this; return *this;
} }
@ -368,14 +368,14 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl_extension{TextureImage3D,EXT,direct_state_access} * @fn_gl_extension{TextureImage3D,EXT,direct_state_access}
*/ */
Texture<Dimensions>& setImage(Int level, TextureFormat internalFormat, const ImageReference<dimensions>& image) { Texture<Dimensions>& setImage(Int level, TextureFormat internalFormat, const ImageReference<dimensions>& image) {
DataHelper<Dimensions>::setImage(this, _target, level, internalFormat, image); DataHelper<Dimensions>::setImage(*this, _target, level, internalFormat, image);
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/** @overload */ /** @overload */
Texture<Dimensions>& setImage(Int level, TextureFormat internalFormat, BufferImage<dimensions>& image) { Texture<Dimensions>& setImage(Int level, TextureFormat internalFormat, BufferImage<dimensions>& image) {
DataHelper<Dimensions>::setImage(this, _target, level, internalFormat, image); DataHelper<Dimensions>::setImage(*this, _target, level, internalFormat, image);
return *this; return *this;
} }
@ -403,14 +403,14 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access} * @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access}
*/ */
Texture<Dimensions>& setSubImage(Int level, const typename DimensionTraits<Dimensions, Int>::VectorType& offset, const ImageReference<dimensions>& image) { Texture<Dimensions>& setSubImage(Int level, const typename DimensionTraits<Dimensions, Int>::VectorType& offset, const ImageReference<dimensions>& image) {
DataHelper<Dimensions>::setSubImage(this, _target, level, offset, image); DataHelper<Dimensions>::setSubImage(*this, _target, level, offset, image);
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/** @overload */ /** @overload */
Texture<Dimensions>& setSubImage(Int level, const typename DimensionTraits<Dimensions, Int>::VectorType& offset, BufferImage<dimensions>& image) { Texture<Dimensions>& setSubImage(Int level, const typename DimensionTraits<Dimensions, Int>::VectorType& offset, BufferImage<dimensions>& image) {
DataHelper<Dimensions>::setSubImage(this, _target, level, offset, image); DataHelper<Dimensions>::setSubImage(*this, _target, level, offset, image);
return *this; return *this;
} }
@ -431,7 +431,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @see @ref invalidateImage(), @fn_gl{InvalidateTexSubImage} * @see @ref invalidateImage(), @fn_gl{InvalidateTexSubImage}
*/ */
void invalidateSubImage(Int level, const typename DimensionTraits<Dimensions, Int>::VectorType& offset, const typename DimensionTraits<Dimensions, Int>::VectorType& size) { void invalidateSubImage(Int level, const typename DimensionTraits<Dimensions, Int>::VectorType& offset, const typename DimensionTraits<Dimensions, Int>::VectorType& size) {
DataHelper<dimensions>::invalidateSubImage(this, level, offset, size); DataHelper<dimensions>::invalidateSubImage(*this, level, offset, size);
} }
/* Overloads to remove WTF-factor from method chaining order */ /* Overloads to remove WTF-factor from method chaining order */

Loading…
Cancel
Save