Equalizer  1.6.1
Public Member Functions | List of all members
eq::util::Texture Class Reference

A wrapper around OpenGL textures. More...

#include <texture.h>

+ Inheritance diagram for eq::util::Texture:
+ Collaboration diagram for eq::util::Texture:

Public Member Functions

 Texture (const unsigned target, const GLEWContext *const glewContext=0)
 Construct a new Texture. More...
 
virtual ~Texture ()
 Destruct the texture. More...
 
const GLEWContext * glewGetContext () const
 
void setGLEWContext (const GLEWContext *context)
 
Data Access.
unsigned getTarget () const
 
uint32_t getCompressorTarget () const
 
unsigned getInternalFormat () const
 
void setExternalFormat (const uint32_t format, const uint32_t type)
 Set the external data format and type. More...
 
unsigned getFormat () const
 
unsigned getType () const
 
unsigned getName () const
 
int32_t getWidth () const
 
int32_t getHeight () const
 
bool isValid () const
 
Operations.
void init (const unsigned internalFormat, const int32_t width, const int32_t height)
 Initialize an OpenGL texture. More...
 
void flush ()
 Clear the texture, including deleting the GL texture name. More...
 
void applyZoomFilter (const ZoomFilter filter) const
 
void applyWrap () const
 
void copyFromFrameBuffer (const unsigned internalFormat, const fabric::PixelViewport &pvp)
 Copy the specified area from the current read buffer to the texture at 0,0. More...
 
void upload (const int32_t width, const int32_t height, const void *ptr)
 Copy the specified buffer to the texture at 0,0. More...
 
void download (void *buffer) const
 Copy the texture data from the GPU to the given memory address. More...
 
void bind () const
 Bind the texture. More...
 
void bindToFBO (const unsigned target, const int32_t width, const int32_t height)
 Create and bind a texture to the current FBO. More...
 
void resize (const int32_t width, const int32_t height)
 Resize the texture. More...
 
void writeRGB (const std::string &filename) const
 Write the texture data as an rgb image file. More...
 
Wrap existing GL textures
void flushNoDelete ()
 Flush the texture without deleting the GL texture name. More...
 
void setGLData (const unsigned id, const unsigned internalFormat, const int32_t width, const int32_t height)
 Use an OpenGL texture created externally. More...
 

Detailed Description

A wrapper around OpenGL textures.

So far used by the Image and Compositor. The target is assumed to be GL_TEXTURE_RECTANGLE_ARB or GL_TEXTURE_2D.

Definition at line 38 of file texture.h.

Constructor & Destructor Documentation

eq::util::Texture::Texture ( const unsigned  target,
const GLEWContext *const  glewContext = 0 
)

Construct a new Texture.

A GLEWContext might be provided later using setGLEWContext(). It is needed for operations using OpenGL extensions or version 1.2 or later functions.

Version
1.0
virtual eq::util::Texture::~Texture ( )
virtual

Destruct the texture.

Version
1.0

Member Function Documentation

void eq::util::Texture::bind ( ) const

Bind the texture.

Version
1.0
void eq::util::Texture::bindToFBO ( const unsigned  target,
const int32_t  width,
const int32_t  height 
)

Create and bind a texture to the current FBO.

Version
1.0
void eq::util::Texture::copyFromFrameBuffer ( const unsigned  internalFormat,
const fabric::PixelViewport pvp 
)

Copy the specified area from the current read buffer to the texture at 0,0.

Version
1.0
void eq::util::Texture::download ( void *  buffer) const

Copy the texture data from the GPU to the given memory address.

Version
1.0
void eq::util::Texture::flush ( )

Clear the texture, including deleting the GL texture name.

Version
1.0
void eq::util::Texture::flushNoDelete ( )

Flush the texture without deleting the GL texture name.

Version
1.0
unsigned eq::util::Texture::getFormat ( ) const
Returns
the external data format of the texture, e.g., GL_RGBA.
Version
1.0
int32_t eq::util::Texture::getHeight ( ) const
Returns
the current height.
Version
1.0
unsigned eq::util::Texture::getInternalFormat ( ) const
Returns
the internal (GPU) pixel format of the texture.
See Also
init()
Version
1.0
unsigned eq::util::Texture::getName ( ) const
Returns
the OpenGL texture name.
Version
1.0

Referenced by eqAsync::AsyncFetcher::run().

+ Here is the caller graph for this function:

unsigned eq::util::Texture::getTarget ( ) const
Returns
the target of the texture.
Version
1.0
unsigned eq::util::Texture::getType ( ) const
Returns
the external data type of the texture, e.g., GL_HALF_FLOAT.
Version
1.0
int32_t eq::util::Texture::getWidth ( ) const
Returns
the current width.
Version
1.0
void eq::util::Texture::init ( const unsigned  internalFormat,
const int32_t  width,
const int32_t  height 
)

Initialize an OpenGL texture.

Parameters
internalFormatthe OpenGL texture internal format.
widththe width of the texture.
heightthe height of the texture.
Version
1.0

Referenced by eqAsync::AsyncFetcher::run().

+ Here is the caller graph for this function:

bool eq::util::Texture::isValid ( ) const
Returns
true if the texture can be bound.
Version
1.0
void eq::util::Texture::resize ( const int32_t  width,
const int32_t  height 
)

Resize the texture.

Version
1.0
void eq::util::Texture::setExternalFormat ( const uint32_t  format,
const uint32_t  type 
)

Set the external data format and type.

Parameters
formatthe OpenGL format.
typethe OpenGL Type.
Version
1.0
void eq::util::Texture::setGLData ( const unsigned  id,
const unsigned  internalFormat,
const int32_t  width,
const int32_t  height 
)

Use an OpenGL texture created externally.

The previous GL texture, if any, is deallocated using flush(). The new texture has to be of the correct target, size and internal format. The texture is validated by this method.

Parameters
idThe OpenGL texture name.
internalFormatthe OpenGL texture internal format.
widththe width of the texture.
heightthe height of the texture.
Version
1.0
void eq::util::Texture::upload ( const int32_t  width,
const int32_t  height,
const void *  ptr 
)

Copy the specified buffer to the texture at 0,0.

Version
1.0

Referenced by eqAsync::AsyncFetcher::run().

+ Here is the caller graph for this function:

void eq::util::Texture::writeRGB ( const std::string &  filename) const

Write the texture data as an rgb image file.

Version
1.0

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