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.
2271 lines
102 KiB
2271 lines
102 KiB
|
15 years ago
|
/*
|
||
|
|
This file is part of Magnum.
|
||
|
|
|
||
|
8 years ago
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
|
||
|
12 years ago
|
Vladimír Vondruš <mosra@centrum.cz>
|
||
|
13 years ago
|
|
||
|
|
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"
|
||
|
|
|
||
|
11 years ago
|
#include <Corrade/Containers/Array.h>
|
||
|
|
|
||
|
12 years ago
|
#include "Magnum/Array.h"
|
||
|
12 years ago
|
#include "Magnum/Image.h"
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
#include "Magnum/GL/BufferImage.h"
|
||
|
|
#endif
|
||
|
|
#include "Magnum/GL/Context.h"
|
||
|
|
#include "Magnum/GL/Extensions.h"
|
||
|
|
#include "Magnum/GL/PixelFormat.h"
|
||
|
|
#include "Magnum/GL/TextureFormat.h"
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
8 years ago
|
#include "Magnum/GL/Implementation/DebugState.h"
|
||
|
11 years ago
|
#endif
|
||
|
8 years ago
|
#include "Magnum/GL/Implementation/State.h"
|
||
|
|
#include "Magnum/GL/Implementation/TextureState.h"
|
||
|
|
#include "Magnum/Math/Color.h"
|
||
|
|
#include "Magnum/Math/Range.h"
|
||
|
14 years ago
|
|
||
|
15 years ago
|
namespace Magnum {
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Float AbstractTexture::maxLodBias() {
|
||
|
10 years ago
|
GLfloat& value = Context::current().state().texture->maxLodBias;
|
||
|
12 years ago
|
|
||
|
|
/* Get the value, if not already cached */
|
||
|
|
if(value == 0.0f)
|
||
|
|
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &value);
|
||
|
|
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
Int AbstractTexture::maxColorSamples() {
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
12 years ago
|
#else
|
||
|
10 years ago
|
if(!Context::current().isVersionSupported(Version::GLES310))
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
return 0;
|
||
|
|
|
||
|
10 years ago
|
GLint& value = Context::current().state().texture->maxColorSamples;
|
||
|
13 years ago
|
|
||
|
|
/* Get the value, if not already cached */
|
||
|
|
if(value == 0)
|
||
|
|
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &value);
|
||
|
|
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
|
||
|
|
Int AbstractTexture::maxDepthSamples() {
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
12 years ago
|
#else
|
||
|
10 years ago
|
if(!Context::current().isVersionSupported(Version::GLES310))
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
return 0;
|
||
|
|
|
||
|
10 years ago
|
GLint& value = Context::current().state().texture->maxDepthSamples;
|
||
|
13 years ago
|
|
||
|
|
/* 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() {
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
12 years ago
|
#else
|
||
|
10 years ago
|
if(!Context::current().isVersionSupported(Version::GLES310))
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
return 0;
|
||
|
|
|
||
|
10 years ago
|
GLint& value = Context::current().state().texture->maxIntegerSamples;
|
||
|
13 years ago
|
|
||
|
|
/* Get the value, if not already cached */
|
||
|
|
if(value == 0)
|
||
|
|
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &value);
|
||
|
|
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::unbind(const Int textureUnit) {
|
||
|
10 years ago
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
12 years ago
|
|
||
|
|
/* If given texture unit is already unbound, nothing to do */
|
||
|
12 years ago
|
if(textureState.bindings[textureUnit].second == 0) return;
|
||
|
12 years ago
|
|
||
|
|
/* Unbind the texture, reset state tracker */
|
||
|
10 years ago
|
Context::current().state().texture->unbindImplementation(textureUnit);
|
||
|
9 years ago
|
/* libstdc++ since GCC 6.3 can't handle just = {} (ambiguous overload of
|
||
|
|
operator=) */
|
||
|
|
textureState.bindings[textureUnit] = std::pair<GLenum, GLuint>{};
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::unbindImplementationDefault(const GLint textureUnit) {
|
||
|
10 years ago
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
12 years ago
|
|
||
|
|
/* Activate given texture unit if not already active, update state tracker */
|
||
|
12 years ago
|
if(textureState.currentTextureUnit != textureUnit)
|
||
|
|
glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = textureUnit));
|
||
|
12 years ago
|
|
||
|
12 years ago
|
CORRADE_INTERNAL_ASSERT(textureState.bindings[textureUnit].first != 0);
|
||
|
|
glBindTexture(textureState.bindings[textureUnit].first, 0);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::unbindImplementationMulti(const GLint textureUnit) {
|
||
|
12 years ago
|
constexpr static GLuint zero = 0;
|
||
|
12 years ago
|
glBindTextures(textureUnit, 1, &zero);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::unbindImplementationDSA(const GLint textureUnit) {
|
||
|
10 years ago
|
CORRADE_INTERNAL_ASSERT(Context::current().state().texture->bindings[textureUnit].first != 0);
|
||
|
12 years ago
|
glBindTextureUnit(textureUnit, 0);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::unbindImplementationDSAEXT(const GLint textureUnit) {
|
||
|
10 years ago
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
12 years ago
|
|
||
|
12 years ago
|
CORRADE_INTERNAL_ASSERT(textureState.bindings[textureUnit].first != 0);
|
||
|
|
glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, textureState.bindings[textureUnit].first, 0);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::unbind(const Int firstTextureUnit, const std::size_t count) {
|
||
|
|
/* State tracker is updated in the implementations */
|
||
|
10 years ago
|
Context::current().state().texture->bindMultiImplementation(firstTextureUnit, {nullptr, count});
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
|
/** @todoc const std::initializer_list makes Doxygen grumpy */
|
||
|
12 years ago
|
void AbstractTexture::bind(const Int firstTextureUnit, std::initializer_list<AbstractTexture*> textures) {
|
||
|
|
/* State tracker is updated in the implementations */
|
||
|
10 years ago
|
Context::current().state().texture->bindMultiImplementation(firstTextureUnit, {textures.begin(), textures.size()});
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, const Containers::ArrayView<AbstractTexture* const> textures) {
|
||
|
12 years ago
|
for(std::size_t i = 0; i != textures.size(); ++i)
|
||
|
|
textures && textures[i] ? textures[i]->bind(firstTextureUnit + i) : unbind(firstTextureUnit + i);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
11 years ago
|
/** @todoc const Containers::ArrayView makes Doxygen grumpy */
|
||
|
|
void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Containers::ArrayView<AbstractTexture* const> textures) {
|
||
|
10 years ago
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
12 years ago
|
|
||
|
|
/* Create array of IDs and also update bindings in state tracker */
|
||
|
11 years ago
|
/** @todo VLAs */
|
||
|
12 years ago
|
Containers::Array<GLuint> ids{textures ? textures.size() : 0};
|
||
|
12 years ago
|
bool different = false;
|
||
|
12 years ago
|
for(std::size_t i = 0; i != textures.size(); ++i) {
|
||
|
|
const GLuint id = textures && textures[i] ? textures[i]->_id : 0;
|
||
|
|
|
||
|
|
if(textures) {
|
||
|
|
if(textures[i]) textures[i]->createIfNotAlready();
|
||
|
|
ids[i] = id;
|
||
|
|
}
|
||
|
12 years ago
|
|
||
|
12 years ago
|
if(textureState.bindings[firstTextureUnit + i].second != id) {
|
||
|
12 years ago
|
different = true;
|
||
|
12 years ago
|
textureState.bindings[firstTextureUnit + i].second = id;
|
||
|
12 years ago
|
}
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
/* Avoid doing the binding if there is nothing different */
|
||
|
12 years ago
|
if(different) glBindTextures(firstTextureUnit, textures.size(), ids);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
Int AbstractTexture::compressedBlockDataSize(const GLenum target, const TextureFormat format) {
|
||
|
10 years ago
|
return (Context::current().state().texture->compressedBlockDataSizeImplementation)(target, format);
|
||
|
10 years ago
|
}
|
||
|
|
|
||
|
|
Int AbstractTexture::compressedBlockDataSizeImplementationDefault(const GLenum target, const TextureFormat format) {
|
||
|
11 years ago
|
GLint value;
|
||
|
|
glGetInternalformativ(target, GLenum(format), GL_TEXTURE_COMPRESSED_BLOCK_SIZE, 1, &value);
|
||
|
|
return value;
|
||
|
|
}
|
||
|
10 years ago
|
|
||
|
|
Int AbstractTexture::compressedBlockDataSizeImplementationBitsWorkaround(const GLenum target, const TextureFormat format) {
|
||
|
|
/* NVidia (358.16) reports the value in bits instead of bytes */
|
||
|
|
return compressedBlockDataSizeImplementationDefault(target, format)/8;
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
AbstractTexture::AbstractTexture(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->createImplementation)();
|
||
|
12 years ago
|
CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::createImplementationDefault() {
|
||
|
|
glGenTextures(1, &_id);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::createImplementationDSA() {
|
||
|
|
glCreateTextures(_target, 1, &_id);
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
AbstractTexture::~AbstractTexture() {
|
||
|
11 years ago
|
/* Moved out or not deleting on destruction, nothing to do */
|
||
|
|
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return;
|
||
|
14 years ago
|
|
||
|
14 years ago
|
/* Remove all bindings */
|
||
|
10 years ago
|
for(auto& binding: Context::current().state().texture->bindings) {
|
||
|
11 years ago
|
/* MSVC 2015 needs the parentheses around */
|
||
|
9 years ago
|
/* libstdc++ since GCC 6.3 can't handle just = {} (ambiguous overload
|
||
|
|
of operator=) */
|
||
|
|
if(binding.second == _id) binding = std::pair<GLenum, GLuint>{};
|
||
|
11 years ago
|
}
|
||
|
14 years ago
|
|
||
|
10 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
/* Remove all image bindings */
|
||
|
|
for(auto& binding: Context::current().state().texture->imageBindings) {
|
||
|
|
/* MSVC 2015 needs the parentheses around */
|
||
|
|
if(std::get<0>(binding) == _id) binding = {};
|
||
|
|
}
|
||
|
10 years ago
|
#endif
|
||
|
10 years ago
|
|
||
|
14 years ago
|
glDeleteTextures(1, &_id);
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::createIfNotAlready() {
|
||
|
11 years ago
|
if(_flags & ObjectFlag::Created) return;
|
||
|
12 years ago
|
|
||
|
|
/* glGen*() does not create the object, just reserves the name. Some
|
||
|
|
commands (such as glBindTextures() or glObjectLabel()) operate with IDs
|
||
|
|
directly and they require the object to be created. Binding the texture
|
||
|
|
to desired target finally creates it. Also all EXT DSA functions
|
||
|
|
implicitly create it. */
|
||
|
|
bindInternal();
|
||
|
11 years ago
|
CORRADE_INTERNAL_ASSERT(_flags & ObjectFlag::Created);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
12 years ago
|
std::string AbstractTexture::label() {
|
||
|
|
createIfNotAlready();
|
||
|
10 years ago
|
return Context::current().state().debug->getLabelImplementation(GL_TEXTURE, _id);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayView<const char> label) {
|
||
|
12 years ago
|
createIfNotAlready();
|
||
|
10 years ago
|
Context::current().state().debug->labelImplementation(GL_TEXTURE, _id, label);
|
||
|
13 years ago
|
return *this;
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
10 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
void AbstractTexture::unbindImage(const Int imageUnit) {
|
||
|
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
|
|
||
|
|
/* If already unbound in given image unit, nothing to do */
|
||
|
|
if(std::get<0>(textureState.imageBindings[imageUnit]) == 0) return;
|
||
|
|
|
||
|
|
/* Update state tracker, bind the texture to the unit */
|
||
|
|
std::get<0>(textureState.imageBindings[imageUnit]) = 0;
|
||
|
|
glBindImageTexture(imageUnit, 0, 0, false, 0, GL_READ_ONLY, GL_R8);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/** @todoc const Containers::ArrayView makes Doxygen grumpy */
|
||
|
|
void AbstractTexture::bindImagesInternal(const Int firstImageUnit, Containers::ArrayView<AbstractTexture* const> textures) {
|
||
|
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
|
|
||
|
|
/* Create array of IDs and also update bindings in state tracker */
|
||
|
|
Containers::Array<GLuint> ids{textures ? textures.size() : 0};
|
||
|
|
bool different = false;
|
||
|
|
for(std::size_t i = 0; i != textures.size(); ++i) {
|
||
|
|
const std::tuple<GLuint, GLint, GLboolean, GLint, GLenum> state = textures && textures[i] ?
|
||
|
|
std::tuple<GLuint, GLint, GLboolean, GLint, GLenum>(textures[i]->_id, 0, true, 0, GL_READ_WRITE) :
|
||
|
|
std::tuple<GLuint, GLint, GLboolean, GLint, GLenum>(0, 0, false, 0, GL_READ_ONLY);
|
||
|
|
|
||
|
|
if(textures) {
|
||
|
|
if(textures[i]) {
|
||
|
|
textures[i]->createIfNotAlready();
|
||
|
|
}
|
||
|
|
ids[i] = std::get<0>(state);
|
||
|
|
}
|
||
|
|
|
||
|
|
if(textureState.imageBindings[firstImageUnit + i] != state) {
|
||
|
|
different = true;
|
||
|
|
textureState.imageBindings[firstImageUnit + i] = state;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Avoid doing the binding if there is nothing different */
|
||
|
|
if(different) glBindImageTextures(firstImageUnit, textures.size(), ids);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void AbstractTexture::bindImageInternal(const Int imageUnit, const Int level, const bool layered, const Int layer, const ImageAccess access, const ImageFormat format) {
|
||
|
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
|
const std::tuple<GLuint, GLint, GLboolean, GLint, GLenum> state{_id, level, layered, layer, GLenum(access)};
|
||
|
|
|
||
|
|
/* If already bound in given texture unit, nothing to do */
|
||
|
|
if(textureState.imageBindings[imageUnit] == state) return;
|
||
|
|
|
||
|
|
/* Update state tracker, bind the texture to the unit */
|
||
|
|
textureState.imageBindings[imageUnit] = state;
|
||
|
|
glBindImageTexture(imageUnit, _id, level, layered, layer, GLenum(access), GLenum(format));
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::bind(Int textureUnit) {
|
||
|
10 years ago
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
14 years ago
|
|
||
|
12 years ago
|
/* If already bound in given texture unit, nothing to do */
|
||
|
12 years ago
|
if(textureState.bindings[textureUnit].second == _id) return;
|
||
|
14 years ago
|
|
||
|
12 years ago
|
/* Update state tracker, bind the texture to the unit */
|
||
|
12 years ago
|
textureState.bindings[textureUnit] = {_target, _id};
|
||
|
|
(this->*textureState.bindImplementation)(textureUnit);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::bindImplementationDefault(GLint textureUnit) {
|
||
|
10 years ago
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
14 years ago
|
|
||
|
12 years ago
|
/* Activate given texture unit if not already active, update state tracker */
|
||
|
12 years ago
|
if(textureState.currentTextureUnit != textureUnit)
|
||
|
|
glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = textureUnit));
|
||
|
14 years ago
|
|
||
|
12 years ago
|
/* Binding the texture finally creates it */
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glBindTexture(_target, _id);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::bindImplementationMulti(GLint textureUnit) {
|
||
|
12 years ago
|
createIfNotAlready();
|
||
|
12 years ago
|
glBindTextures(textureUnit, 1, &_id);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::bindImplementationDSA(const GLint textureUnit) {
|
||
|
|
glBindTextureUnit(textureUnit, _id);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::bindImplementationDSAEXT(GLint textureUnit) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, _target, _id);
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void AbstractTexture::setBaseLevel(Int level) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_BASE_LEVEL, level);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
12 years ago
|
void AbstractTexture::setMaxLevel(Int level) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
GL_TEXTURE_MAX_LEVEL
|
||
|
|
#else
|
||
|
|
GL_TEXTURE_MAX_LEVEL_APPLE
|
||
|
|
#endif
|
||
|
|
, level);
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
void AbstractTexture::setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap));
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::setMagnificationFilter(const Sampler::Filter filter) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_MAG_FILTER, GLint(filter));
|
||
|
15 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void AbstractTexture::setMinLod(const Float lod) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MIN_LOD, lod);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::setMaxLod(const Float lod) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MAX_LOD, lod);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::setLodBias(const Float bias) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_LOD_BIAS, bias);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
12 years ago
|
void AbstractTexture::setBorderColor(const Color4& color) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameterfvImplementation)(
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
11 years ago
|
GL_TEXTURE_BORDER_COLOR,
|
||
|
|
#else
|
||
|
|
GL_TEXTURE_BORDER_COLOR_EXT,
|
||
|
|
#endif
|
||
|
|
color.data());
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
void AbstractTexture::setBorderColor(const Vector4ui& color) {
|
||
|
9 years ago
|
(this->*Context::current().state().texture->parameterIuivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data());
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::setBorderColor(const Vector4i& color) {
|
||
|
9 years ago
|
(this->*Context::current().state().texture->parameterIivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data());
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
void AbstractTexture::setMaxAnisotropy(const Float anisotropy) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->setMaxAnisotropyImplementation)(anisotropy);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
12 years ago
|
void AbstractTexture::setSRGBDecode(bool decode) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SRGB_DECODE_EXT,
|
||
|
12 years ago
|
decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT);
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
void AbstractTexture::setSwizzleInternal(const GLint r, const GLint g, const GLint b, const GLint a) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
const GLint rgba[] = {r, g, b, a};
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameterivImplementation)(GL_TEXTURE_SWIZZLE_RGBA, rgba);
|
||
|
12 years ago
|
#else
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_R, r);
|
||
|
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_G, g);
|
||
|
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_B, b);
|
||
|
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_A, a);
|
||
|
12 years ago
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
12 years ago
|
void AbstractTexture::setCompareMode(const Sampler::CompareMode mode) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
GL_TEXTURE_COMPARE_MODE
|
||
|
|
#else
|
||
|
|
GL_TEXTURE_COMPARE_MODE_EXT
|
||
|
|
#endif
|
||
|
|
, GLenum(mode));
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::setCompareFunction(const Sampler::CompareFunction function) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
GL_TEXTURE_COMPARE_FUNC
|
||
|
|
#else
|
||
|
|
GL_TEXTURE_COMPARE_FUNC_EXT
|
||
|
|
#endif
|
||
|
|
, GLenum(function));
|
||
|
12 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
void AbstractTexture::setDepthStencilMode(const Sampler::DepthStencilMode mode) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode));
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::invalidateImage(const Int level) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->invalidateImageImplementation)(level);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::generateMipmap() {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->mipmapImplementation)();
|
||
|
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
|
||
|
12 years ago
|
void AbstractTexture::mipmapImplementationDSA() {
|
||
|
|
glGenerateTextureMipmap(_id);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::mipmapImplementationDSAEXT() {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
14 years ago
|
glGenerateTextureMipmapEXT(_id, _target);
|
||
|
15 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
15 years ago
|
|
||
|
14 years ago
|
void AbstractTexture::bindInternal() {
|
||
|
12 years ago
|
/* Using glBindTextures() here is meaningless, because the non-DSA
|
||
|
12 years ago
|
functions need to have the texture bound in *currently active* unit,
|
||
|
12 years ago
|
so we would need to call glActiveTexture() afterwards anyway. */
|
||
|
|
|
||
|
10 years ago
|
Implementation::TextureState& textureState = *Context::current().state().texture;
|
||
|
14 years ago
|
|
||
|
12 years ago
|
/* If the texture is already bound in current unit, nothing to do */
|
||
|
12 years ago
|
if(textureState.bindings[textureState.currentTextureUnit].second == _id)
|
||
|
14 years ago
|
return;
|
||
|
|
|
||
|
12 years ago
|
/* Set internal unit as active if not already, update state tracker */
|
||
|
12 years ago
|
CORRADE_INTERNAL_ASSERT(textureState.maxTextureUnits > 1);
|
||
|
|
const GLint internalTextureUnit = textureState.maxTextureUnits-1;
|
||
|
|
if(textureState.currentTextureUnit != internalTextureUnit)
|
||
|
|
glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = internalTextureUnit));
|
||
|
14 years ago
|
|
||
|
12 years ago
|
/* Bind the texture to internal unit if not already, update state tracker */
|
||
|
12 years ago
|
if(textureState.bindings[internalTextureUnit].second == _id) return;
|
||
|
|
textureState.bindings[internalTextureUnit] = {_target, _id};
|
||
|
12 years ago
|
|
||
|
|
/* Binding the texture finally creates it */
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glBindTexture(_target, _id);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
|
||
|
9 years ago
|
namespace {
|
||
|
|
|
||
|
|
PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) {
|
||
|
13 years ago
|
switch(internalFormat) {
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::Red:
|
||
|
|
case TextureFormat::R8:
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
13 years ago
|
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:
|
||
|
12 years ago
|
case TextureFormat::CompressedRedRgtc1:
|
||
|
13 years ago
|
case TextureFormat::CompressedSignedRedRgtc1:
|
||
|
11 years ago
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::CompressedR11Eac:
|
||
|
|
case TextureFormat::CompressedSignedR11Eac:
|
||
|
13 years ago
|
#endif
|
||
|
11 years ago
|
return PixelFormat::Red;
|
||
|
11 years ago
|
#endif
|
||
|
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:
|
||
|
11 years ago
|
return PixelFormat::RedInteger;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::RG:
|
||
|
|
case TextureFormat::RG8:
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
13 years ago
|
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:
|
||
|
11 years ago
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::CompressedRG11Eac:
|
||
|
|
case TextureFormat::CompressedSignedRG11Eac:
|
||
|
13 years ago
|
#endif
|
||
|
11 years ago
|
return PixelFormat::RG;
|
||
|
11 years ago
|
#endif
|
||
|
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:
|
||
|
11 years ago
|
return PixelFormat::RGInteger;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
case TextureFormat::RGB:
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::RGB8:
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
#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:
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
case TextureFormat::RGB10:
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGB12:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R11FG11FB10F:
|
||
|
|
case TextureFormat::RGB9E5:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::CompressedRGB:
|
||
|
|
case TextureFormat::CompressedRGBBptcUnsignedFloat:
|
||
|
|
case TextureFormat::CompressedRGBBptcSignedFloat:
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::CompressedRGB8Etc2:
|
||
|
|
case TextureFormat::CompressedSRGB8Etc2:
|
||
|
|
#endif
|
||
|
11 years ago
|
case TextureFormat::CompressedRGBS3tcDxt1:
|
||
|
11 years ago
|
return PixelFormat::RGB;
|
||
|
13 years ago
|
|
||
|
9 years ago
|
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
|
||
|
|
case TextureFormat::SRGB:
|
||
|
|
#endif
|
||
|
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
|
case TextureFormat::SRGB8:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
return PixelFormat::RGB;
|
||
|
|
#else
|
||
|
|
return PixelFormat::SRGB;
|
||
|
|
#endif
|
||
|
|
|
||
|
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:
|
||
|
11 years ago
|
return PixelFormat::RGBInteger;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
case TextureFormat::RGBA:
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::RGBA8:
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
#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:
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::RGB10A2:
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGBA12:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::CompressedRGBA:
|
||
|
|
case TextureFormat::CompressedRGBABptcUnorm:
|
||
|
|
case TextureFormat::CompressedSRGBAlphaBptcUnorm:
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::CompressedRGB8PunchthroughAlpha1Etc2:
|
||
|
|
case TextureFormat::CompressedSRGB8PunchthroughAlpha1Etc2:
|
||
|
|
case TextureFormat::CompressedRGBA8Etc2Eac:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Etc2Eac:
|
||
|
|
#endif
|
||
|
11 years ago
|
case TextureFormat::CompressedRGBAS3tcDxt1:
|
||
|
|
case TextureFormat::CompressedRGBAS3tcDxt3:
|
||
|
|
case TextureFormat::CompressedRGBAS3tcDxt5:
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
|
case TextureFormat::CompressedRGBAAstc4x4:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc4x4:
|
||
|
|
case TextureFormat::CompressedRGBAAstc5x4:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc5x4:
|
||
|
|
case TextureFormat::CompressedRGBAAstc5x5:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc5x5:
|
||
|
|
case TextureFormat::CompressedRGBAAstc6x5:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc6x5:
|
||
|
|
case TextureFormat::CompressedRGBAAstc6x6:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc6x6:
|
||
|
|
case TextureFormat::CompressedRGBAAstc8x5:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc8x5:
|
||
|
|
case TextureFormat::CompressedRGBAAstc8x6:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc8x6:
|
||
|
|
case TextureFormat::CompressedRGBAAstc8x8:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc8x8:
|
||
|
|
case TextureFormat::CompressedRGBAAstc10x5:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc10x5:
|
||
|
|
case TextureFormat::CompressedRGBAAstc10x6:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc10x6:
|
||
|
|
case TextureFormat::CompressedRGBAAstc10x8:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc10x8:
|
||
|
|
case TextureFormat::CompressedRGBAAstc10x10:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc10x10:
|
||
|
|
case TextureFormat::CompressedRGBAAstc12x10:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc12x10:
|
||
|
|
case TextureFormat::CompressedRGBAAstc12x12:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc12x12:
|
||
|
|
#endif
|
||
|
11 years ago
|
return PixelFormat::RGBA;
|
||
|
13 years ago
|
|
||
|
9 years ago
|
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
|
||
|
|
case TextureFormat::SRGBAlpha:
|
||
|
|
#endif
|
||
|
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
|
case TextureFormat::SRGB8Alpha8:
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
return PixelFormat::RGBA;
|
||
|
|
#else
|
||
|
|
return PixelFormat::SRGBAlpha;
|
||
|
|
#endif
|
||
|
|
|
||
|
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:
|
||
|
11 years ago
|
return PixelFormat::RGBAInteger;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::Luminance:
|
||
|
11 years ago
|
return PixelFormat::Luminance;
|
||
|
13 years ago
|
case TextureFormat::LuminanceAlpha:
|
||
|
11 years ago
|
return PixelFormat::LuminanceAlpha;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
case TextureFormat::DepthComponent:
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::DepthComponent16:
|
||
|
|
case TextureFormat::DepthComponent24:
|
||
|
11 years ago
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
13 years ago
|
case TextureFormat::DepthComponent32:
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::DepthComponent32F:
|
||
|
|
#endif
|
||
|
11 years ago
|
return PixelFormat::DepthComponent;
|
||
|
13 years ago
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
13 years ago
|
case TextureFormat::StencilIndex8:
|
||
|
11 years ago
|
return PixelFormat::StencilIndex;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
13 years ago
|
case TextureFormat::DepthStencil:
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::Depth24Stencil8:
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::Depth32FStencil8:
|
||
|
|
#endif
|
||
|
11 years ago
|
return PixelFormat::DepthStencil;
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
10 years ago
|
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) {
|
||
|
13 years ago
|
switch(internalFormat) {
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::Red:
|
||
|
|
case TextureFormat::RG:
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
case TextureFormat::RGB:
|
||
|
|
case TextureFormat::RGBA:
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::R8:
|
||
|
|
case TextureFormat::RG8:
|
||
|
|
case TextureFormat::RGB8:
|
||
|
|
case TextureFormat::RGBA8:
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
#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
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
|
||
|
13 years ago
|
case TextureFormat::SRGB:
|
||
|
|
case TextureFormat::SRGBAlpha:
|
||
|
11 years ago
|
#endif
|
||
|
9 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
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:
|
||
|
12 years ago
|
case TextureFormat::CompressedRedRgtc1:
|
||
|
13 years ago
|
case TextureFormat::CompressedRGRgtc2:
|
||
|
|
case TextureFormat::CompressedRGBABptcUnorm:
|
||
|
|
case TextureFormat::CompressedSRGBAlphaBptcUnorm:
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::CompressedRGB8Etc2:
|
||
|
|
case TextureFormat::CompressedSRGB8Etc2:
|
||
|
|
case TextureFormat::CompressedRGB8PunchthroughAlpha1Etc2:
|
||
|
|
case TextureFormat::CompressedSRGB8PunchthroughAlpha1Etc2:
|
||
|
|
case TextureFormat::CompressedRGBA8Etc2Eac:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Etc2Eac:
|
||
|
|
case TextureFormat::CompressedR11Eac:
|
||
|
|
case TextureFormat::CompressedSignedR11Eac:
|
||
|
|
case TextureFormat::CompressedRG11Eac:
|
||
|
|
case TextureFormat::CompressedSignedRG11Eac:
|
||
|
|
#endif
|
||
|
11 years ago
|
case TextureFormat::CompressedRGBS3tcDxt1:
|
||
|
|
case TextureFormat::CompressedRGBAS3tcDxt1:
|
||
|
|
case TextureFormat::CompressedRGBAS3tcDxt3:
|
||
|
|
case TextureFormat::CompressedRGBAS3tcDxt5:
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
|
case TextureFormat::CompressedRGBAAstc4x4:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc4x4:
|
||
|
|
case TextureFormat::CompressedRGBAAstc5x4:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc5x4:
|
||
|
|
case TextureFormat::CompressedRGBAAstc5x5:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc5x5:
|
||
|
|
case TextureFormat::CompressedRGBAAstc6x5:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc6x5:
|
||
|
|
case TextureFormat::CompressedRGBAAstc6x6:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc6x6:
|
||
|
|
case TextureFormat::CompressedRGBAAstc8x5:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc8x5:
|
||
|
|
case TextureFormat::CompressedRGBAAstc8x6:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc8x6:
|
||
|
|
case TextureFormat::CompressedRGBAAstc8x8:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc8x8:
|
||
|
|
case TextureFormat::CompressedRGBAAstc10x5:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc10x5:
|
||
|
|
case TextureFormat::CompressedRGBAAstc10x6:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc10x6:
|
||
|
|
case TextureFormat::CompressedRGBAAstc10x8:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc10x8:
|
||
|
|
case TextureFormat::CompressedRGBAAstc10x10:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc10x10:
|
||
|
|
case TextureFormat::CompressedRGBAAstc12x10:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc12x10:
|
||
|
|
case TextureFormat::CompressedRGBAAstc12x12:
|
||
|
|
case TextureFormat::CompressedSRGB8Alpha8Astc12x12:
|
||
|
|
#endif
|
||
|
11 years ago
|
return PixelType::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
|
||
|
11 years ago
|
return PixelType::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
|
||
|
11 years ago
|
return PixelType::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:
|
||
|
11 years ago
|
return PixelType::Short;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R16F:
|
||
|
|
case TextureFormat::RG16F:
|
||
|
|
case TextureFormat::RGB16F:
|
||
|
|
case TextureFormat::RGBA16F:
|
||
|
11 years ago
|
return PixelType::HalfFloat;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::R32UI:
|
||
|
|
case TextureFormat::RG32UI:
|
||
|
|
case TextureFormat::RGB32UI:
|
||
|
|
case TextureFormat::RGBA32UI:
|
||
|
11 years ago
|
return PixelType::UnsignedInt;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::R32I:
|
||
|
|
case TextureFormat::RG32I:
|
||
|
|
case TextureFormat::RGB32I:
|
||
|
|
case TextureFormat::RGBA32I:
|
||
|
11 years ago
|
return PixelType::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
|
||
|
11 years ago
|
return PixelType::Float;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::R3B3G2:
|
||
|
11 years ago
|
return PixelType::UnsignedByte332;
|
||
|
13 years ago
|
case TextureFormat::RGB4:
|
||
|
11 years ago
|
return PixelType::UnsignedShort4444;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
case TextureFormat::RGB5:
|
||
|
|
#endif
|
||
|
|
case TextureFormat::RGB5A1:
|
||
|
11 years ago
|
return PixelType::UnsignedShort5551;
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::RGB565:
|
||
|
11 years ago
|
return PixelType::UnsignedShort565;
|
||
|
13 years ago
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
|
||
|
13 years ago
|
case TextureFormat::RGB10:
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
case TextureFormat::RGB10A2:
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::RGB10A2UI:
|
||
|
|
#endif
|
||
|
11 years ago
|
return PixelType::UnsignedInt2101010Rev; /**< @todo Rev for all? */
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::R11FG11FB10F:
|
||
|
11 years ago
|
return PixelType::UnsignedInt10F11F11FRev;
|
||
|
13 years ago
|
case TextureFormat::RGB9E5:
|
||
|
11 years ago
|
return PixelType::UnsignedInt5999Rev;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::DepthComponent16:
|
||
|
11 years ago
|
return PixelType::UnsignedShort;
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
case TextureFormat::DepthComponent:
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::DepthComponent24:
|
||
|
11 years ago
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
13 years ago
|
case TextureFormat::DepthComponent32:
|
||
|
11 years ago
|
#endif
|
||
|
11 years ago
|
return PixelType::UnsignedInt;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::DepthComponent32F:
|
||
|
11 years ago
|
return PixelType::Float;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
13 years ago
|
case TextureFormat::StencilIndex8:
|
||
|
11 years ago
|
return PixelType::UnsignedByte;
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
13 years ago
|
case TextureFormat::DepthStencil:
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
13 years ago
|
case TextureFormat::Depth24Stencil8:
|
||
|
11 years ago
|
#endif
|
||
|
11 years ago
|
return PixelType::UnsignedInt248;
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
case TextureFormat::Depth32FStencil8:
|
||
|
11 years ago
|
return PixelType::Float32UnsignedInt248Rev;
|
||
|
13 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
10 years ago
|
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
|
||
|
13 years ago
|
}
|
||
|
9 years ago
|
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
14 years ago
|
void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLint value) {
|
||
|
|
bindInternal();
|
||
|
|
glTexParameteri(_target, parameter, value);
|
||
|
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLint value) {
|
||
|
|
glTextureParameteri(_id, parameter, value);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLint value) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
14 years ago
|
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
|
||
|
12 years ago
|
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLfloat value) {
|
||
|
|
glTextureParameterf(_id, parameter, value);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLfloat value) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
14 years ago
|
glTextureParameterfEXT(_id, _target, parameter, value);
|
||
|
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLint* values) {
|
||
|
|
bindInternal();
|
||
|
|
glTexParameteriv(_target, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLint* const values) {
|
||
|
|
glTextureParameteriv(_id, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, const GLint* values) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureParameterivEXT(_id, _target, parameter, values);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
|
||
|
14 years ago
|
void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLfloat* values) {
|
||
|
|
bindInternal();
|
||
|
|
glTexParameterfv(_target, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLfloat* const values) {
|
||
|
|
glTextureParameterfv(_id, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, const GLfloat* values) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
14 years ago
|
glTextureParameterfvEXT(_id, _target, parameter, values);
|
||
|
|
}
|
||
|
13 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GLuint* values) {
|
||
|
12 years ago
|
bindInternal();
|
||
|
9 years ago
|
glTexParameterIuiv(_target, parameter, values);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::parameterIImplementationEXT(GLenum parameter, const GLuint* values) {
|
||
|
|
bindInternal();
|
||
|
|
glTexParameterIuivEXT(_target, parameter, values);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::parameterIImplementationDSA(const GLenum parameter, const GLuint* const values) {
|
||
|
|
glTextureParameterIuiv(_id, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLuint* values) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureParameterIuivEXT(_id, _target, parameter, values);
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GLint* values) {
|
||
|
12 years ago
|
bindInternal();
|
||
|
9 years ago
|
glTexParameterIiv(_target, parameter, values);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::parameterIImplementationEXT(GLenum parameter, const GLint* values) {
|
||
|
|
bindInternal();
|
||
|
|
glTexParameterIivEXT(_target, parameter, values);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::parameterIImplementationDSA(const GLenum parameter, const GLint* const values) {
|
||
|
|
glTextureParameterIiv(_id, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLint* values) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureParameterIivEXT(_id, _target, parameter, values);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
13 years ago
|
void AbstractTexture::setMaxAnisotropyImplementationNoOp(GLfloat) {}
|
||
|
|
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::setMaxAnisotropyImplementationArb(GLfloat anisotropy) {
|
||
|
|
(this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY, anisotropy);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) {
|
||
|
10 years ago
|
(this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
void AbstractTexture::getLevelParameterImplementationDefault(const GLint level, const GLenum parameter, GLint* const values) {
|
||
|
13 years ago
|
bindInternal();
|
||
|
10 years ago
|
glGetTexLevelParameteriv(_target, level, parameter, values);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
void AbstractTexture::getLevelParameterImplementationDSA(const GLint level, const GLenum parameter, GLint* const values) {
|
||
|
12 years ago
|
glGetTextureLevelParameteriv(_id, level, parameter, values);
|
||
|
|
}
|
||
|
|
|
||
|
10 years ago
|
void AbstractTexture::getLevelParameterImplementationDSAEXT(const GLint level, const GLenum parameter, GLint* const values) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
10 years ago
|
glGetTextureLevelParameterivEXT(_id, _target, level, parameter, values);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
|
||
|
9 years ago
|
const PixelFormat format = pixelFormatForInternalFormat(internalFormat);
|
||
|
|
const PixelType type = pixelTypeForInternalFormat(internalFormat);
|
||
|
13 years ago
|
|
||
|
12 years ago
|
for(GLsizei level = 0; level != levels; ++level)
|
||
|
12 years ago
|
DataHelper<1>::setImage(*this, level, internalFormat,
|
||
|
11 years ago
|
ImageView1D{format, type, Math::max(Math::Vector<1, GLsizei>(1), size >> level)});
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
12 years ago
|
glTexStorage1D(_target, levels, GLenum(internalFormat), size[0]);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
|
||
|
|
glTextureStorage1D(_id, levels, GLenum(internalFormat), size[0]);
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureStorage1DEXT(_id, _target, levels, GLenum(internalFormat), size[0]);
|
||
|
14 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
|
||
|
9 years ago
|
const PixelFormat format = pixelFormatForInternalFormat(internalFormat);
|
||
|
|
const PixelType type = pixelTypeForInternalFormat(internalFormat);
|
||
|
13 years ago
|
|
||
|
9 years ago
|
/* If EXT_texture_storage is not available on ES2, passing e.g.
|
||
|
|
TextureFormat::RGBA8 would cause an error. On ES2 it's required to have
|
||
|
|
internalFormat equal to format, so we do exactly that. */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
const TextureFormat finalInternalFormat = internalFormat;
|
||
|
|
#else
|
||
|
|
const TextureFormat finalInternalFormat = TextureFormat(GLenum(format));
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
/* Common code for classic types */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
if(_target == GL_TEXTURE_2D || _target == GL_TEXTURE_RECTANGLE)
|
||
|
13 years ago
|
#else
|
||
|
12 years ago
|
if(_target == GL_TEXTURE_2D)
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
12 years ago
|
for(GLsizei level = 0; level != levels; ++level)
|
||
|
9 years ago
|
DataHelper<2>::setImage(*this, level, finalInternalFormat,
|
||
|
11 years ago
|
ImageView2D{format, type, Math::max(Vector2i(1), size >> level)});
|
||
|
13 years ago
|
|
||
|
13 years ago
|
/* Cube map additionally needs to specify all faces */
|
||
|
12 years ago
|
} else if(_target == GL_TEXTURE_CUBE_MAP) {
|
||
|
13 years ago
|
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})
|
||
|
9 years ago
|
DataHelper<2>::setImage(*this, face, level, finalInternalFormat,
|
||
|
11 years ago
|
ImageView2D{format, type, Math::max(Vector2i(1), size >> level)});
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Array texture is not scaled in "layer" dimension */
|
||
|
12 years ago
|
} else if(_target == GL_TEXTURE_1D_ARRAY) {
|
||
|
12 years ago
|
for(GLsizei level = 0; level != levels; ++level)
|
||
|
12 years ago
|
DataHelper<2>::setImage(*this, level, internalFormat,
|
||
|
11 years ago
|
ImageView2D{format, type, Vector2i{Math::max(1, size.x() >> level), size.y()}});
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
/* No other targets are available */
|
||
|
10 years ago
|
} else CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
glTexStorage2D(_target, levels, GLenum(internalFormat), size.x(), size.y());
|
||
|
14 years ago
|
#else
|
||
|
9 years ago
|
glTexStorage2DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y());
|
||
|
14 years ago
|
#endif
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
|
||
|
|
glTextureStorage2D(_id, levels, GLenum(internalFormat), size.x(), size.y());
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureStorage2DEXT(_id, _target, levels, GLenum(internalFormat), size.x(), size.y());
|
||
|
14 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
|
||
|
9 years ago
|
const PixelFormat format = pixelFormatForInternalFormat(internalFormat);
|
||
|
|
const PixelType type = pixelTypeForInternalFormat(internalFormat);
|
||
|
13 years ago
|
|
||
|
9 years ago
|
/* If EXT_texture_storage is not available on ES2, passing e.g.
|
||
|
|
TextureFormat::RGBA8 would cause an error. On ES2 it's required to have
|
||
|
|
internalFormat equal to format, so we do exactly that. */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
const TextureFormat finalInternalFormat = internalFormat;
|
||
|
|
#else
|
||
|
|
const TextureFormat finalInternalFormat = TextureFormat(GLenum(format));
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
/* Common code for classic type */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
if(_target == GL_TEXTURE_3D)
|
||
|
13 years ago
|
#else
|
||
|
12 years ago
|
if(_target == GL_TEXTURE_3D_OES)
|
||
|
13 years ago
|
#endif
|
||
|
12 years ago
|
for(GLsizei level = 0; level != levels; ++level)
|
||
|
9 years ago
|
DataHelper<3>::setImage(*this, level, finalInternalFormat,
|
||
|
11 years ago
|
ImageView3D{format, type, Math::max(Vector3i(1), size >> level)});
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
/* Array texture is not scaled in "layer" dimension */
|
||
|
9 years ago
|
else if(_target == GL_TEXTURE_2D_ARRAY || _target ==
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
GL_TEXTURE_CUBE_MAP_ARRAY
|
||
|
|
#else
|
||
|
|
GL_TEXTURE_CUBE_MAP_ARRAY_EXT
|
||
|
|
#endif
|
||
|
|
) {
|
||
|
12 years ago
|
for(GLsizei level = 0; level != levels; ++level)
|
||
|
12 years ago
|
DataHelper<3>::setImage(*this, level, internalFormat,
|
||
|
11 years ago
|
ImageView3D{format, type, Vector3i{Math::max(Vector2i{1}, size.xy() >> level), size.z()}});
|
||
|
9 years ago
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
/* No other targets are available */
|
||
|
10 years ago
|
else CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
glTexStorage3D(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
|
||
|
14 years ago
|
#else
|
||
|
9 years ago
|
glTexStorage3DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
|
||
|
14 years ago
|
#endif
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) {
|
||
|
|
glTextureStorage3D(_id, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureStorage3DEXT(_id, _target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
|
||
|
14 years ago
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::storageMultisampleImplementationFallback(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
|
||
|
12 years ago
|
bindInternal();
|
||
|
12 years ago
|
glTexImage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
|
||
|
12 years ago
|
}
|
||
|
12 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
void AbstractTexture::storageMultisampleImplementationDefault(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
|
||
|
12 years ago
|
bindInternal();
|
||
|
12 years ago
|
glTexStorage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
|
||
|
12 years ago
|
}
|
||
|
12 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
|
||
|
|
glTextureStorage2DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureStorage2DMultisampleEXT(_id, _target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::storageMultisampleImplementationFallback(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
|
||
|
12 years ago
|
bindInternal();
|
||
|
12 years ago
|
glTexImage3DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
|
||
|
12 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
void AbstractTexture::storageMultisampleImplementationDefault(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
|
||
|
12 years ago
|
bindInternal();
|
||
|
9 years ago
|
glTexStorage3DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::storageMultisampleImplementationOES(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
|
||
|
|
bindInternal();
|
||
|
|
glTexStorage3DMultisampleOES(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
|
||
|
12 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
9 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
|
||
|
|
glTextureStorage3DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
|
||
|
|
}
|
||
|
|
|
||
|
|
void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureStorage3DMultisampleEXT(_id, _target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
11 years ago
|
void AbstractTexture::getImageImplementationDefault(const GLint level, const PixelFormat format, const PixelType type, const std::size_t, GLvoid* const data) {
|
||
|
13 years ago
|
bindInternal();
|
||
|
12 years ago
|
glGetTexImage(_target, level, GLenum(format), GLenum(type), data);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::getCompressedImageImplementationDefault(const GLint level, std::size_t, GLvoid* const data) {
|
||
|
|
bindInternal();
|
||
|
|
glGetCompressedTexImage(_target, level, data);
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::getImageImplementationDSA(const GLint level, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) {
|
||
|
12 years ago
|
glGetTextureImage(_id, level, GLenum(format), GLenum(type), dataSize, data);
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::getCompressedImageImplementationDSA(const GLint level, const std::size_t dataSize, GLvoid* const data) {
|
||
|
|
glGetCompressedTextureImage(_id, level, dataSize, data);
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::getImageImplementationDSAEXT(const GLint level, const PixelFormat format, const PixelType type, const std::size_t, GLvoid* const data) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glGetTextureImageEXT(_id, _target, level, GLenum(format), GLenum(type), data);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::getCompressedImageImplementationDSAEXT(const GLint level, std::size_t, GLvoid* const data) {
|
||
|
|
_flags |= ObjectFlag::Created;
|
||
|
|
glGetCompressedTextureImageEXT(_id, _target, level, data);
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::getImageImplementationRobustness(const GLint level, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) {
|
||
|
13 years ago
|
bindInternal();
|
||
|
12 years ago
|
glGetnTexImageARB(_target, level, GLenum(format), GLenum(type), dataSize, data);
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
void AbstractTexture::getCompressedImageImplementationRobustness(const GLint level, const std::size_t dataSize, GLvoid* const data) {
|
||
|
|
bindInternal();
|
||
|
|
glGetnCompressedTexImageARB(_target, level, dataSize, data);
|
||
|
|
}
|
||
|
13 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
11 years ago
|
void AbstractTexture::subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
12 years ago
|
glTexSubImage1D(_target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
11 years ago
|
bindInternal();
|
||
|
11 years ago
|
glCompressedTexSubImage1D(_target, level, offset[0], size[0], GLenum(format), dataSize, data);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::subImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const PixelFormat format, const PixelType type, const GLvoid* const data) {
|
||
|
12 years ago
|
glTextureSubImage1D(_id, level, offset[0], size[0], GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
|
glCompressedTextureSubImage1D(_id, level, offset[0], size[0], GLenum(format), dataSize, data);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureSubImage1DEXT(_id, _target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
11 years ago
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDSAEXT(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
11 years ago
|
glCompressedTextureSubImage1DEXT(_id, _target, level, offset[0], size[0], GLenum(format), dataSize, data);
|
||
|
11 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
9 years ago
|
void AbstractTexture::imageImplementationDefault(const GLenum target, const GLint level, const TextureFormat internalFormat, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) {
|
||
|
|
bindInternal();
|
||
|
|
glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void AbstractTexture::imageImplementationSvga3DSliceBySlice(const GLenum target, const GLint level, const TextureFormat internalFormat, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) {
|
||
|
|
/* Allocate and upload the first slice */
|
||
|
|
imageImplementationDefault(target, level, internalFormat, size, format, type, data, storage);
|
||
|
|
|
||
|
|
/* Upload the next slices slice by slice only if this is an array texture
|
||
|
|
with more than one slice and we are copying from user memory (not from a
|
||
|
|
buffer). The hard work is done by the subImage() implementation.
|
||
|
|
Moreover, I am simply calling the default implementation and not the DSA
|
||
|
|
one as just using glTexImage() pollutes the state already anyway so the
|
||
|
|
DSA cleanness is not worth it. */
|
||
|
|
/** @todo this will break when we support uploading from buffer offset (i.e. data != nullptr) */
|
||
|
|
if(target == GL_TEXTURE_1D_ARRAY && data && size.y() > 1)
|
||
|
|
subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(level, {0, 1}, {size.x(), size.y() - 1}, format, type, static_cast<const char*>(data) + std::get<1>(storage.dataProperties(format, type, {size, 1})).x(), storage);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void AbstractTexture::subImage2DImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
12 years ago
|
glTexSubImage2D(_target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
/* Doxygen gets confused by the template parameter */
|
||
|
|
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_GLES)
|
||
|
9 years ago
|
template<void(AbstractTexture::*original)(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&)> void AbstractTexture::subImageImplementationSvga3DSliceBySlice(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* const data, const PixelStorage& storage) {
|
||
|
|
/* Upload the data slice by slice only if this is an array texture and we
|
||
|
|
are copying from user memory (not from a buffer) */
|
||
|
|
if(_target == GL_TEXTURE_1D_ARRAY && data) {
|
||
|
|
const std::size_t stride = std::get<1>(storage.dataProperties(format, type, {size, 1})).x();
|
||
|
|
for(Int i = 0; i != size.y(); ++i)
|
||
|
|
(this->*original)(level, {offset.x(), offset.y() + i}, {size.x(), 1}, format, type, static_cast<const char*>(data) + stride*i, storage);
|
||
|
|
|
||
|
|
/* Otherwise just pass-though to the default implementation */
|
||
|
|
} else (this->*original)(level, offset, size, format, type, data, storage);
|
||
|
|
}
|
||
|
|
|
||
|
|
template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&);
|
||
|
|
template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDSA>(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&);
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
11 years ago
|
bindInternal();
|
||
|
11 years ago
|
glCompressedTexSubImage2D(_target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
void AbstractTexture::subImage2DImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) {
|
||
|
12 years ago
|
glTextureSubImage2D(_id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
|
glCompressedTextureSubImage2D(_id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 years ago
|
glTextureSubImage2DEXT(_id, _target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
|
||
|
14 years ago
|
}
|
||
|
11 years ago
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
11 years ago
|
glCompressedTextureSubImage2DEXT(_id, _target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data);
|
||
|
11 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
9 years ago
|
void AbstractTexture::imageImplementationDefault(GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) {
|
||
|
|
bindInternal();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
glTexImage3D
|
||
|
|
#else
|
||
|
|
glTexImage3DOES
|
||
|
|
#endif
|
||
|
|
(_target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
|
void AbstractTexture::imageImplementationSvga3DSliceBySlice(GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage& storage) {
|
||
|
|
/* Allocate and upload the first slice */
|
||
|
|
imageImplementationDefault(level, internalFormat, size, format, type, data, storage);
|
||
|
|
|
||
|
|
/* Upload the next slices slice by slice only if this is an array texture
|
||
|
|
with more than one slice or a 3D texture and we are copying from user
|
||
|
|
memory (not from a buffer). The hard work is done by the subImage()
|
||
|
|
implementation. Moreover, I am simply calling the default implementation
|
||
|
|
and not the DSA one as just using glTexImage() pollutes the state
|
||
|
|
already anyway so the DSA cleanness is not worth it. */
|
||
|
|
/** @todo this will break when we support uploading from buffer offset (i.e. data != nullptr) */
|
||
|
|
if((
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
_target == GL_TEXTURE_2D_ARRAY || _target == GL_TEXTURE_3D
|
||
|
|
#else
|
||
|
|
_target == GL_TEXTURE_3D_OES
|
||
|
|
#endif
|
||
|
|
) && data && size.z() > 1)
|
||
|
|
{
|
||
|
|
subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(level, {0, 0, 1}, {size.xy(), size.z() - 1}, format, type, static_cast<const char*>(data) + std::get<1>(storage.dataProperties(format, type, size)).xy().product(), storage);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void AbstractTexture::subImage3DImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) {
|
||
|
14 years ago
|
bindInternal();
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 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
|
||
|
9 years ago
|
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
|
}
|
||
|
11 years ago
|
|
||
|
9 years ago
|
/* Doxygen gets confused by the template parameter */
|
||
|
|
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
template<void(AbstractTexture::*original)(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&)> void AbstractTexture::subImageImplementationSvga3DSliceBySlice(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* const data, const PixelStorage& storage) {
|
||
|
9 years ago
|
/* Upload the data slice by slice only if this is an array texture and we
|
||
|
|
are copying from user memory (not from a buffer) */
|
||
|
|
if(
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
_target == GL_TEXTURE_2D_ARRAY || _target == GL_TEXTURE_3D
|
||
|
|
#else
|
||
|
|
_target == GL_TEXTURE_3D_OES
|
||
|
|
#endif
|
||
|
|
)
|
||
|
|
{
|
||
|
|
const std::size_t stride = std::get<1>(storage.dataProperties(format, type, size)).xy().product();
|
||
|
|
for(Int i = 0; i != size.z(); ++i)
|
||
|
|
(this->*original)(level, {offset.xy(), offset.z() + i}, {size.xy(), 1}, format, type, static_cast<const char*>(data) + stride*i, storage);
|
||
|
|
|
||
|
|
/* Otherwise just pass-though to the default implementation */
|
||
|
|
} else (this->*original)(level, offset, size, format, type, data, storage);
|
||
|
|
}
|
||
|
|
|
||
|
|
template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&);
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
template void AbstractTexture::subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDSA>(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&);
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
11 years ago
|
bindInternal();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
11 years ago
|
glCompressedTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data);
|
||
|
11 years ago
|
#else
|
||
|
9 years ago
|
glCompressedTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data);
|
||
|
11 years ago
|
#endif
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
void AbstractTexture::subImage3DImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage&) {
|
||
|
12 years ago
|
glTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
|
glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
12 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
|
}
|
||
|
11 years ago
|
|
||
|
11 years ago
|
void AbstractTexture::compressedSubImageImplementationDSAEXT(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) {
|
||
|
11 years ago
|
_flags |= ObjectFlag::Created;
|
||
|
11 years ago
|
glCompressedTextureSubImage3DEXT(_id, _target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data);
|
||
|
11 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) {
|
||
|
12 years ago
|
createIfNotAlready();
|
||
|
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) {
|
||
|
12 years ago
|
createIfNotAlready();
|
||
|
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
|
||
|
12 years ago
|
template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Image<dimensions>& image) {
|
||
|
10 years ago
|
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
|
||
|
11 years ago
|
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};
|
||
|
11 years ago
|
|
||
|
11 years ago
|
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
|
||
|
11 years ago
|
image.storage().applyPack();
|
||
|
10 years ago
|
(this->*Context::current().state().texture->getImageImplementation)(level, image.format(), image.type(), data.size(), data);
|
||
|
8 years ago
|
image = Image<dimensions>{image.storage(), image.format(), image.type(), size, std::move(data)};
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, Image<1>&);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::image<2>(GLint, Image<2>&);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::image<3>(GLint, Image<3>&);
|
||
|
13 years ago
|
|
||
|
12 years ago
|
template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, BufferImage<dimensions>& image, BufferUsage usage) {
|
||
|
10 years ago
|
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
|
||
|
11 years ago
|
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size);
|
||
|
11 years ago
|
|
||
|
|
/* Reallocate only if needed */
|
||
|
|
if(image.dataSize() < dataSize)
|
||
|
11 years ago
|
image.setData(image.storage(), image.format(), image.type(), size, {nullptr, dataSize}, usage);
|
||
|
11 years ago
|
else
|
||
|
|
image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage);
|
||
|
13 years ago
|
|
||
|
12 years ago
|
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
|
||
|
11 years ago
|
image.storage().applyPack();
|
||
|
10 years ago
|
(this->*Context::current().state().texture->getImageImplementation)(level, image.format(), image.type(), dataSize, nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, BufferImage<1>&, BufferUsage);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::image<2>(GLint, BufferImage<2>&, BufferUsage);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::image<3>(GLint, BufferImage<3>&, BufferUsage);
|
||
|
11 years ago
|
|
||
|
11 years ago
|
template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedImage<dimensions>& image) {
|
||
|
10 years ago
|
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
|
||
|
9 years ago
|
|
||
|
|
/* If the user-provided pixel storage doesn't tell us all properties about
|
||
|
|
the compression, we need to ask GL for it */
|
||
|
|
std::size_t dataSize;
|
||
|
|
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) {
|
||
|
|
GLint textureDataSize;
|
||
|
|
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
|
||
|
|
dataSize = textureDataSize;
|
||
|
|
} else dataSize = Implementation::compressedImageDataSizeFor(image, size);
|
||
|
|
|
||
|
|
/* Internal texture format */
|
||
|
11 years ago
|
GLint format;
|
||
|
10 years ago
|
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
|
||
|
11 years ago
|
|
||
|
|
/* Reallocate only if needed */
|
||
|
|
Containers::Array<char> data{image.release()};
|
||
|
|
if(data.size() < dataSize)
|
||
|
|
data = Containers::Array<char>{dataSize};
|
||
|
11 years ago
|
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
|
||
|
11 years ago
|
image.storage().applyPack();
|
||
|
10 years ago
|
(this->*Context::current().state().texture->getCompressedImageImplementation)(level, data.size(), data);
|
||
|
8 years ago
|
image = CompressedImage<dimensions>{image.storage(), CompressedPixelFormat(format), size, std::move(data)};
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedImage<1>&);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<2>(GLint, CompressedImage<2>&);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<3>(GLint, CompressedImage<3>&);
|
||
|
11 years ago
|
|
||
|
|
template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedBufferImage<dimensions>& image, BufferUsage usage) {
|
||
|
10 years ago
|
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
|
||
|
9 years ago
|
|
||
|
|
/* If the user-provided pixel storage doesn't tell us all properties about
|
||
|
|
the compression, we need to ask GL for it */
|
||
|
|
std::size_t dataSize;
|
||
|
|
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) {
|
||
|
|
GLint textureDataSize;
|
||
|
|
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize);
|
||
|
|
dataSize = textureDataSize;
|
||
|
|
} else dataSize = Implementation::compressedImageDataSizeFor(image, size);
|
||
|
|
|
||
|
|
/* Internal texture format */
|
||
|
11 years ago
|
GLint format;
|
||
|
10 years ago
|
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
|
||
|
11 years ago
|
|
||
|
11 years ago
|
/* 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);
|
||
|
|
|
||
|
11 years ago
|
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
|
||
|
11 years ago
|
image.storage().applyPack();
|
||
|
10 years ago
|
(this->*Context::current().state().texture->getCompressedImageImplementation)(level, dataSize, nullptr);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedBufferImage<1>&, BufferUsage);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<2>(GLint, CompressedBufferImage<2>&, BufferUsage);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<3>(GLint, CompressedBufferImage<3>&, BufferUsage);
|
||
|
11 years ago
|
|
||
|
11 years ago
|
template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image) {
|
||
|
|
createIfNotAlready();
|
||
|
|
|
||
|
|
const Math::Vector<dimensions, Int> size = range.size();
|
||
|
11 years ago
|
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size);
|
||
|
11 years ago
|
const Vector3i paddedOffset = Vector3i::pad(range.min());
|
||
|
|
const Vector3i paddedSize = Vector3i::pad(size, 1);
|
||
|
11 years ago
|
|
||
|
|
/* Reallocate only if needed */
|
||
|
|
Containers::Array<char> data{image.release()};
|
||
|
|
if(data.size() < dataSize)
|
||
|
|
data = Containers::Array<char>{dataSize};
|
||
|
11 years ago
|
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
|
||
|
11 years ago
|
image.storage().applyPack();
|
||
|
11 years ago
|
glGetTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), GLenum(image.format()), GLenum(image.type()), data.size(), data);
|
||
|
8 years ago
|
image = Image<dimensions>{image.storage(), image.format(), image.type(), size, std::move(data)};
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<1>(GLint, const Range1Di&, Image<1>&);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<2>(GLint, const Range2Di&, Image<2>&);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<3>(GLint, const Range3Di&, Image<3>&);
|
||
|
11 years ago
|
|
||
|
|
template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, BufferImage<dimensions>& image, const BufferUsage usage) {
|
||
|
|
createIfNotAlready();
|
||
|
|
|
||
|
|
const Math::Vector<dimensions, Int> size = range.size();
|
||
|
11 years ago
|
const std::size_t dataSize = Implementation::imageDataSizeFor(image, size);
|
||
|
11 years ago
|
const Vector3i paddedOffset = Vector3i::pad(range.min());
|
||
|
|
const Vector3i paddedSize = Vector3i::pad(size, 1);
|
||
|
11 years ago
|
|
||
|
|
/* Reallocate only if needed */
|
||
|
|
if(image.dataSize() < dataSize)
|
||
|
11 years ago
|
image.setData(image.storage(), image.format(), image.type(), size, {nullptr, dataSize}, usage);
|
||
|
11 years ago
|
else
|
||
|
|
image.setData(image.storage(), image.format(), image.type(), size, nullptr, usage);
|
||
|
11 years ago
|
|
||
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
|
||
|
11 years ago
|
image.storage().applyPack();
|
||
|
11 years ago
|
glGetTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), GLenum(image.format()), GLenum(image.type()), dataSize, nullptr);
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<1>(GLint, const Range1Di&, BufferImage<1>&, BufferUsage);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<2>(GLint, const Range2Di&, BufferImage<2>&, BufferUsage);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<3>(GLint, const Range3Di&, BufferImage<3>&, BufferUsage);
|
||
|
11 years ago
|
|
||
|
|
template<UnsignedInt dimensions> std::size_t AbstractTexture::compressedSubImageSize(TextureFormat format, const Math::Vector<dimensions, Int>& size) {
|
||
|
|
/* Amount of blocks in given range (rounded up) multiplied by block
|
||
|
|
data size. The user is responsible for proper block-aligned size. */
|
||
|
|
const Math::Vector<dimensions, Int> blockSize = DataHelper<dimensions>::compressedBlockSize(_target, format);
|
||
|
|
return ((size + blockSize - Math::Vector<dimensions, Int>{1})/blockSize).product()*
|
||
|
|
compressedBlockDataSize(_target, format);
|
||
|
|
}
|
||
|
|
|
||
|
|
template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, CompressedImage<dimensions>& image) {
|
||
|
|
createIfNotAlready();
|
||
|
|
|
||
|
|
const Math::Vector<dimensions, Int> size = range.size();
|
||
|
|
const Vector3i paddedOffset = Vector3i::pad(range.min());
|
||
|
|
const Vector3i paddedSize = Vector3i::pad(size, 1);
|
||
|
9 years ago
|
|
||
|
|
/* Internal texture format */
|
||
|
11 years ago
|
GLint format;
|
||
|
10 years ago
|
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
|
||
|
9 years ago
|
|
||
|
|
/* Calculate compressed subimage size. If the user-provided pixel storage
|
||
|
|
doesn't tell us all properties about the compression, we need to ask GL
|
||
|
|
for it. That requires GL_ARB_internalformat_query2. */
|
||
|
|
std::size_t dataSize;
|
||
|
|
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize())
|
||
|
|
dataSize = compressedSubImageSize<dimensions>(TextureFormat(format), size);
|
||
|
|
else dataSize = Implementation::compressedImageDataSizeFor(image, size);
|
||
|
11 years ago
|
|
||
|
|
/* Reallocate only if needed */
|
||
|
|
Containers::Array<char> data{image.release()};
|
||
|
|
if(data.size() < dataSize)
|
||
|
|
data = Containers::Array<char>{dataSize};
|
||
|
|
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
|
||
|
|
image.storage().applyPack();
|
||
|
|
glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), data.size(), data);
|
||
|
8 years ago
|
image = CompressedImage<dimensions>{CompressedPixelFormat(format), size, std::move(data)};
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<1>(GLint, const Range1Di&, CompressedImage<1>&);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<2>(GLint, const Range2Di&, CompressedImage<2>&);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<3>(GLint, const Range3Di&, CompressedImage<3>&);
|
||
|
11 years ago
|
|
||
|
|
template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, CompressedBufferImage<dimensions>& image, const BufferUsage usage) {
|
||
|
|
createIfNotAlready();
|
||
|
|
|
||
|
|
const Math::Vector<dimensions, Int> size = range.size();
|
||
|
|
const Vector3i paddedOffset = Vector3i::pad(range.min());
|
||
|
|
const Vector3i paddedSize = Vector3i::pad(size, 1);
|
||
|
9 years ago
|
|
||
|
|
/* Internal texture format */
|
||
|
11 years ago
|
GLint format;
|
||
|
10 years ago
|
(this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
|
||
|
9 years ago
|
|
||
|
|
/* Calculate compressed subimage size. If the user-provided pixel storage
|
||
|
|
doesn't tell us all properties about the compression, we need to ask GL
|
||
|
|
for it. That requires GL_ARB_internalformat_query2. */
|
||
|
|
std::size_t dataSize;
|
||
|
|
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize())
|
||
|
|
dataSize = compressedSubImageSize<dimensions>(TextureFormat(format), size);
|
||
|
|
else dataSize = Implementation::compressedImageDataSizeFor(image, size);
|
||
|
11 years ago
|
|
||
|
|
/* 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.storage().applyPack();
|
||
|
|
glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), dataSize, nullptr);
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<1>(GLint, const Range1Di&, CompressedBufferImage<1>&, BufferUsage);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<2>(GLint, const Range2Di&, CompressedBufferImage<2>&, BufferUsage);
|
||
|
|
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<3>(GLint, const Range3Di&, CompressedBufferImage<3>&, BufferUsage);
|
||
|
13 years ago
|
#endif
|
||
|
|
#endif
|
||
|
|
|
||
|
14 years ago
|
#ifndef DOXYGEN_GENERATING_OUTPUT
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::compressedBlockSize(const GLenum target, const TextureFormat format) {
|
||
|
|
GLint value;
|
||
|
|
glGetInternalformativ(target, GLenum(format), GL_TEXTURE_COMPRESSED_BLOCK_WIDTH, 1, &value);
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
|
||
|
|
Vector2i AbstractTexture::DataHelper<2>::compressedBlockSize(const GLenum target, const TextureFormat format) {
|
||
|
|
Vector2i value{Math::NoInit};
|
||
|
|
glGetInternalformativ(target, GLenum(format), GL_TEXTURE_COMPRESSED_BLOCK_WIDTH, 1, &value.x());
|
||
|
|
glGetInternalformativ(target, GLenum(format), GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT, 1, &value.y());
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
|
||
|
|
Vector3i AbstractTexture::DataHelper<3>::compressedBlockSize(const GLenum target, const TextureFormat format) {
|
||
|
|
/** @todo use real value when OpenGL has proper queries for 3D compression formats */
|
||
|
|
return Vector3i{DataHelper<2>::compressedBlockSize(target, format), 1};
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, const GLint level) {
|
||
|
13 years ago
|
Math::Vector<1, GLint> value;
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
|
||
|
13 years ago
|
return value;
|
||
|
|
}
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLint level) {
|
||
|
10 years ago
|
const Implementation::TextureState& state = *Context::current().state().texture;
|
||
|
12 years ago
|
|
||
|
13 years ago
|
Vector2i value;
|
||
|
10 years ago
|
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
|
||
|
|
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
|
||
|
13 years ago
|
return value;
|
||
|
|
}
|
||
|
|
|
||
|
10 years ago
|
Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, const GLint level) {
|
||
|
10 years ago
|
const Implementation::TextureState& state = *Context::current().state().texture;
|
||
|
12 years ago
|
|
||
|
13 years ago
|
Vector3i value;
|
||
|
10 years ago
|
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
|
||
|
|
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
|
||
|
|
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_DEPTH, &value[2]);
|
||
|
13 years ago
|
return value;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->storage1DImplementation)(levels, internalFormat, size);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->storage2DImplementation)(levels, internalFormat, size);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->storage3DImplementation)(levels, internalFormat, size);
|
||
|
12 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageView1D& image) {
|
||
|
12 years ago
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
12 years ago
|
texture.bindInternal();
|
||
|
12 years ago
|
glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(image.format()), GLenum(image.type()), image.data());
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<1>::setCompressedImage(AbstractTexture& texture, const GLint level, const CompressedImageView1D& image) {
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
11 years ago
|
texture.bindInternal();
|
||
|
11 years ago
|
glCompressedTexImage1D(texture._target, level, GLenum(image.format()), image.size()[0], 0, Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data());
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) {
|
||
|
12 years ago
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
12 years ago
|
texture.bindInternal();
|
||
|
12 years ago
|
glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(image.format()), GLenum(image.type()), nullptr);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<1>::setCompressedImage(AbstractTexture& texture, const GLint level, CompressedBufferImage1D& image) {
|
||
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
11 years ago
|
texture.bindInternal();
|
||
|
11 years ago
|
glCompressedTexImage1D(texture._target, level, GLenum(image.format()), image.size()[0], 0, Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const ImageView1D& image) {
|
||
|
12 years ago
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), image.data());
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const CompressedImageView1D& image) {
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size()));
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) {
|
||
|
12 years ago
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr);
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, CompressedBufferImage1D& image) {
|
||
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize()));
|
||
|
11 years ago
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageView2D& image) {
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
13 years ago
|
#endif
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
9 years ago
|
(texture.*Context::current().state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()
|
||
|
11 years ago
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
+ Implementation::pixelStorageSkipOffset(image)
|
||
|
|
#endif
|
||
|
9 years ago
|
, image.storage());
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<2>::setCompressedImage(AbstractTexture& texture, const GLenum target, const GLint level, const CompressedImageView2D& image) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Pixel storage is completely ignored for compressed images on ES, no need
|
||
|
|
to reset anything */
|
||
|
|
image.storage().applyUnpack();
|
||
|
|
#endif
|
||
|
11 years ago
|
texture.bindInternal();
|
||
|
11 years ago
|
glCompressedTexImage2D(target, level, GLenum(image.format()), image.size().x(), image.size().y(), 0, Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data());
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) {
|
||
|
12 years ago
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
12 years ago
|
texture.bindInternal();
|
||
|
|
glTexImage2D(target, level, GLint(internalFormat), image.size().x(), image.size().y(), 0, GLenum(image.format()), GLenum(image.type()), nullptr);
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
void AbstractTexture::DataHelper<2>::setCompressedImage(AbstractTexture& texture, const GLenum target, const GLint level, CompressedBufferImage2D& image) {
|
||
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Pixel storage is completely ignored for compressed images on ES, no need
|
||
|
|
to reset anything */
|
||
|
|
image.storage().applyUnpack();
|
||
|
|
#endif
|
||
|
11 years ago
|
texture.bindInternal();
|
||
|
11 years ago
|
glCompressedTexImage2D(target, level, GLenum(image.format()), image.size().x(), image.size().y(), 0, Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr);
|
||
|
11 years ago
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const ImageView2D& image) {
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
13 years ago
|
#endif
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), image.data()
|
||
|
11 years ago
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
+ Implementation::pixelStorageSkipOffset(image)
|
||
|
|
#endif
|
||
|
9 years ago
|
, image.storage());
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const CompressedImageView2D& image) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Pixel storage is completely ignored for compressed images on ES, no need
|
||
|
|
to reset anything */
|
||
|
|
image.storage().applyUnpack();
|
||
|
|
#endif
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size()));
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, BufferImage2D& image) {
|
||
|
12 years ago
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
9 years ago
|
(texture.*Context::current().state().texture->subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage());
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, CompressedBufferImage2D& image) {
|
||
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Pixel storage is completely ignored for compressed images on ES, no need
|
||
|
|
to reset anything */
|
||
|
|
image.storage().applyUnpack();
|
||
|
|
#endif
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize()));
|
||
|
11 years ago
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageView3D& image) {
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
13 years ago
|
#endif
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
9 years ago
|
(texture.*Context::current().state().texture->image3DImplementation)(level, internalFormat, image.size(), image.format(), image.type(), image.data()
|
||
|
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
+ Implementation::pixelStorageSkipOffset(image)
|
||
|
|
#endif
|
||
|
|
, image.storage());
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture, const GLint level, const CompressedImageView3D& image) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Pixel storage is completely ignored for compressed images on ES, no need
|
||
|
|
to reset anything */
|
||
|
|
image.storage().applyUnpack();
|
||
|
|
#endif
|
||
|
11 years ago
|
texture.bindInternal();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
11 years ago
|
glCompressedTexImage3D(texture._target, level, GLenum(image.format()), image.size().x(), image.size().y(), image.size().z(), 0, Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data());
|
||
|
11 years ago
|
#else
|
||
|
9 years ago
|
glCompressedTexImage3DOES(texture._target, level, GLenum(image.format()), image.size().x(), image.size().y(), image.size().z(), 0, Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data());
|
||
|
11 years ago
|
#endif
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) {
|
||
|
12 years ago
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
12 years ago
|
texture.bindInternal();
|
||
|
12 years ago
|
glTexImage3D(texture._target, level, GLint(internalFormat), image.size().x(), image.size().y(), image.size().z(), 0, GLenum(image.format()), GLenum(image.type()), nullptr);
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture, const GLint level, CompressedBufferImage3D& image) {
|
||
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Pixel storage is completely ignored for compressed images on ES, no need
|
||
|
|
to reset anything */
|
||
|
|
image.storage().applyUnpack();
|
||
|
|
#endif
|
||
|
11 years ago
|
texture.bindInternal();
|
||
|
11 years ago
|
glCompressedTexImage3D(texture._target, level, GLenum(image.format()), image.size().x(), image.size().y(), image.size().z(), 0, Implementation::occupiedCompressedImageDataSize(image, image.dataSize()), nullptr);
|
||
|
11 years ago
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
11 years ago
|
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const ImageView3D& image) {
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
13 years ago
|
#endif
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), image.data()
|
||
|
11 years ago
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
+ Implementation::pixelStorageSkipOffset(image)
|
||
|
|
#endif
|
||
|
9 years ago
|
, image.storage());
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const CompressedImageView3D& image) {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Pixel storage is completely ignored for compressed images on ES, no need
|
||
|
|
to reset anything */
|
||
|
|
image.storage().applyUnpack();
|
||
|
|
#endif
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size()));
|
||
|
11 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, BufferImage3D& image) {
|
||
|
12 years ago
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
image.storage().applyUnpack();
|
||
|
9 years ago
|
(texture.*Context::current().state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr, image.storage());
|
||
|
12 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, CompressedBufferImage3D& image) {
|
||
|
|
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Pixel storage is completely ignored for compressed images on ES, no need
|
||
|
|
to reset anything */
|
||
|
|
image.storage().applyUnpack();
|
||
|
|
#endif
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize()));
|
||
|
11 years ago
|
}
|
||
|
12 years ago
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<1>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1});
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<2>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const Vector2i& size) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, {offset, 0}, {size, 1});
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const Vector3i& size) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, offset, size);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Array1D<Sampler::Wrapping>& wrapping) {
|
||
|
10 years ago
|
(texture.*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Array2D<Sampler::Wrapping>& wrapping) {
|
||
|
10 years ago
|
const Implementation::TextureState& state = *Context::current().state().texture;
|
||
|
12 years ago
|
|
||
|
12 years ago
|
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
|
||
|
|
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
12 years ago
|
void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Array3D<Sampler::Wrapping>& wrapping) {
|
||
|
10 years ago
|
const Implementation::TextureState& state = *Context::current().state().texture;
|
||
|
12 years ago
|
|
||
|
12 years ago
|
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
|
||
|
|
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_R, GLint(wrapping.z()));
|
||
|
11 years ago
|
#else
|
||
|
|
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_R_OES, GLint(wrapping.z()));
|
||
|
14 years ago
|
#endif
|
||
|
14 years ago
|
}
|
||
|
14 years ago
|
#endif
|
||
|
11 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
15 years ago
|
}
|