Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

vrvis::Texture Class Reference

Represents a single texture in a LayerComponent as well as related figures and data. More...

#include <Texture.hpp>

List of all members.

Public Member Functions

Constructor & Destructor
 Texture (const int cOriginX, const int cOriginY, const int cWidth, const int cHeight, const int cMaxValidX, const int cMaxValidY, const ColorDataMap &crColorDataMap)
 Construct a Texture object out of relevant sizes and a ColorDataMap.
 ~Texture (void)
 Destructor.
Accessors
int getOriginX (void) const
 Get X pixel origin relative to the whole RasterData source object.
int getOriginY (void) const
 Get Y pixel origin relative to the whole RasterData source object.
int getSizeX (void) const
 Get width in pixels.
int getSizeY (void) const
 Get height in pixels.
int getMaxValidX (void) const
 Get size of the Texture part containing valid pixels; horizontal size.
int getMaxValidY (void) const
 Get size of the Texture part containing valid pixels; vertical size.
double getLowerLimit (void) const
 Get the lower limit of this Texture data's histogram.
double getUpperLimit (void) const
 Get the upper limit of this Texture data's histogram.
ushortgetTexData (void) const
 Get pointer to the texture data storage.
void getTexCoords (float &rMinX, float &rMaxX, float &rMinY, float &rMaxY)
 Get current GL texture coordinates.
Mutators
void setTexCoords (const float cMinX, const float cMaxX, const float cMinY, const float cMaxY)
 Set GL texture coordinates.
void setLimits (const double cLowerLimit, const double cUpperLimit)
 Set histogram limits.
Data Initialization
void fill (void)
 Fill the texture according to the ColorDataMap.
void createGLTexture (void)
 Create a new GL texture object out of this Texture.
Data Manipulation
void calculateTextureData (void)
 Converts the ColorDataMap member to the texture data array.
void rebuildGLTexture (int offsetX=0, int offsetY=0, int width=-1, int height=-1)
 Rebuilds a given part of the GL texture.
Drawing
void drawTexturedQuad (const float cDrawUnitX, const float cDrawUnitY)
 Draw a textured quad with this Texture mapped on it.

Static Public Member Functions

int getMaxTexSize (void)
 Get the maximum texture size supported on this system.


Detailed Description

Class representing one texture part of a LayerComponent. Textures are created as necessary by LayerComponents and are dependent on the maximum available GL texture size for the executing graphics system. The larger the available maximum texture size, the fewer slices, i.e. Texture objects have to be created.
Note:
On the way from RasterData to visible texture, the data values run through a three-stage process:
Warning:
Texture is the most crucial class concerning context-dependent function calls. Special care has to be taken in order to call context-related functions only during an active GL context!
See also:
Calling cycle, context issues

LayerComponent


Constructor & Destructor Documentation

Texture::Texture const int  cOriginX,
const int  cOriginY,
const int  cWidth,
const int  cHeight,
const int  cMaxValidX,
const int  cMaxValidY,
const ColorDataMap crColorDataMap
 

Creates a new Texture object of a certain size and origin. A given ColorDataMap is used to create the final pixel values of the visible texture.

Parameters:
[in] cOriginX Origin of the texture in relation to the whole RasterData size; X coordinate.
[in] cOriginY Origin of the texture in relation to the whole RasterData size; Y coordinate.
[in] cWidth Width of this Texture object in pixels.
[in] cHeight Height of this Texture object in pixels.
[in] cMaxValidX Maximum X coordinate that contains valid pixel information.
[in] cMaxValidY Maximum Y coordinate that contains valid pixel information.
[in] crColorDataMap Reference to the LayerComponent's ColorDataMap; used to calculate the final pixel values.
Note:
Since OpenGL texture objects always have to be $2^n$ sized in either dimension, the useful pixel part of a texture may be smaller than its real size. That is what the cMaxValid[X|Y] figures are for.
See also:
ColorDataMap

Texture::~Texture void   ) 
 

Destructor.


Member Function Documentation

void Texture::calculateTextureData void   ) 
 

Converts the RasterData objects stored in the ColorDataMap to a texture data array. Includes a left-handed (RasterData) to right-handed coordinate system conversion.

void Texture::createGLTexture void   ) 
 

Creates an OpenGL texture object out of a data-filled(!) Texture.

Warning:
This method requires an active OpenGL context to be executed properly!

void Texture::drawTexturedQuad const float  cDrawUnitX,
const float  cDrawUnitY
 

Draws a textured GL quad with a mapping of the created GL texture object and the current texture coordinates.

Parameters:
[in] cDrawUnitX The width of a drawn square that represents one drawn pixel.
[in] cDrawUnitY The height of a drawn square that represents one drawn pixel.

void Texture::fill void   ) 
 

Fills the Texture with data for the first time. Memory is allocated and initialized, the data calculated and empty areas made invisible via alpha correction.

double Texture::getLowerLimit void   )  const
 

Get lower limit of the texture data's histogram.

Returns:
Current lower limit of the texture data histogram.

int Texture::getMaxTexSize void   )  [static]
 

int Texture::getMaxValidX void   )  const
 

Get this Texture's maximum valid X cordinate.

Returns:
The maximum valid X coordinate.

int Texture::getMaxValidY void   )  const
 

Get this Texture's maximum valid Y cordinate.

Returns:
The maximum valid Y coordinate.

int Texture::getOriginX void   )  const
 

Get this Texture's X origin in relation to the RasterData size.

Returns:
Origin; X coordinate.

int Texture::getOriginY void   )  const
 

Get this Texture's Y origin in relation to the RasterData size.

Returns:
Origin; Y coordinate.

int Texture::getSizeX void   )  const
 

Get this Texture's horizontal size in pixels.

Returns:
Width in pixels.

int Texture::getSizeY void   )  const
 

Get this Texture's vertical size in pixels.

Returns:
Height in pixels.

void Texture::getTexCoords float &  rMinX,
float &  rMaxX,
float &  rMinY,
float &  rMaxY
 

Get the current GL texture coordinates.

Parameters:
[out] rMinX Minimal X texture coordinate.
[out] rMaxX Maximal X texture coordinate.
[out] rMinY Minimal Y texture coordinate.
[out] rMaxY Maximal Y texture coordinate.
Note:
The default minimal texture coordinates are 0.0, the default maximal coordinates are (mcMaxValid[X|Y] / mcSize[X|Y]); i.e. the whole area of valid pixels.

ushort * Texture::getTexData void   )  const
 

Get pointer to the memory where the texture data is stored.

Returns:
Pointer to the texture data storage.

double Texture::getUpperLimit void   )  const
 

Get upper limit of the texture data's histogram.

Returns:
Current upper limit of the texture data histogram.

void Texture::rebuildGLTexture int  offsetX = 0,
int  offsetY = 0,
int  width = -1,
int  height = -1
 

Recreates a given part of the GL texture based on the current texture data array.

Parameters:
[in] offsetX Offset from where to start the recreation; X coordinate.
[in] offsetY Offset from where to start the recreation; X coordinate.
[in] width Width of the area to recreate in pixels.
[in] height Height of the area to recreate in pixels.
Note:
Offsets are by default 0, both width and height -1. If either width or height have a value of -1, that value is replaced by the mcSize[X|Y] member, i.e. if the method is called without arguments, the whole valid texture is rebuilt.
Warning:
This method requires an active OpenGL context to be executed properly!

void Texture::setLimits const double  cLowerLimit,
const double  cUpperLimit
 

Set the lower and upper limits for this Texture data's histogram.

Parameters:
[in] cLowerLimit New lower histogram limit.
[in] cUpperLimit New upper histogram limit.
Note:
This method just updates the corresponding data members. To see the histogram changes visually in the scene, you have to call calculateTextureData() and rebuildGLTexture() first.

void Texture::setTexCoords const float  cMinX,
const float  cMaxX,
const float  cMinY,
const float  cMaxY
 

Set the GL texture coordinates used for this texture.

Parameters:
[in] cMinX Minimal X texture coordinate.
[in] cMaxX Maximal X texture coordinate.
[in] cMinY Minimal Y texture coordinate.
[in] cMaxY Maximal Y texture coordinate.
Note:
The default minimal texture coordinates are 0.0, the default maximal coordinates are (mcMaxValid[X|Y] / mcSize[X|Y]); i.e. the whole area of valid pixels.


The documentation for this class was generated from the following files:
Generated on Tue Sep 21 07:31:11 2004 for VRVis by doxygen 1.3.8