void Texture3D::init(int w, int h, int d, TextureInternalFormat tf, TextureFormat f, PixelType t, const Parameters ¶ms, const Buffer::Parameters &s, const Buffer &pixels) { Texture::init(tf, params); this->w = w; this->h = h; this->d = d; bindToTextureUnit(); pixels.bind(GL_PIXEL_UNPACK_BUFFER); if (isCompressed() && s.compressedSize() > 0) { glCompressedTexImage3D(GL_TEXTURE_3D, 0, getTextureInternalFormat(internalFormat), w, h, d, 0, s.compressedSize(), pixels.data(0)); } else { s.set(); glTexImage3D(GL_TEXTURE_3D, 0, getTextureInternalFormat(internalFormat), w, h, d, 0, getTextureFormat(f), getPixelType(t), pixels.data(0)); s.unset(); } pixels.unbind(GL_PIXEL_UNPACK_BUFFER); generateMipMap(); if (FrameBuffer::getError() != 0) { throw exception(); } }
void Texture2D::setCompressedSubImage(int level, int x, int y, int w, int h, int s, const Buffer &pixels) { bindToTextureUnit(); pixels.bind(GL_PIXEL_UNPACK_BUFFER); glCompressedTexSubImage2D(textureTarget, level, x, y, w, h, getTextureInternalFormat(internalFormat), s, pixels.data(0)); pixels.unbind(GL_PIXEL_UNPACK_BUFFER); assert(FrameBuffer::getError() == GL_NO_ERROR); }
void Texture2DArray::setCompressedSubImage(int level, int x, int y, int l, int w, int h, int d, int s, const Buffer &pixels) { bindToTextureUnit(); pixels.bind(GL_PIXEL_UNPACK_BUFFER); glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, x, y, l, w, h, d, getTextureInternalFormat(internalFormat), s, pixels.data(0)); pixels.unbind(GL_PIXEL_UNPACK_BUFFER); assert(FrameBuffer::getError() == GL_NO_ERROR); }
void TextureCube::setSubImage(CubeFace cf, int level, int x, int y, int w, int h, TextureFormat f, PixelType t, const Buffer::Parameters &s, const Buffer &pixels) { bindToTextureUnit(); pixels.bind(GL_PIXEL_UNPACK_BUFFER); s.set(); glTexSubImage2D(getCubeFace(cf), level, x, y, w, h, getTextureFormat(f), getPixelType(t), pixels.data(0)); s.unset(); pixels.unbind(GL_PIXEL_UNPACK_BUFFER); assert(FrameBuffer::getError() == GL_NO_ERROR); }
void Texture2DArray::setSubImage(int level, int x, int y, int l, int w, int h, int d, TextureFormat f, PixelType t, const Buffer::Parameters &s, const Buffer &pixels) { bindToTextureUnit(); pixels.bind(GL_PIXEL_UNPACK_BUFFER); s.set(); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, x, y, l, w, h, d, getTextureFormat(f), getPixelType(t), pixels.data(0)); s.unset(); pixels.unbind(GL_PIXEL_UNPACK_BUFFER); assert(FrameBuffer::getError() == GL_NO_ERROR); }
void Texture2D::setImage(int w, int h, TextureFormat f, PixelType t, const Buffer &pixels) { this->w = w; this->h = h; bindToTextureUnit(); pixels.bind(GL_PIXEL_UNPACK_BUFFER); glTexImage2D(textureTarget, 0, getTextureInternalFormat(internalFormat), w, h, 0, getTextureFormat(f), getPixelType(t), pixels.data(0)); pixels.unbind(GL_PIXEL_UNPACK_BUFFER); generateMipMap(); assert(FrameBuffer::getError() == GL_NO_ERROR); }
//-------------------------------------------------------------- void ofxCubeMap::bind() { bindToTextureUnit( 0 ); }