Browse Source

Pass image as reference, not pointer to *Texture::image().

Avoids some nullptr-related errors.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
87fff877ba
  1. 32
      src/AbstractTexture.cpp
  2. 4
      src/AbstractTexture.h
  3. 8
      src/CubeMapTexture.h
  4. 8
      src/CubeMapTextureArray.h
  5. 6
      src/Texture.h

32
src/AbstractTexture.cpp

@ -949,31 +949,31 @@ void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vec
#ifndef DOXYGEN_GENERATING_OUTPUT
#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 std::size_t dataSize = size.product()*image->pixelSize();
const std::size_t dataSize = size.product()*image.pixelSize();
char* data = new char[dataSize];
(this->*getImageImplementation)(target, level, image->format(), image->type(), dataSize, data);
image->setData(size, image->format(), image->type(), data);
(this->*getImageImplementation)(target, level, image.format(), image.type(), dataSize, data);
image.setData(size, image.format(), image.type(), data);
}
template void AbstractTexture::image<1>(GLenum, GLint, Image<1>*);
template void AbstractTexture::image<2>(GLenum, GLint, Image<2>*);
template void AbstractTexture::image<3>(GLenum, GLint, Image<3>*);
template void AbstractTexture::image<1>(GLenum, GLint, Image<1>&);
template void AbstractTexture::image<2>(GLenum, GLint, Image<2>&);
template void AbstractTexture::image<3>(GLenum, GLint, Image<3>&);
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, BufferImage<dimensions>* image, Buffer::Usage usage) {
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, BufferImage<dimensions>& image, Buffer::Usage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(this, target, level);
const std::size_t dataSize = size.product()*image->pixelSize();
if(image->size() != size)
image->setData(size, image->format(), image->type(), nullptr, usage);
const std::size_t dataSize = size.product()*image.pixelSize();
if(image.size() != size)
image.setData(size, image.format(), image.type(), nullptr, usage);
image->buffer()->bind(Buffer::Target::PixelPack);
(this->*getImageImplementation)(target, level, image->format(), image->type(), dataSize, nullptr);
image.buffer()->bind(Buffer::Target::PixelPack);
(this->*getImageImplementation)(target, level, image.format(), image.type(), dataSize, nullptr);
}
template void AbstractTexture::image<1>(GLenum, GLint, BufferImage<1>*, Buffer::Usage);
template void AbstractTexture::image<2>(GLenum, GLint, BufferImage<2>*, Buffer::Usage);
template void AbstractTexture::image<3>(GLenum, GLint, BufferImage<3>*, Buffer::Usage);
template void AbstractTexture::image<1>(GLenum, GLint, BufferImage<1>&, Buffer::Usage);
template void AbstractTexture::image<2>(GLenum, GLint, BufferImage<2>&, Buffer::Usage);
template void AbstractTexture::image<3>(GLenum, GLint, BufferImage<3>&, Buffer::Usage);
#endif
#endif

4
src/AbstractTexture.h

@ -271,8 +271,8 @@ class MAGNUM_EXPORT AbstractTexture {
void MAGNUM_LOCAL bindInternal();
#ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void image(GLenum target, GLint level, Image<dimensions>* image);
template<UnsignedInt dimensions> void image(GLenum target, GLint level, BufferImage<dimensions>* image, Buffer::Usage usage);
template<UnsignedInt dimensions> void image(GLenum target, GLint level, Image<dimensions>& image);
template<UnsignedInt dimensions> void image(GLenum target, GLint level, BufferImage<dimensions>& image, Buffer::Usage usage);
#endif
GLenum _target;

8
src/CubeMapTexture.h

@ -137,10 +137,10 @@ class CubeMapTexture: public AbstractTexture {
* @param level Mip level
* @param image %Image where to put the data
*
* See Texture::image(Int, Image*) for more information.
* See Texture::image(Int, Image&) for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, Image2D* image) {
void image(Coordinate coordinate, Int level, Image2D& image) {
AbstractTexture::image<2>(GLenum(coordinate), level, image);
}
@ -151,11 +151,11 @@ class CubeMapTexture: public AbstractTexture {
* @param image %Buffer image where to put the data
* @param usage %Buffer usage
*
* See Texture::image(Int, BufferImage*, Buffer::Usage) for more
* See Texture::image(Int, BufferImage&, Buffer::Usage) for more
* information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, BufferImage2D* image, Buffer::Usage usage) {
void image(Coordinate coordinate, Int level, BufferImage2D& image, Buffer::Usage usage) {
AbstractTexture::image<2>(GLenum(coordinate), level, image, usage);
}
#endif

8
src/CubeMapTextureArray.h

@ -138,10 +138,10 @@ class CubeMapTextureArray: public AbstractTexture {
* @param level Mip level
* @param image %Image where to put the data
*
* See Texture::image(Int, Image*) for more information.
* See Texture::image(Int, Image&) for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, Image3D* image) {
void image(Coordinate coordinate, Int level, Image3D& image) {
AbstractTexture::image<3>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level, image);
}
@ -152,11 +152,11 @@ class CubeMapTextureArray: public AbstractTexture {
* @param image %Buffer image where to put the data
* @param usage %Buffer usage
*
* See Texture::image(Int, BufferImage*, Buffer::Usage) for more
* See Texture::image(Int, BufferImage&, Buffer::Usage) for more
* information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, BufferImage3D* image, Buffer::Usage usage) {
void image(Coordinate coordinate, Int level, BufferImage3D& image, Buffer::Usage usage) {
AbstractTexture::image<3>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level, image, usage);
}
#endif

6
src/Texture.h

@ -324,7 +324,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* then @fn_gl{GetTexImage}, @fn_gl_extension{GetTextureImage,EXT,direct_state_access}
* or @fn_gl_extension{GetnTexImage,ARB,robustness}
*/
void image(Int level, Image<dimensions>* image) {
void image(Int level, Image<dimensions>& image) {
AbstractTexture::image<dimensions>(_target, level, image);
}
@ -334,10 +334,10 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @param image %Buffer image where to put the data
* @param usage %Buffer usage
*
* See image(Int, Image*) for more information.
* See image(Int, Image&) for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Int level, BufferImage<dimensions>* image, Buffer::Usage usage) {
void image(Int level, BufferImage<dimensions>& image, Buffer::Usage usage) {
AbstractTexture::image<dimensions>(_target, level, image, usage);
}
#endif

Loading…
Cancel
Save