|
|
|
|
@ -60,7 +60,13 @@ void CubeMapTexture::image(const Int level, Image3D& image) {
|
|
|
|
|
createIfNotAlready(); |
|
|
|
|
|
|
|
|
|
const Vector3i size{imageSize(level), 6}; |
|
|
|
|
Containers::Array<char> data{Implementation::imageDataSizeFor(image, size)}; |
|
|
|
|
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); |
|
|
|
|
|
|
|
|
|
/* Reallocate only if needed */ |
|
|
|
|
Containers::Array<char> data{image.release()}; |
|
|
|
|
if(data.size() < dataSize) |
|
|
|
|
data = Containers::Array<char>{dataSize}; |
|
|
|
|
|
|
|
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); |
|
|
|
|
glGetTextureImage(_id, level, GLenum(image.format()), GLenum(image.type()), data.size(), data); |
|
|
|
|
image.setData(image.storage(), image.format(), image.type(), size, std::move(data)); |
|
|
|
|
@ -76,8 +82,12 @@ void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUs
|
|
|
|
|
|
|
|
|
|
const Vector3i size{imageSize(level), 6}; |
|
|
|
|
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); |
|
|
|
|
if(image.size() != size) |
|
|
|
|
|
|
|
|
|
/* Reallocate only if needed */ |
|
|
|
|
if(image.dataSize() < dataSize) |
|
|
|
|
image.setData(image.storage(), image.format(), image.type(), size, {nullptr, dataSize}, usage); |
|
|
|
|
else |
|
|
|
|
image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage); |
|
|
|
|
|
|
|
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); |
|
|
|
|
glGetTextureImage(_id, level, GLenum(image.format()), GLenum(image.type()), dataSize, nullptr); |
|
|
|
|
@ -97,10 +107,14 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image)
|
|
|
|
|
const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); |
|
|
|
|
GLint format; |
|
|
|
|
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); |
|
|
|
|
Containers::Array<char> data{dataSize}; |
|
|
|
|
|
|
|
|
|
/* Reallocate only if needed */ |
|
|
|
|
Containers::Array<char> data{image.release()}; |
|
|
|
|
if(data.size() < dataSize) |
|
|
|
|
data = Containers::Array<char>{dataSize}; |
|
|
|
|
|
|
|
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); |
|
|
|
|
glGetCompressedTextureImage(_id, level, dataSize, data); |
|
|
|
|
glGetCompressedTextureImage(_id, level, data.size(), data); |
|
|
|
|
image.setData(image.storage(), CompressedPixelFormat(format), size, std::move(data)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -119,8 +133,13 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i
|
|
|
|
|
GLint format; |
|
|
|
|
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); |
|
|
|
|
|
|
|
|
|
/* Reallocate only if needed */ |
|
|
|
|
if(image.dataSize() < dataSize) |
|
|
|
|
image.setData(image.storage(), CompressedPixelFormat(format), size, {nullptr, dataSize}, usage); |
|
|
|
|
else |
|
|
|
|
image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); |
|
|
|
|
|
|
|
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); |
|
|
|
|
image.setData(image.storage(), CompressedPixelFormat(format), size, {nullptr, dataSize}, usage); |
|
|
|
|
glGetCompressedTextureImage(_id, level, dataSize, nullptr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -131,7 +150,12 @@ CompressedBufferImage3D CubeMapTexture::compressedImage(const Int level, Compres
|
|
|
|
|
|
|
|
|
|
void CubeMapTexture::image(const Coordinate coordinate, const Int level, Image2D& image) { |
|
|
|
|
const Vector2i size = imageSize(level); |
|
|
|
|
Containers::Array<char> data{Implementation::imageDataSizeFor(image, size)}; |
|
|
|
|
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); |
|
|
|
|
|
|
|
|
|
/* Reallocate only if needed */ |
|
|
|
|
Containers::Array<char> data{image.release()}; |
|
|
|
|
if(data.size() < dataSize) |
|
|
|
|
data = Containers::Array<char>{dataSize}; |
|
|
|
|
|
|
|
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); |
|
|
|
|
(this->*Context::current()->state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), data.size(), data); |
|
|
|
|
@ -146,8 +170,12 @@ Image2D CubeMapTexture::image(const Coordinate coordinate, const Int level, Imag
|
|
|
|
|
void CubeMapTexture::image(const Coordinate coordinate, const Int level, BufferImage2D& image, const BufferUsage usage) { |
|
|
|
|
const Vector2i size = imageSize(level); |
|
|
|
|
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); |
|
|
|
|
if(image.size() != size) |
|
|
|
|
|
|
|
|
|
/* Reallocate only if needed */ |
|
|
|
|
if(image.dataSize() < dataSize) |
|
|
|
|
image.setData(image.storage(), image.format(), image.type(), size, {nullptr, dataSize}, usage); |
|
|
|
|
else |
|
|
|
|
image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage); |
|
|
|
|
|
|
|
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); |
|
|
|
|
(this->*Context::current()->state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), dataSize, nullptr); |
|
|
|
|
@ -162,9 +190,14 @@ void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int leve
|
|
|
|
|
const Vector2i size = imageSize(level); |
|
|
|
|
GLint textureDataSize; |
|
|
|
|
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); |
|
|
|
|
const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); |
|
|
|
|
GLint format; |
|
|
|
|
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); |
|
|
|
|
Containers::Array<char> data{Implementation::compressedImageDataSizeFor(image, size, textureDataSize)}; |
|
|
|
|
|
|
|
|
|
/* Reallocate only if needed */ |
|
|
|
|
Containers::Array<char> data{image.release()}; |
|
|
|
|
if(data.size() < dataSize) |
|
|
|
|
data = Containers::Array<char>{dataSize}; |
|
|
|
|
|
|
|
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); |
|
|
|
|
(this->*Context::current()->state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), data); |
|
|
|
|
@ -184,7 +217,12 @@ void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int leve
|
|
|
|
|
GLint format; |
|
|
|
|
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); |
|
|
|
|
|
|
|
|
|
image.setData(image.storage(), CompressedPixelFormat(format), size, {nullptr, dataSize}, usage); |
|
|
|
|
/* Reallocate only if needed */ |
|
|
|
|
if(image.dataSize() < dataSize) |
|
|
|
|
image.setData(image.storage(), CompressedPixelFormat(format), size, {nullptr, dataSize}, usage); |
|
|
|
|
else |
|
|
|
|
image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); |
|
|
|
|
|
|
|
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); |
|
|
|
|
(this->*Context::current()->state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, nullptr); |
|
|
|
|
} |
|
|
|
|
|