mirror of https://github.com/mosra/magnum.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1135 lines
46 KiB
1135 lines
46 KiB
|
15 years ago
|
/*
|
||
|
|
This file is part of Magnum.
|
||
|
|
|
||
|
13 years ago
|
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
|
||
|
|
|
||
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||
|
|
copy of this software and associated documentation files (the "Software"),
|
||
|
|
to deal in the Software without restriction, including without limitation
|
||
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
||
|
|
Software is furnished to do so, subject to the following conditions:
|
||
|
|
|
||
|
|
The above copyright notice and this permission notice shall be included
|
||
|
|
in all copies or substantial portions of the Software.
|
||
|
15 years ago
|
|
||
|
13 years ago
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||
|
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||
|
|
DEALINGS IN THE SOFTWARE.
|
||
|
15 years ago
|
*/
|
||
|
|
|
||
|
|
#include "AbstractTexture.h"
|
||
|
|
|
||
|
13 years ago
|
#include "BufferImage.h"
|
||
|
13 years ago
|
#include "ColorFormat.h"
|
||
|
14 years ago
|
#include "Context.h"
|
||
|
14 years ago
|
#include "Extensions.h"
|
||
|
13 years ago
|
#include "Image.h"
|
||
|
13 years ago
|
#include "Shader.h"
|
||
|
13 years ago
|
#include "TextureFormat.h"
|
||
|
13 years ago
|
#include "Implementation/DebugState.h"
|
||
|
14 years ago
|
#include "Implementation/State.h"
|
||
|
|
#include "Implementation/TextureState.h"
|
||
|
|
|
||
|
15 years ago
|
namespace Magnum {
|
||
|
|
|
||
|
14 years ago
|
AbstractTexture::BindImplementation AbstractTexture::bindImplementation =
|
||
|
|
&AbstractTexture::bindImplementationDefault;
|
||
|
|
AbstractTexture::ParameteriImplementation AbstractTexture::parameteriImplementation =
|
||
|
|
&AbstractTexture::parameterImplementationDefault;
|
||
|
|
AbstractTexture::ParameterfImplementation AbstractTexture::parameterfImplementation =
|
||
|
|
&AbstractTexture::parameterImplementationDefault;
|
||
|
|
AbstractTexture::ParameterfvImplementation AbstractTexture::parameterfvImplementation =
|
||
|
|
&AbstractTexture::parameterImplementationDefault;
|
||
|
13 years ago
|
AbstractTexture::SetMaxAnisotropyImplementation AbstractTexture::setMaxAnisotropyImplementation =
|
||
|
|
&AbstractTexture::setMaxAnisotropyImplementationNoOp;
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
AbstractTexture::GetLevelParameterivImplementation AbstractTexture::getLevelParameterivImplementation =
|
||
|
|
&AbstractTexture::getLevelParameterImplementationDefault;
|
||
|
|
#endif
|
||
|
14 years ago
|
AbstractTexture::MipmapImplementation AbstractTexture::mipmapImplementation =
|
||
|
|
&AbstractTexture::mipmapImplementationDefault;
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
14 years ago
|
AbstractTexture::Storage1DImplementation AbstractTexture::storage1DImplementation =
|
||
|
13 years ago
|
&AbstractTexture::storageImplementationFallback;
|
||
|
14 years ago
|
#endif
|
||
|
|
AbstractTexture::Storage2DImplementation AbstractTexture::storage2DImplementation =
|
||
|
13 years ago
|
&AbstractTexture::storageImplementationFallback;
|
||
|
14 years ago
|
AbstractTexture::Storage3DImplementation AbstractTexture::storage3DImplementation =
|
||
|
13 years ago
|
&AbstractTexture::storageImplementationFallback;
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
AbstractTexture::GetImageImplementation AbstractTexture::getImageImplementation =
|
||
|
|
&AbstractTexture::getImageImplementationDefault;
|
||
|
14 years ago
|
AbstractTexture::Image1DImplementation AbstractTexture::image1DImplementation =
|
||
|
|
&AbstractTexture::imageImplementationDefault;
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
AbstractTexture::Image2DImplementation AbstractTexture::image2DImplementation =
|
||
|
|
&AbstractTexture::imageImplementationDefault;
|
||
|
|
AbstractTexture::Image3DImplementation AbstractTexture::image3DImplementation =
|
||
|
|
&AbstractTexture::imageImplementationDefault;
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
14 years ago
|
AbstractTexture::SubImage1DImplementation AbstractTexture::subImage1DImplementation =
|
||
|
|
&AbstractTexture::subImageImplementationDefault;
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
AbstractTexture::SubImage2DImplementation AbstractTexture::subImage2DImplementation =
|
||
|
|
&AbstractTexture::subImageImplementationDefault;
|
||
|
|
AbstractTexture::SubImage3DImplementation AbstractTexture::subImage3DImplementation =
|
||
|
|
&AbstractTexture::subImageImplementationDefault;
|
||
|
|
|
||
|
13 years ago
|
AbstractTexture::InvalidateImageImplementation AbstractTexture::invalidateImageImplementation = &AbstractTexture::invalidateImageImplementationNoOp;
|
||
|
|
AbstractTexture::InvalidateSubImageImplementation AbstractTexture::invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationNoOp;
|
||
|
14 years ago
|
|
||
|
13 years ago
|
Int AbstractTexture::maxLayers() { return Shader::maxCombinedTextureImageUnits(); }
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
Int AbstractTexture::maxColorSamples() {
|
||
|
|
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
|
return 0;
|
||
|
|
|
||
|
|
GLint& value = Context::current()->state().texture->maxColorSamples;
|
||
|
|
|
||
|
|
/* Get the value, if not already cached */
|
||
|
|
if(value == 0)
|
||
|
|
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &value);
|
||
|
|
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
|
||
|
|
Int AbstractTexture::maxDepthSamples() {
|
||
|
|
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
|
return 0;
|
||
|
|
|
||
|
|
GLint& value = Context::current()->state().texture->maxDepthSamples;
|
||
|
|
|
||
|
|
/* Get the value, if not already cached */
|
||
|
|
if(value == 0)
|
||
|
|
glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &value);
|
||
|
|
|
||
|
|
return value;
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
Int AbstractTexture::maxIntegerSamples() {
|
||
|
|
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
|
return 0;
|
||
|
|
|
||
|
|
GLint& value = Context::current()->state().texture->maxIntegerSamples;
|
||
|
|
|
||
|
|
/* Get the value, if not already cached */
|
||
|
|
if(value == 0)
|
||
|
|
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &value);
|
||
|
|
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
AbstractTexture::AbstractTexture(GLenum target): _target(target) {
|
||
|
|
glGenTextures(1, &_id);
|
||
|
|
}
|
||
|
|
|
||
|
|
AbstractTexture::~AbstractTexture() {
|
||
|
|
/* Moved out, nothing to do */
|
||
|
14 years ago
|
if(!_id) return;
|
||
|
|
|
||
|
14 years ago
|
/* Remove all bindings */
|
||
|
13 years ago
|
for(GLuint& binding: Context::current()->state().texture->bindings)
|
||
|
14 years ago
|
if(binding == _id) binding = 0;
|
||
|
|
|
||
|
|
glDeleteTextures(1, &_id);
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
std::string AbstractTexture::label() const {
|
||
|
|
return Context::current()->state().debug->getLabelImplementation(GL_TEXTURE, _id);
|
||
|
|
}
|
||
|
|
|
||
|
|
AbstractTexture& AbstractTexture::setLabel(const std::string& label) {
|
||
|
|
Context::current()->state().debug->labelImplementation(GL_TEXTURE, _id, label);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::bind(Int layer) {
|
||
|
13 years ago
|
Implementation::TextureState* const textureState = Context::current()->state().texture;
|
||
|
14 years ago
|
|
||
|
|
/* If already bound in given layer, nothing to do */
|
||
|
|
if(textureState->bindings[layer] == _id) return;
|
||
|
|
|
||
|
14 years ago
|
(this->*bindImplementation)(layer);
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::bindImplementationDefault(GLint layer) {
|
||
|
13 years ago
|
Implementation::TextureState* const textureState = Context::current()->state().texture;
|
||
|
14 years ago
|
|
||
|
14 years ago
|
/* Change to given layer, if not already there */
|
||
|
|
if(textureState->currentLayer != layer)
|
||
|
|
glActiveTexture(GL_TEXTURE0 + (textureState->currentLayer = layer));
|
||
|
|
|
||
|
|
/* Bind the texture to the layer */
|
||
|
|
glBindTexture(_target, (textureState->bindings[layer] = _id));
|
||
|
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
14 years ago
|
void AbstractTexture::bindImplementationDSA(GLint layer) {
|
||
|
13 years ago
|
glBindMultiTextureEXT(GL_TEXTURE0 + layer, _target, (Context::current()->state().texture->bindings[layer] = _id));
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
AbstractTexture& AbstractTexture::setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap) {
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
CORRADE_ASSERT(_target != GL_TEXTURE_RECTANGLE || mipmap == Sampler::Mipmap::Base, "AbstractTexture: rectangle textures cannot have mipmaps", *this);
|
||
|
14 years ago
|
#endif
|
||
|
15 years ago
|
|
||
|
13 years ago
|
(this->*parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap));
|
||
|
13 years ago
|
return *this;
|
||
|
15 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
AbstractTexture& AbstractTexture::generateMipmap() {
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
CORRADE_ASSERT(_target != GL_TEXTURE_RECTANGLE, "AbstractTexture: rectangle textures cannot have mipmaps", *this);
|
||
|
14 years ago
|
#endif
|
||
|
15 years ago
|
|
||
|
14 years ago
|
(this->*mipmapImplementation)();
|
||
|
13 years ago
|
return *this;
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::mipmapImplementationDefault() {
|
||
|
14 years ago
|
bindInternal();
|
||
|
14 years ago
|
glGenerateMipmap(_target);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
14 years ago
|
void AbstractTexture::mipmapImplementationDSA() {
|
||
|
|
glGenerateTextureMipmapEXT(_id, _target);
|
||
|
15 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
15 years ago
|
|
||
|
14 years ago
|
void AbstractTexture::bindInternal() {
|
||
|
13 years ago
|
Implementation::TextureState* const textureState = Context::current()->state().texture;
|
||
|
14 years ago
|
|
||
|
|
/* If the texture is already bound in current layer, nothing to do */
|
||
|
|
if(textureState->bindings[textureState->currentLayer] == _id)
|
||
|
|
return;
|
||
|
|
|
||
|
|
/* Set internal layer as active if not already */
|
||
|
13 years ago
|
const GLint internalLayer = maxLayers()-1;
|
||
|
14 years ago
|
if(textureState->currentLayer != internalLayer)
|
||
|
|
glActiveTexture(GL_TEXTURE0 + (textureState->currentLayer = internalLayer));
|
||
|
|
|
||
|
|
/* Bind the texture to internal layer, if not already */
|
||
|
|
if(textureState->bindings[internalLayer] != _id)
|
||
|
|
glBindTexture(_target, (textureState->bindings[internalLayer] = _id));
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::initializeContextBasedFunctionality(Context& context) {
|
||
|
13 years ago
|
/* Resize bindings array to hold all possible layers */
|
||
|
|
context.state().texture->bindings.resize(maxLayers());
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
|
||
|
14 years ago
|
Debug() << "AbstractTexture: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
|
||
|
|
|
||
|
|
bindImplementation = &AbstractTexture::bindImplementationDSA;
|
||
|
|
parameteriImplementation = &AbstractTexture::parameterImplementationDSA;
|
||
|
|
parameterfImplementation = &AbstractTexture::parameterImplementationDSA;
|
||
|
|
parameterfvImplementation = &AbstractTexture::parameterImplementationDSA;
|
||
|
13 years ago
|
getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDSA;
|
||
|
14 years ago
|
mipmapImplementation = &AbstractTexture::mipmapImplementationDSA;
|
||
|
13 years ago
|
getImageImplementation = &AbstractTexture::getImageImplementationDSA;
|
||
|
14 years ago
|
image1DImplementation = &AbstractTexture::imageImplementationDSA;
|
||
|
|
image2DImplementation = &AbstractTexture::imageImplementationDSA;
|
||
|
|
image3DImplementation = &AbstractTexture::imageImplementationDSA;
|
||
|
|
subImage1DImplementation = &AbstractTexture::subImageImplementationDSA;
|
||
|
|
subImage2DImplementation = &AbstractTexture::subImageImplementationDSA;
|
||
|
|
subImage3DImplementation = &AbstractTexture::subImageImplementationDSA;
|
||
|
|
}
|
||
|
14 years ago
|
|
||
|
13 years ago
|
if(context.isExtensionSupported<Extensions::GL::ARB::invalidate_subdata>()) {
|
||
|
14 years ago
|
Debug() << "AbstractTexture: using" << Extensions::GL::ARB::invalidate_subdata::string() << "features";
|
||
|
|
|
||
|
13 years ago
|
invalidateImageImplementation = &AbstractTexture::invalidateImageImplementationARB;
|
||
|
|
invalidateSubImageImplementation = &AbstractTexture::invalidateSubImageImplementationARB;
|
||
|
14 years ago
|
}
|
||
|
13 years ago
|
|
||
|
13 years ago
|
if(context.isExtensionSupported<Extensions::GL::ARB::robustness>() &&
|
||
|
|
!context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
|
||
|
13 years ago
|
Debug() << "AbstractTexture: using" << Extensions::GL::ARB::robustness::string() << "features";
|
||
|
|
|
||
|
|
getImageImplementation = &AbstractTexture::getImageImplementationRobustness;
|
||
|
|
}
|
||
|
13 years ago
|
|
||
|
13 years ago
|
if(context.isExtensionSupported<Extensions::GL::ARB::texture_storage>()) {
|
||
|
13 years ago
|
Debug() << "AbstractTexture: using" << Extensions::GL::ARB::texture_storage::string() << "features";
|
||
|
|
|
||
|
13 years ago
|
if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
|
||
|
13 years ago
|
storage1DImplementation = &AbstractTexture::storageImplementationDSA;
|
||
|
|
storage2DImplementation = &AbstractTexture::storageImplementationDSA;
|
||
|
|
storage3DImplementation = &AbstractTexture::storageImplementationDSA;
|
||
|
|
} else {
|
||
|
|
storage1DImplementation = &AbstractTexture::storageImplementationDefault;
|
||
|
|
storage2DImplementation = &AbstractTexture::storageImplementationDefault;
|
||
|
|
storage3DImplementation = &AbstractTexture::storageImplementationDefault;
|
||
|
|
}
|
||
|
|
}
|
||
|
14 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
if(context.isExtensionSupported<Extensions::GL::EXT::texture_filter_anisotropic>()) {
|
||
|
|
Debug() << "AbstractTexture: using" << Extensions::GL::EXT::texture_filter_anisotropic::string() << "features";
|
||
|
|
|
||
|
|
setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationExt;
|
||
|
|
}
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) {
|
||
|
13 years ago
|
switch(internalFormat) {
|
||
|
|
case TextureFormat::Red:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R8:
|
||
|
|
case TextureFormat::R8Snorm:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::R16:
|
||
|
|
case TextureFormat::R16Snorm:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R16F:
|
||
|
|
case TextureFormat::R32F:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::CompressedRed:
|
||
|
|
case TextureFormat::CompressedRedRtgc1:
|
||
|
|
case TextureFormat::CompressedSignedRedRgtc1:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorFormat::Red;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R8UI:
|
||
|
|
case TextureFormat::R8I:
|
||
|
|
case TextureFormat::R16UI:
|
||
|
|
case TextureFormat::R16I:
|
||
|
|
case TextureFormat::R32UI:
|
||
|
|
case TextureFormat::R32I:
|
||
|
13 years ago
|
return ColorFormat::RedInteger;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
case TextureFormat::RG:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RG8:
|
||
|
|
case TextureFormat::RG8Snorm:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RG16:
|
||
|
|
case TextureFormat::RG16Snorm:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RG16F:
|
||
|
|
case TextureFormat::RG32F:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::CompressedRG:
|
||
|
|
case TextureFormat::CompressedRGRgtc2:
|
||
|
|
case TextureFormat::CompressedSignedRGRgtc2:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorFormat::RG;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RG8UI:
|
||
|
|
case TextureFormat::RG8I:
|
||
|
|
case TextureFormat::RG16UI:
|
||
|
|
case TextureFormat::RG16I:
|
||
|
|
case TextureFormat::RG32UI:
|
||
|
|
case TextureFormat::RG32I:
|
||
|
13 years ago
|
return ColorFormat::RGInteger;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
case TextureFormat::RGB:
|
||
|
|
case TextureFormat::RGB8:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RGB8Snorm:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGB16:
|
||
|
|
case TextureFormat::RGB16Snorm:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RGB16F:
|
||
|
|
case TextureFormat::RGB32F:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::R3B3G2:
|
||
|
|
case TextureFormat::RGB4:
|
||
|
|
case TextureFormat::RGB5:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::RGB565:
|
||
|
|
case TextureFormat::RGB10:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGB12:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R11FG11FB10F:
|
||
|
|
case TextureFormat::RGB9E5:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::SRGB:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::SRGB8:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::CompressedRGB:
|
||
|
|
case TextureFormat::CompressedRGBBptcUnsignedFloat:
|
||
|
|
case TextureFormat::CompressedRGBBptcSignedFloat:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorFormat::RGB;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RGB8UI:
|
||
|
|
case TextureFormat::RGB8I:
|
||
|
|
case TextureFormat::RGB16UI:
|
||
|
|
case TextureFormat::RGB16I:
|
||
|
|
case TextureFormat::RGB32UI:
|
||
|
|
case TextureFormat::RGB32I:
|
||
|
13 years ago
|
return ColorFormat::RGBInteger;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
case TextureFormat::RGBA:
|
||
|
|
case TextureFormat::RGBA8:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RGBA8Snorm:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGBA16:
|
||
|
|
case TextureFormat::RGBA16Snorm:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RGBA16F:
|
||
|
|
case TextureFormat::RGBA32F:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGBA2:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::RGBA4:
|
||
|
|
case TextureFormat::RGB5A1:
|
||
|
|
case TextureFormat::RGB10A2:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGBA12:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::SRGBAlpha:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::SRGB8Alpha8:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::CompressedRGBA:
|
||
|
|
case TextureFormat::CompressedRGBABptcUnorm:
|
||
|
|
case TextureFormat::CompressedSRGBAlphaBptcUnorm:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorFormat::RGBA;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RGBA8UI:
|
||
|
|
case TextureFormat::RGBA8I:
|
||
|
|
case TextureFormat::RGBA16UI:
|
||
|
|
case TextureFormat::RGBA16I:
|
||
|
|
case TextureFormat::RGBA32UI:
|
||
|
|
case TextureFormat::RGBA32I:
|
||
|
|
case TextureFormat::RGB10A2UI:
|
||
|
13 years ago
|
return ColorFormat::RGBAInteger;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::Luminance:
|
||
|
13 years ago
|
return ColorFormat::Luminance;
|
||
|
13 years ago
|
case TextureFormat::LuminanceAlpha:
|
||
|
13 years ago
|
return ColorFormat::LuminanceAlpha;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
case TextureFormat::DepthComponent:
|
||
|
|
case TextureFormat::DepthComponent16:
|
||
|
|
case TextureFormat::DepthComponent24:
|
||
|
|
case TextureFormat::DepthComponent32:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::DepthComponent32F:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorFormat::DepthComponent;
|
||
|
13 years ago
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::StencilIndex8:
|
||
|
13 years ago
|
return ColorFormat::StencilIndex;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
13 years ago
|
case TextureFormat::DepthStencil:
|
||
|
|
case TextureFormat::Depth24Stencil8:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::Depth32FStencil8:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorFormat::DepthStencil;
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
CORRADE_ASSERT_UNREACHABLE();
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat internalFormat) {
|
||
|
13 years ago
|
switch(internalFormat) {
|
||
|
|
case TextureFormat::Red:
|
||
|
|
case TextureFormat::RG:
|
||
|
|
case TextureFormat::RGB:
|
||
|
|
case TextureFormat::RGBA:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R8:
|
||
|
|
case TextureFormat::RG8:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::RGB8:
|
||
|
|
case TextureFormat::RGBA8:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R8UI:
|
||
|
|
case TextureFormat::RG8UI:
|
||
|
|
case TextureFormat::RGB8UI:
|
||
|
|
case TextureFormat::RGBA8UI:
|
||
|
|
#endif
|
||
|
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::Luminance:
|
||
|
|
case TextureFormat::LuminanceAlpha:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::SRGB:
|
||
|
|
case TextureFormat::SRGBAlpha:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::SRGB8:
|
||
|
|
case TextureFormat::SRGB8Alpha8:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGBA2: /**< @todo really? */
|
||
|
|
case TextureFormat::CompressedRed:
|
||
|
|
case TextureFormat::CompressedRG:
|
||
|
|
case TextureFormat::CompressedRGB:
|
||
|
|
case TextureFormat::CompressedRGBA:
|
||
|
|
case TextureFormat::CompressedRedRtgc1:
|
||
|
|
case TextureFormat::CompressedRGRgtc2:
|
||
|
|
case TextureFormat::CompressedRGBABptcUnorm:
|
||
|
|
case TextureFormat::CompressedSRGBAlphaBptcUnorm:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorType::UnsignedByte;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R8Snorm:
|
||
|
|
case TextureFormat::RG8Snorm:
|
||
|
|
case TextureFormat::RGB8Snorm:
|
||
|
|
case TextureFormat::RGBA8Snorm:
|
||
|
|
case TextureFormat::R8I:
|
||
|
|
case TextureFormat::RG8I:
|
||
|
|
case TextureFormat::RGB8I:
|
||
|
|
case TextureFormat::RGBA8I:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::CompressedSignedRedRgtc1:
|
||
|
|
case TextureFormat::CompressedSignedRGRgtc2:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorType::Byte;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::R16:
|
||
|
|
case TextureFormat::RG16:
|
||
|
|
case TextureFormat::RGB16:
|
||
|
|
case TextureFormat::RGBA16:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R16UI:
|
||
|
|
case TextureFormat::RG16UI:
|
||
|
|
case TextureFormat::RGB16UI:
|
||
|
|
case TextureFormat::RGBA16UI:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGB12: /**< @todo really? */
|
||
|
|
#endif
|
||
|
|
case TextureFormat::RGBA4: /**< @todo really? */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGBA12: /**< @todo really? */
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorType::UnsignedShort;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::R16Snorm:
|
||
|
|
case TextureFormat::RG16Snorm:
|
||
|
|
case TextureFormat::RGB16Snorm:
|
||
|
|
case TextureFormat::RGBA16Snorm:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::R16I:
|
||
|
|
case TextureFormat::RG16I:
|
||
|
|
case TextureFormat::RGB16I:
|
||
|
|
case TextureFormat::RGBA16I:
|
||
|
13 years ago
|
return ColorType::Short;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R16F:
|
||
|
|
case TextureFormat::RG16F:
|
||
|
|
case TextureFormat::RGB16F:
|
||
|
|
case TextureFormat::RGBA16F:
|
||
|
13 years ago
|
return ColorType::HalfFloat;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::R32UI:
|
||
|
|
case TextureFormat::RG32UI:
|
||
|
|
case TextureFormat::RGB32UI:
|
||
|
|
case TextureFormat::RGBA32UI:
|
||
|
13 years ago
|
return ColorType::UnsignedInt;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::R32I:
|
||
|
|
case TextureFormat::RG32I:
|
||
|
|
case TextureFormat::RGB32I:
|
||
|
|
case TextureFormat::RGBA32I:
|
||
|
13 years ago
|
return ColorType::Int;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::R32F:
|
||
|
|
case TextureFormat::RG32F:
|
||
|
|
case TextureFormat::RGB32F:
|
||
|
|
case TextureFormat::RGBA32F:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::CompressedRGBBptcUnsignedFloat:
|
||
|
|
case TextureFormat::CompressedRGBBptcSignedFloat:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorType::Float;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::R3B3G2:
|
||
|
13 years ago
|
return ColorType::UnsignedByte332;
|
||
|
13 years ago
|
case TextureFormat::RGB4:
|
||
|
13 years ago
|
return ColorType::UnsignedShort4444;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGB5:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::RGB5A1:
|
||
|
13 years ago
|
return ColorType::UnsignedShort5551;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::RGB565:
|
||
|
13 years ago
|
return ColorType::UnsignedShort565;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::RGB10:
|
||
|
|
case TextureFormat::RGB10A2:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RGB10A2UI:
|
||
|
|
#endif
|
||
|
13 years ago
|
return ColorType::UnsignedInt2101010Rev; /**< @todo Rev for all? */
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R11FG11FB10F:
|
||
|
13 years ago
|
return ColorType::UnsignedInt10F11F11FRev;
|
||
|
13 years ago
|
case TextureFormat::RGB9E5:
|
||
|
13 years ago
|
return ColorType::UnsignedInt5999Rev;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
case TextureFormat::DepthComponent16:
|
||
|
13 years ago
|
return ColorType::UnsignedShort;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::DepthComponent:
|
||
|
|
case TextureFormat::DepthComponent24:
|
||
|
|
case TextureFormat::DepthComponent32:
|
||
|
13 years ago
|
return ColorType::UnsignedInt;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::DepthComponent32F:
|
||
|
13 years ago
|
return ColorType::Float;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::StencilIndex8:
|
||
|
13 years ago
|
return ColorType::UnsignedByte;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
13 years ago
|
case TextureFormat::DepthStencil:
|
||
|
|
case TextureFormat::Depth24Stencil8:
|
||
|
13 years ago
|
return ColorType::UnsignedInt248;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::Depth32FStencil8:
|
||
|
13 years ago
|
return ColorType::Float32UnsignedInt248Rev;
|
||
|
13 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
CORRADE_ASSERT_UNREACHABLE();
|
||
|
|
}
|
||
|
|
|
||
|
14 years ago
|
void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLint value) {
|
||
|
|
bindInternal();
|
||
|
|
glTexParameteri(_target, parameter, value);
|
||
|
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
14 years ago
|
void AbstractTexture::parameterImplementationDSA(GLenum parameter, GLint value) {
|
||
|
|
glTextureParameteriEXT(_id, _target, parameter, value);
|
||
|
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
|
void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLfloat value) {
|
||
|
|
bindInternal();
|
||
|
|
glTexParameterf(_target, parameter, value);
|
||
|
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
14 years ago
|
void AbstractTexture::parameterImplementationDSA(GLenum parameter, GLfloat value) {
|
||
|
|
glTextureParameterfEXT(_id, _target, parameter, value);
|
||
|
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
|
void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLfloat* values) {
|
||
|
|
bindInternal();
|
||
|
|
glTexParameterfv(_target, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
14 years ago
|
void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLfloat* values) {
|
||
|
|
glTextureParameterfvEXT(_id, _target, parameter, values);
|
||
|
|
}
|
||
|
13 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
void AbstractTexture::setMaxAnisotropyImplementationNoOp(GLfloat) {}
|
||
|
|
|
||
|
|
void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) {
|
||
|
|
(this->*parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values) {
|
||
|
|
bindInternal();
|
||
|
|
glGetTexLevelParameteriv(target, level, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::getLevelParameterImplementationDSA(GLenum target, GLint level, GLenum parameter, GLint* values) {
|
||
|
|
glGetTextureLevelParameterivEXT(_id, target, level, parameter, values);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
|
||
|
|
CORRADE_INTERNAL_ASSERT(target == GL_TEXTURE_1D);
|
||
|
|
|
||
|
13 years ago
|
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
|
||
|
|
const ColorType type = imageTypeForInternalFormat(internalFormat);
|
||
|
13 years ago
|
|
||
|
|
for(GLsizei level = 0; level != levels; ++level) {
|
||
|
13 years ago
|
(this->*image1DImplementation)(target, level, internalFormat, Math::max(Math::Vector<1, GLsizei>(1), size >> level), format, type, nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
/** @todo Re-enable when extension loader is available for ES */
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
glTexStorage1D(target, levels, GLenum(internalFormat), size[0]);
|
||
|
|
#else
|
||
|
|
static_cast<void>(target);
|
||
|
|
static_cast<void>(levels);
|
||
|
|
static_cast<void>(internalFormat);
|
||
|
|
static_cast<void>(size);
|
||
|
13 years ago
|
CORRADE_INTERNAL_ASSERT(false);
|
||
|
|
//glTexStorage2DEXT(target, levels, GLenum(internalFormat), size.x(), size.y());
|
||
|
14 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
|
||
|
14 years ago
|
glTextureStorage1DEXT(_id, target, levels, GLenum(internalFormat), size[0]);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
|
||
|
13 years ago
|
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
|
||
|
|
const ColorType type = imageTypeForInternalFormat(internalFormat);
|
||
|
13 years ago
|
|
||
|
|
/* Common code for classic types */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE)
|
||
|
|
#else
|
||
|
|
if(target == GL_TEXTURE_2D)
|
||
|
|
#endif
|
||
|
|
{
|
||
|
|
for(GLsizei level = 0; level != levels; ++level) {
|
||
|
13 years ago
|
(this->*image2DImplementation)(target, level, internalFormat, Math::max(Vector2i(1), size >> level), format, type, nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
/* Cube map additionally needs to specify all faces */
|
||
|
13 years ago
|
} else if(target == GL_TEXTURE_CUBE_MAP) {
|
||
|
|
for(GLsizei level = 0; level != levels; ++level) {
|
||
|
|
for(GLenum face: {GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
||
|
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||
|
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||
|
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
||
|
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
|
||
|
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z})
|
||
|
13 years ago
|
(this->*image2DImplementation)(face, level, internalFormat, Math::max(Vector2i(1), size >> level), format, type, nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Array texture is not scaled in "layer" dimension */
|
||
|
|
} else if(target == GL_TEXTURE_1D_ARRAY) {
|
||
|
|
for(GLsizei level = 0; level != levels; ++level) {
|
||
|
13 years ago
|
(this->*image2DImplementation)(target, level, internalFormat, Math::max(Vector2i(1), size >> level), format, type, nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
/* No other targets are available */
|
||
|
|
} else CORRADE_ASSERT_UNREACHABLE();
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
/** @todo Re-enable when extension loader is available for ES */
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
glTexStorage2D(target, levels, GLenum(internalFormat), size.x(), size.y());
|
||
|
|
#else
|
||
|
|
static_cast<void>(target);
|
||
|
|
static_cast<void>(levels);
|
||
|
|
static_cast<void>(internalFormat);
|
||
|
|
static_cast<void>(size);
|
||
|
13 years ago
|
CORRADE_INTERNAL_ASSERT(false);
|
||
|
|
//glTexStorage2DEXT(target, levels, GLenum(internalFormat), size.x(), size.y());
|
||
|
14 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
|
||
|
14 years ago
|
glTextureStorage2DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y());
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
|
||
|
13 years ago
|
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
|
||
|
|
const ColorType type = imageTypeForInternalFormat(internalFormat);
|
||
|
13 years ago
|
|
||
|
|
/* Common code for classic type */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
if(target == GL_TEXTURE_3D)
|
||
|
|
#else
|
||
|
|
if(target == GL_TEXTURE_3D_OES)
|
||
|
|
#endif
|
||
|
|
{
|
||
|
|
for(GLsizei level = 0; level != levels; ++level) {
|
||
|
13 years ago
|
(this->*image3DImplementation)(target, level, internalFormat, Math::max(Vector3i(1), size >> level), format, type, nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
/* Array texture is not scaled in "layer" dimension */
|
||
|
|
}
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
else if(target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
||
|
|
#else
|
||
|
|
else if(target == GL_TEXTURE_2D_ARRAY)
|
||
|
|
#endif
|
||
|
|
{
|
||
|
|
for(GLsizei level = 0; level != levels; ++level) {
|
||
|
13 years ago
|
(this->*image3DImplementation)(target, level, internalFormat, Math::max(Vector3i(1), size >> level), format, type, nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
/* No other targets are available */
|
||
|
|
} else CORRADE_ASSERT_UNREACHABLE();
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
/** @todo Re-enable when extension loader is available for ES */
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
glTexStorage3D(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
|
||
|
|
#else
|
||
|
|
static_cast<void>(target);
|
||
|
|
static_cast<void>(levels);
|
||
|
|
static_cast<void>(internalFormat);
|
||
|
|
static_cast<void>(size);
|
||
|
13 years ago
|
CORRADE_INTERNAL_ASSERT(false);
|
||
|
|
//glTexStorage3DEXT(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
|
||
|
14 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
|
||
|
14 years ago
|
glTextureStorage3DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
|
||
|
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::getImageImplementationDefault(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
|
||
|
13 years ago
|
bindInternal();
|
||
|
|
glGetTexImage(target, level, GLenum(format), GLenum(type), data);
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
|
||
|
13 years ago
|
glGetTextureImageEXT(_id, target, level, GLenum(format), GLenum(type), data);
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::getImageImplementationRobustness(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
|
||
|
13 years ago
|
/** @todo Re-enable when extension loader is available for ES */
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
bindInternal();
|
||
|
|
glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data);
|
||
|
|
#else
|
||
|
|
static_cast<void>(target);
|
||
|
|
static_cast<void>(level);
|
||
|
|
static_cast<void>(format);
|
||
|
|
static_cast<void>(type);
|
||
|
|
static_cast<void>(dataSize);
|
||
|
|
static_cast<void>(data);
|
||
|
13 years ago
|
CORRADE_INTERNAL_ASSERT(false);
|
||
|
13 years ago
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
glTexImage1D(target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
13 years ago
|
glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
13 years ago
|
glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
/** @todo Re-enable when extension loader is available for ES */
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
13 years ago
|
glTexImage3D(target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
#else
|
||
|
|
static_cast<void>(target);
|
||
|
14 years ago
|
static_cast<void>(level);
|
||
|
14 years ago
|
static_cast<void>(internalFormat);
|
||
|
|
static_cast<void>(size);
|
||
|
14 years ago
|
static_cast<void>(format);
|
||
|
14 years ago
|
static_cast<void>(type);
|
||
|
|
static_cast<void>(data);
|
||
|
13 years ago
|
CORRADE_INTERNAL_ASSERT(false);
|
||
|
|
//glTexImage3DOES(target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
13 years ago
|
glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
glTexSubImage1D(target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
13 years ago
|
glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
13 years ago
|
glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
13 years ago
|
/** @todo Re-enable when extension loader is available for ES */
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
13 years ago
|
glTexSubImage3D(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
#else
|
||
|
|
static_cast<void>(target);
|
||
|
14 years ago
|
static_cast<void>(level);
|
||
|
14 years ago
|
static_cast<void>(offset);
|
||
|
|
static_cast<void>(size);
|
||
|
14 years ago
|
static_cast<void>(format);
|
||
|
14 years ago
|
static_cast<void>(type);
|
||
|
|
static_cast<void>(data);
|
||
|
13 years ago
|
CORRADE_INTERNAL_ASSERT(false);
|
||
|
|
//glTexSubImage3DOES(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
|
||
|
13 years ago
|
glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
void AbstractTexture::invalidateImageImplementationNoOp(GLint) {}
|
||
|
14 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::invalidateImageImplementationARB(GLint level) {
|
||
|
14 years ago
|
glInvalidateTexImage(_id, level);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::invalidateSubImageImplementationNoOp(GLint, const Vector3i&, const Vector3i&) {}
|
||
|
14 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vector3i& offset, const Vector3i& size) {
|
||
|
14 years ago
|
glInvalidateTexSubImage(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z());
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
#ifndef DOXYGEN_GENERATING_OUTPUT
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, Image<dimensions>& image) {
|
||
|
13 years ago
|
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(this, target, level);
|
||
|
13 years ago
|
const std::size_t dataSize = size.product()*image.pixelSize();
|
||
|
13 years ago
|
char* data = new char[dataSize];
|
||
|
13 years ago
|
(this->*getImageImplementation)(target, level, image.format(), image.type(), dataSize, data);
|
||
|
13 years ago
|
image.setData(image.format(), image.type(), size, data);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
template void MAGNUM_EXPORT AbstractTexture::image<1>(GLenum, GLint, Image<1>&);
|
||
|
|
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, Image<2>&);
|
||
|
|
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, Image<3>&);
|
||
|
13 years ago
|
|
||
|
13 years ago
|
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, BufferImage<dimensions>& image, BufferUsage usage) {
|
||
|
13 years ago
|
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(this, target, level);
|
||
|
13 years ago
|
const std::size_t dataSize = size.product()*image.pixelSize();
|
||
|
|
if(image.size() != size)
|
||
|
13 years ago
|
image.setData(image.format(), image.type(), size, nullptr, usage);
|
||
|
13 years ago
|
|
||
|
13 years ago
|
image.buffer().bind(Buffer::Target::PixelPack);
|
||
|
13 years ago
|
(this->*getImageImplementation)(target, level, image.format(), image.type(), dataSize, nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
template void MAGNUM_EXPORT AbstractTexture::image<1>(GLenum, GLint, BufferImage<1>&, BufferUsage);
|
||
|
|
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, BufferImage<2>&, BufferUsage);
|
||
|
|
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, BufferImage<3>&, BufferUsage);
|
||
|
13 years ago
|
#endif
|
||
|
|
#endif
|
||
|
|
|
||
|
14 years ago
|
#ifndef DOXYGEN_GENERATING_OUTPUT
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture* texture, GLenum target, GLint level) {
|
||
|
|
Math::Vector<1, GLint> value;
|
||
|
|
(texture->*getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
|
||
|
|
Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture* texture, GLenum target, GLint level) {
|
||
|
|
Vector2i value;
|
||
|
|
(texture->*getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
|
||
|
|
(texture->*getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]);
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
|
||
|
|
Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture* texture, GLenum target, GLint level) {
|
||
|
|
Vector3i value;
|
||
|
|
(texture->*getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
|
||
|
|
(texture->*getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]);
|
||
|
|
(texture->*getLevelParameterivImplementation)(target, level, GL_TEXTURE_DEPTH, &value[2]);
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference1D& image) {
|
||
|
|
Buffer::unbind(Buffer::Target::PixelUnpack);
|
||
|
|
(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) {
|
||
|
13 years ago
|
image.buffer().bind(Buffer::Target::PixelUnpack);
|
||
|
13 years ago
|
(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) {
|
||
|
|
Buffer::unbind(Buffer::Target::PixelUnpack);
|
||
|
|
(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) {
|
||
|
13 years ago
|
image.buffer().bind(Buffer::Target::PixelUnpack);
|
||
|
13 years ago
|
(texture->*subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference2D& image) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Buffer::unbind(Buffer::Target::PixelUnpack);
|
||
|
|
#endif
|
||
|
|
(texture->*image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data());
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) {
|
||
|
13 years ago
|
image.buffer().bind(Buffer::Target::PixelUnpack);
|
||
|
13 years ago
|
(texture->*image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector2i& offset, const ImageReference2D& image) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Buffer::unbind(Buffer::Target::PixelUnpack);
|
||
|
|
#endif
|
||
|
|
(texture->*subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data());
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector2i& offset, BufferImage2D& image) {
|
||
|
13 years ago
|
image.buffer().bind(Buffer::Target::PixelUnpack);
|
||
|
13 years ago
|
(texture->*subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Buffer::unbind(Buffer::Target::PixelUnpack);
|
||
|
|
#endif
|
||
|
|
(texture->*image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data());
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture* const texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) {
|
||
|
13 years ago
|
image.buffer().bind(Buffer::Target::PixelUnpack);
|
||
|
13 years ago
|
(texture->*image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector3i& offset, const ImageReference3D& image) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Buffer::unbind(Buffer::Target::PixelUnpack);
|
||
|
|
#endif
|
||
|
|
(texture->*subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data());
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture* const texture, const GLenum target, const GLint level, const Vector3i& offset, BufferImage3D& image) {
|
||
|
13 years ago
|
image.buffer().bind(Buffer::Target::PixelUnpack);
|
||
|
13 years ago
|
(texture->*subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture* texture, const Array2D<Sampler::Wrapping>& wrapping) {
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
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", );
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
13 years ago
|
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
|
||
|
|
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture* texture, const Array3D<Sampler::Wrapping>& wrapping) {
|
||
|
13 years ago
|
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
|
||
|
|
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_R, GLint(wrapping.z()));
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
15 years ago
|
}
|