- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# osg::Texture2D Class Reference

Encapsulates OpenGl 2D texture functionality. More...

Inheritance diagram for osg::Texture2D:

[legend]
List of all members.

## Public Member Functions
| Texture2D ()
| Texture2D (Image *image)
| Texture2D (const Texture2D &text, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
| Copy constructor using CopyOp to manage deep vs shallow copy.
| META_StateAttribute (osg, Texture2D, TEXTURE)
virtual int | compare (const StateAttribute &rhs) const
| Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
virtual bool | getModeUsage (ModeUsage &usage) const
void | setImage (Image *image)
| Sets the texture image.
Image * | getImage ()
| Gets the texture image.
const Image * | getImage () const
| Gets the const texture image.
unsigned int & | getModifiedTag (unsigned int contextID) const
virtual void | setImage (unsigned int, Image *image)
| Sets the texture image, ignoring face.
virtual Image * | getImage (unsigned int)
| Gets the texture image, ignoring face.
virtual const Image * | getImage (unsigned int) const
| Gets the const texture image, ignoring face.
virtual unsigned int | getNumImages () const
| Gets the number of images that can be assigned to the Texture.
void | setTextureSize (int width, int height) const
| Sets the texture width and height.
int | getTextureWidth () const
int | getTextureHeight () const
void | getTextureSize (int &width, int &height) const
| Deprecated.
void | setSubloadCallback (SubloadCallback *cb)
SubloadCallback * | getSubloadCallback ()
const SubloadCallback * | getSubloadCallback () const
void | setNumMipmapLevels (unsigned int num) const
| Helper function.
unsigned int | getNumMipmapLevels () const
| Gets the number of mipmap levels created.
void | copyTexImage2D (State &state, int x, int y, int width, int height)
| Copies pixels into a 2D texture image, as per glCopyTexImage2D.
void | copyTexSubImage2D (State &state, int xoffset, int yoffset, int x, int y, int width, int height)
| Copies a two-dimensional texture subimage, as per glCopyTexSubImage2D.
virtual void | apply (State &state) const
| Bind the texture object.
## Protected Types
typedef buffered_value< unsigned int > | ImageModifiedTag
## Protected Member Functions
virtual | ~Texture2D ()
virtual void | computeInternalFormat () const
## Protected Attributes
ref_ptr< Image > | _image
| It's not ideal that _image is mutable, but it's required since Image::ensureDimensionsArePowerOfTwo() can only be called in a valid OpenGL context, and therefore within Texture::apply, which is const.
GLsizei | _textureWidth
| Subloaded images can have different texture and image sizes.
GLsizei | _textureHeight
GLsizei | _numMipmapLevels
| Number of mipmap levels created.
ref_ptr< SubloadCallback > | _subloadCallback
ImageModifiedTag | _modifiedTag
## Classes
class | SubloadCallback

## Detailed Description

Encapsulates OpenGl 2D texture functionality.

Doesn't support cube maps, so ignore face parameters.

## Member Typedef Documentation

typedef buffered_value<unsigned int> osg::Texture2D::ImageModifiedTag`[protected]`

## Constructor & Destructor Documentation

Texture2D::Texture2D | ( |  | ) |

Texture2D::Texture2D | ( | Image * | image | ) |

Texture2D::Texture2D | ( | const Texture2D & | text,
|  | const CopyOp & | copyop = `CopyOp::SHALLOW_COPY`
| ) |

| Copy constructor using CopyOp to manage deep vs shallow copy.

Texture2D::~Texture2D | ( |  | ) | `[protected, virtual]`

## Member Function Documentation

void Texture2D::apply | ( | State & | state | ) | const`[virtual]`

| Bind the texture object. If the texture object hasn't already been compiled, create the texture mipmap levels. Implements osg::Texture. Reimplemented in osgText::Font::GlyphTexture.

int Texture2D::compare | ( | const StateAttribute & | rhs | ) | const`[virtual]`

| Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. Implements osg::StateAttribute. Reimplemented in osgText::Font::GlyphTexture.

void Texture2D::computeInternalFormat | ( |  | ) | const`[protected, virtual]`

| Implements osg::Texture.

void Texture2D::copyTexImage2D | ( | State & | state,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |

| Copies pixels into a 2D texture image, as per glCopyTexImage2D. Creates an OpenGL texture object from the current OpenGL background framebuffer contents at position x, y with width width and height height. width and height must be a power of two.

void Texture2D::copyTexSubImage2D | ( | State & | state,
|  | int | xoffset,
|  | int | yoffset,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |

| Copies a two-dimensional texture subimage, as per glCopyTexSubImage2D. Updates a portion of an existing OpenGL texture object from the current OpenGL background framebuffer contents at position x, y with width width and height height. Loads framebuffer data into the texture using offsets xoffset and yoffset. width and height must be powers of two.

virtual const Image* osg::Texture2D::getImage | ( | unsigned int |  | ) | const`[inline, virtual]`

| Gets the const texture image, ignoring face. Implements osg::Texture.

virtual Image* osg::Texture2D::getImage | ( | unsigned int |  | ) | `[inline, virtual]`

| Gets the texture image, ignoring face. Implements osg::Texture.

const Image* osg::Texture2D::getImage | ( |  | ) | const`[inline]`

| Gets the const texture image.

Image* osg::Texture2D::getImage | ( |  | ) | `[inline]`

| Gets the texture image.

virtual bool osg::Texture2D::getModeUsage | ( | ModeUsage & | usage | ) | const`[inline, virtual]`

unsigned int& osg::Texture2D::getModifiedTag | ( | unsigned int | contextID | ) | const`[inline]`

virtual unsigned int osg::Texture2D::getNumImages | ( |  | ) | const`[inline, virtual]`

| Gets the number of images that can be assigned to the Texture. Implements osg::Texture.

unsigned int osg::Texture2D::getNumMipmapLevels | ( |  | ) | const`[inline]`

| Gets the number of mipmap levels created.

const SubloadCallback* osg::Texture2D::getSubloadCallback | ( |  | ) | const`[inline]`

SubloadCallback* osg::Texture2D::getSubloadCallback | ( |  | ) | `[inline]`

int osg::Texture2D::getTextureHeight | ( |  | ) | const`[inline]`

void osg::Texture2D::getTextureSize | ( | int & | width,
|  | int & | height
| ) | const`[inline]`

| Deprecated.

int osg::Texture2D::getTextureWidth | ( |  | ) | const`[inline]`

osg::Texture2D::META_StateAttribute | ( | osg | ,
|  | Texture2D | ,
|  | TEXTURE |
| ) |

virtual void osg::Texture2D::setImage | ( | unsigned int | ,
|  | Image * | image
| ) | `[inline, virtual]`

| Sets the texture image, ignoring face. Implements osg::Texture.

void Texture2D::setImage | ( | Image * | image | ) |

| Sets the texture image.

void osg::Texture2D::setNumMipmapLevels | ( | unsigned int | num | ) | const`[inline]`

| Helper function. Sets the number of mipmap levels created for this texture. Should only be called within an osg::Texuture::apply(), or during a custom OpenGL texture load.

void osg::Texture2D::setSubloadCallback | ( | SubloadCallback * | cb | ) | `[inline]`

void osg::Texture2D::setTextureSize | ( | int | width,
|  | int | height
| ) | const`[inline]`

| Sets the texture width and height. If width or height are zero, calculate the respective value from the source image size.

## Member Data Documentation

ref_ptr<Image> osg::Texture2D::_image`[protected]`

| It's not ideal that _image is mutable, but it's required since Image::ensureDimensionsArePowerOfTwo() can only be called in a valid OpenGL context, and therefore within Texture::apply, which is const.

ImageModifiedTag osg::Texture2D::_modifiedTag`[mutable, protected]`

GLsizei osg::Texture2D::_numMipmapLevels`[mutable, protected]`

| Number of mipmap levels created.

ref_ptr<SubloadCallback> osg::Texture2D::_subloadCallback`[protected]`

GLsizei osg::Texture2D::_textureHeight`[mutable, protected]`

GLsizei osg::Texture2D::_textureWidth`[mutable, protected]`

| Subloaded images can have different texture and image sizes.

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

- Texture2D
- Texture2D.cpp