Loading...
Searching...
No Matches
Texture2D Class Reference

The Texture2D class manages texture resources in graphics libraries.

`#include <avogadro/rendering/texture2d.h>`

## Public Types

enum | FilterOption { InvalidFilter = -1 , Nearest = 0 , Linear }
| The FilterOption enum defines options for interpolating texels onto pixels. More...
enum | WrappingOption { InvalidWrapping = -1 , ClampToEdge = 0 , MirroredRepeat , Repeat }
| 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. More...
enum | InternalFormat { InvalidInternalFormat = -1 , InternalDepth = 0 , InternalDepthStencil , InternalR , InternalRG , InternalRGB , InternalRGBA }
| The InternalFormat enum defines how the texture data will be stored by the graphics library implementation. More...
enum | IncomingFormat { InvalidIncomingFormat = -1 , IncomingR = 0 , IncomingRG , IncomingRGB , IncomingBGR , IncomingRGBA , IncomingBGRA , IncomingDepth , IncomingDepthStencil }
| The IncomingFormat enum defines the supported formats for incoming texture data. More...

## Public Member Functions

Index | handle () const
bool | ready () const
void | setMinFilter (FilterOption opt)
FilterOption | minFilter () const
void | setMagFilter (FilterOption opt)
FilterOption | magFilter () const
template<class ContainerT>
bool | upload (const ContainerT &buffer, const Vector2i &dims, IncomingFormat dataFormat, InternalFormat internalFormat)
bool | bind () const
bool | release () const
std::string | error () const
void | setWrappingS (WrappingOption opt)
WrappingOption | wrappingS () const
void | setWrappingT (WrappingOption opt)
WrappingOption | wrappingT () const

## Member Enumeration Documentation

## FilterOption

enum FilterOption

Enumerator
Nearest | Use the nearest texel for the pixel value.
Linear | Interpolate the four neighboring texels for the pixel value.

## WrappingOption

enum WrappingOption

Enumerator
ClampToEdge | Use the texel at the nearest edge.
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.
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).

## InternalFormat

enum InternalFormat

Enumerator
InternalDepth | Each element is a single depth component.
InternalDepthStencil | Each element contains a depth component and a stencil value.
InternalR | Each element contains a single color value.
InternalRG | Each element contains two color values.
InternalRGB | Each element contains three color values.
InternalRGBA | Each element contains four color values.

## IncomingFormat

enum IncomingFormat

Enumerator
IncomingR | Each element is a single red component.
IncomingRG | Each element is a red then green component.
IncomingRGB | Each element is a red, green, then blue component.
IncomingBGR | Each element is a blue, green, then red component.
IncomingRGBA | Each element is a red, green, blue, then alpha component.
IncomingBGRA | Each element is a blue, green, red, then alpha component.
IncomingDepth | Each element is a single depth component.
IncomingDepthStencil | Each element is a depth component followed by a stencil value.

## Member Function Documentation

## handle()

Index handle | ( |  | ) | const

A unique integer value identifying the texture.

## ready()

bool ready | ( |  | ) | const

True if the texture is ready to use.

## setMinFilter()

void setMinFilter | ( | FilterOption | opt | ) |

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

## setWrappingS()

void setWrappingS | ( | WrappingOption | opt | ) |

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

## wrappingS()

WrappingOption wrappingS | ( |  | ) | const

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

## setWrappingT()

void setWrappingT | ( | WrappingOption | opt | ) |

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

## wrappingT()

WrappingOption wrappingT | ( |  | ) | const

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

## upload()

template<class ContainerT>

bool upload | ( | const ContainerT & | buffer,
|  | const Vector2i & | dims,
|  | IncomingFormat | dataFormat,
|  | InternalFormat | internalFormat )

Upload a buffer of texture data to the graphics library.

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.

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.

## bind()

bool bind | ( |  | ) | const

Bind the texture for rendering.

The documentation for this class was generated from the following file:

- texture2d.h