Avogadro::Rendering::Texture2D#

class Texture2D#

The Texture2D class manages texture resources in graphics libraries.

Unnamed Group

void setWrappingS(WrappingOption opt)#

Wrapping options in the s-direction. Default is Repeat.

WrappingOption wrappingS() const#

Wrapping options in the s-direction. Default is Repeat.

Unnamed Group

void setWrappingT(WrappingOption opt)#

Wrapping options in the t-direction. Default is Repeat.

WrappingOption wrappingT() const#

Wrapping options in the t-direction. Default is Repeat.

Public Types

enum FilterOption#

The FilterOption enum defines options for interpolating texels onto pixels.

Values:

enumerator InvalidFilter#
enumerator Nearest#

Use the nearest texel for the pixel value.

enumerator Linear#

Interpolate the four neighboring texels for the pixel value.

enum WrappingOption#

The WrappingOption enum defines options for handling texture coordinates outside of the range [0, 1]. Note that these are specified separately for each dimension of the texture.

Values:

enumerator InvalidWrapping#
enumerator ClampToEdge#

Use the texel at the nearest edge.

enumerator MirroredRepeat#

Repeat the texels such that texture coordinates in the range [1, 2] map to [1, 0]; [2, 3] map to [0, 1], and so on.

enumerator Repeat#

Repeat the texels such that integer components of the texture coordinates are ignored (e.g. 1.7 becomes 0.7, 2.3 becomes 0.3, etc).

enum InternalFormat#

The InternalFormat enum defines how the texture data will be stored by the graphics library implementation.

Values:

enumerator InvalidInternalFormat#
enumerator InternalDepth#

Each element is a single depth component.

enumerator InternalDepthStencil#

Each element contains a depth component and a stencil value.

enumerator InternalR#

Each element contains a single color value.

enumerator InternalRG#

Each element contains two color values.

enumerator InternalRGB#

Each element contains three color values.

enumerator InternalRGBA#

Each element contains four color values.

enum IncomingFormat#

The IncomingFormat enum defines the supported formats for incoming texture data.

Values:

enumerator InvalidIncomingFormat#
enumerator IncomingR#

Each element is a single red component.

enumerator IncomingRG#

Each element is a red then green component.

enumerator IncomingRGB#

Each element is a red, green, then blue component.

enumerator IncomingBGR#

Each element is a blue, green, then red component.

enumerator IncomingRGBA#

Each element is a red, green, blue, then alpha component.

enumerator IncomingBGRA#

Each element is a blue, green, red, then alpha component.

enumerator IncomingDepth#

Each element is a single depth component.

enumerator IncomingDepthStencil#

Each element is a depth component followed by a stencil value.

Public Functions

Texture2D()#
~Texture2D()#
Index handle() const#

A unique integer value identifying the texture.

inline bool ready() const#

True if the texture is ready to use.

void setMinFilter(FilterOption opt)#

Filtering options for interpolating pixel values. Default is Linear. {@

FilterOption minFilter() const#
void setMagFilter(FilterOption opt)#
FilterOption magFilter() const#
template<class ContainerT>
inline bool upload(const ContainerT &buffer, const Vector2i &dims, IncomingFormat dataFormat, InternalFormat internalFormat)#

Upload a buffer of texture data to the graphics library.

The buffer must contain homogeneous elements of the follow types: unsigned char, char, unsigned short, short, unsigned int, int, or float.

The first element of buffer is the lower-left texel. Subsequent elements are ordered such that rows are contiguous, moving right and up.

The ContainerT must satisfy the following requirements (short version: use std::vector or Avogadro::Core::Array):

  • ContainerT must have tightly packed values of ContainerT::value_type

  • elements must be accessible by reference via ContainerT::operator[].

  • ContainerT::size() must return the number of elements in the container as integral type ContainerT::size_type.

Parameters:
  • buffer – The texture data (see below for requirements of ContainerT).

  • dims – The width and height of the texture data.

  • dataFormat – The ordering of components in the buffer data.

  • internalFormat – The internal storage ordering of components in the buffer data.

bool bind() const#

Bind the texture for rendering.

bool release() const#
inline std::string error() const#