Crazy Eddie's GUI System  0.8.6
CEGUI::OpenGLTexture Class Reference

Texture implementation for the OpenGLRenderer. More...

+ Inheritance diagram for CEGUI::OpenGLTexture:
+ Collaboration diagram for CEGUI::OpenGLTexture:

Public Member Functions

void setOpenGLTexture (GLuint tex, const Sizef &size)
 set the openGL texture that this Texture is based on to the specified texture, with the specified size.
 
GLuint getOpenGLTexture () const
 Return the internal OpenGL texture id used by this Texture object. More...
 
void setTextureSize (const Sizef &sz)
 set the size of the internal texture. More...
 
void grabTexture ()
 Grab the texture to a local buffer. More...
 
void restoreTexture ()
 Restore the texture from the locally buffered copy previously create by a call to grabTexture.
 
const StringgetName () const
 Returns the name given to the texture when it was created. More...
 
const SizefgetSize () const
 Returns the current pixel size of the texture. More...
 
const SizefgetOriginalDataSize () const
 Returns the original pixel size of the data loaded into the texture. More...
 
const Vector2fgetTexelScaling () const
 Returns pixel to texel scale values that should be used for converting pixel values to texture co-ords. More...
 
void loadFromFile (const String &filename, const String &resourceGroup)
 Loads the specified image file into the texture. The texture is resized as required to hold the image. More...
 
void loadFromMemory (const void *buffer, const Sizef &buffer_size, PixelFormat pixel_format)
 Loads (copies) an image in memory into the texture. The texture is resized as required to hold the image. More...
 
void blitFromMemory (const void *sourceData, const Rectf &area)
 Performs an area memory blit to the texture. More...
 
void blitToMemory (void *targetData)
 Performs a complete blit from the texture surface to memory. More...
 
bool isPixelFormatSupported (const PixelFormat fmt) const
 Return whether the specified pixel format is supported by the system for the CEGUI::Texture implementation. More...
 
- Public Member Functions inherited from CEGUI::Texture
virtual ~Texture ()
 Destructor for Texture base class.
 

Protected Member Functions

 OpenGLTexture (OpenGLRendererBase &owner, const String &name)
 Basic constructor.
 
 OpenGLTexture (OpenGLRendererBase &owner, const String &name, const String &filename, const String &resourceGroup)
 Constructor that creates a Texture from an image file.
 
 OpenGLTexture (OpenGLRendererBase &owner, const String &name, const Sizef &size)
 Constructor that creates a Texture with a given size.
 
 OpenGLTexture (OpenGLRendererBase &owner, const String &name, GLuint tex, const Sizef &size)
 Constructor that wraps an existing GL texture.
 
virtual ~OpenGLTexture ()
 Destructor.
 
void generateOpenGLTexture ()
 generate the OpenGL texture and set some initial options.
 
void updateCachedScaleValues ()
 updates cached scale value used to map pixels to texture co-ords.
 
void cleanupOpenGLTexture ()
 clean up the GL texture, or the grab buffer if it had been grabbed
 
GLint internalFormat () const
 
void initInternalPixelFormatFields (const PixelFormat fmt)
 initialise the internal format flags for the given CEGUI::PixelFormat.
 
void setTextureSize_impl (const Sizef &sz)
 internal texture resize function (does not reset format or other fields)
 
void loadUncompressedTextureBuffer (const Rectf &dest_area, const GLvoid *buffer) const
 
void loadCompressedTextureBuffer (const Rectf &dest_area, const GLvoid *buffer) const
 
GLsizei getCompressedTextureSize (const Sizef &pixel_size) const
 

Protected Attributes

GLuint d_ogltexture
 The OpenGL texture we're wrapping.
 
Sizef d_size
 Size of the texture.
 
uint8 * d_grabBuffer
 cached image data for restoring the texture.
 
Sizef d_dataSize
 original size of pixel data loaded into texture
 
Vector2f d_texelScaling
 cached pixel to texel mapping scale values.
 
OpenGLRendererBased_owner
 OpenGLRenderer that created and owns this OpenGLTexture.
 
const String d_name
 The name given for this texture.
 
GLenum d_format
 Texture format.
 
GLenum d_subpixelFormat
 Texture subpixel format.
 
bool d_isCompressed
 Whether Texture format is a compressed format.
 

Friends

TextureOpenGLRendererBase::createTexture (const String &)
 
TextureOpenGLRendererBase::createTexture (const String &, const String &, const String &)
 
TextureOpenGLRendererBase::createTexture (const String &, const Sizef &)
 
TextureOpenGLRendererBase::createTexture (const String &, GLuint, const Sizef &)
 
void OpenGLRendererBase::destroyTexture (Texture &)
 
void OpenGLRendererBase::destroyTexture (const String &)
 

Additional Inherited Members

- Public Types inherited from CEGUI::Texture
enum  PixelFormat {
  PF_RGB, PF_RGBA, PF_RGBA_4444, PF_RGB_565,
  PF_PVRTC2, PF_PVRTC4, PF_RGB_DXT1, PF_RGBA_DXT1,
  PF_RGBA_DXT3, PF_RGBA_DXT5
}
 Enumerated type containing the supported pixel formats that can be passed to loadFromMemory. More...
 

Detailed Description

Texture implementation for the OpenGLRenderer.

Member Function Documentation

void CEGUI::OpenGLTexture::blitFromMemory ( const void *  sourceData,
const Rectf area 
)
virtual

Performs an area memory blit to the texture.

Parameters
sourceDatainput data, the size must match area described by the given Rect
areaarea where the blit will happen
Note
The pixel format must match current Texture's pixel format!

Implements CEGUI::Texture.

void CEGUI::OpenGLTexture::blitToMemory ( void *  targetData)
virtual

Performs a complete blit from the texture surface to memory.

Parameters
targetDatathe buffer where the target is stored
Note
You have to (correctly) preallocate the target buffer!

Implements CEGUI::Texture.

const String& CEGUI::OpenGLTexture::getName ( ) const
virtual

Returns the name given to the texture when it was created.

Returns
Reference to a String object that holds the name of the texture.

Implements CEGUI::Texture.

GLuint CEGUI::OpenGLTexture::getOpenGLTexture ( ) const

Return the internal OpenGL texture id used by this Texture object.

Returns
id of the OpenGL texture that this object is using.
const Sizef& CEGUI::OpenGLTexture::getOriginalDataSize ( ) const
virtual

Returns the original pixel size of the data loaded into the texture.

Returns
reference to a Size object that describes the original size, in pixels, of the data loaded into the texture.

Implements CEGUI::Texture.

const Sizef& CEGUI::OpenGLTexture::getSize ( ) const
virtual

Returns the current pixel size of the texture.

Returns
Reference to a Size object that describes the size of the texture in pixels.

Implements CEGUI::Texture.

const Vector2f& CEGUI::OpenGLTexture::getTexelScaling ( ) const
virtual

Returns pixel to texel scale values that should be used for converting pixel values to texture co-ords.

Returns
Reference to a Vector2 object that describes the scaling values required to accurately map pixel positions to texture co-ordinates.

Implements CEGUI::Texture.

void CEGUI::OpenGLTexture::grabTexture ( )

Grab the texture to a local buffer.

This will destroy the OpenGL texture, and restoreTexture must be called before using it again.

bool CEGUI::OpenGLTexture::isPixelFormatSupported ( const PixelFormat  fmt) const
virtual

Return whether the specified pixel format is supported by the system for the CEGUI::Texture implementation.

The result of this call will vary according to the implementaion API and the capabilities of the hardware.

Note
Whether the CEGUI system as a whole will make use of support for any given pixel format will depend upon that format being recognised and supported by both the renderer module implementation and the ImageCodec module that is used to load texture data.
Parameters
fmtOne of the PixelFormat enumerated values specifying the pixel format that is to be tested.
Returns
  • true if the specified PixelFormat is supported.
  • false if the specified PixelFormat is not supported.

Implements CEGUI::Texture.

void CEGUI::OpenGLTexture::loadFromFile ( const String filename,
const String resourceGroup 
)
virtual

Loads the specified image file into the texture. The texture is resized as required to hold the image.

Parameters
filenameThe filename of the image file that is to be loaded into the texture
resourceGroupResource group identifier to be passed to the resource provider when loading the image file.
Returns
Nothing.

Implements CEGUI::Texture.

void CEGUI::OpenGLTexture::loadFromMemory ( const void *  buffer,
const Sizef buffer_size,
PixelFormat  pixel_format 
)
virtual

Loads (copies) an image in memory into the texture. The texture is resized as required to hold the image.

Parameters
bufferPointer to the buffer containing the image data.
buffer_sizeSize of the buffer (in pixels as specified by pixelFormat)
pixel_formatPixelFormat value describing the format contained in buffPtr.
Returns
Nothing.

Implements CEGUI::Texture.

void CEGUI::OpenGLTexture::setTextureSize ( const Sizef sz)

set the size of the internal texture.

Parameters
szsize for the internal texture, in pixels.
Note
Depending upon the hardware capabilities, the actual final size of the texture may be larger than what is specified when calling this function. The texture will never be smaller than what you request here. To discover the actual size, call getSize.
Exceptions
RendererExceptionthrown if the hardware is unable to support a texture large enough to fulfill the requested size.
Returns
Nothing.