Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglTextureCubeMap Class Reference

#include <sglTextureCubeMap.hpp>

Inheritance diagram for sglTextureCubeMap::

sglTexture sglTexturingStatelet sglStatelet sglObject List of all members.

Public Methods

 sglTextureCubeMap ()
virtual ~sglTextureCubeMap ()
bool setImage (void *px_image, void *nx_image, void *py_image, void *ny_image, void *pz_image, void *nz_image, ExternalFormatEnum format, TypeEnum type, unsigned int size, bool border=false)
void getImage (void *&px_image, void *&nx_image, void *&py_image, void *&ny_image, void *&pz_image, void *&nz_image, ExternalFormatEnum &format, TypeEnum &type, unsigned int &size, bool &border) const
bool setMipmapLevels (const vector< void *> &)
unsigned int getSize () const
virtual unsigned int getIdealInternalSize () const
virtual unsigned int getLikelyInternalSize () const
void setWrapMode (WrapEnum s_repeat_flag, WrapEnum t_repeat_flag)
void getWrapMode (WrapEnum &s_repeat_flag, WrapEnum &t_repeat_flag) const
void setMaxAnisotropy (float max)
float getMaxAnisotropy () const
virtual bool checkProxy ()
virtual void bind ()
virtual bool replaceImage (void *, GLint)
virtual bool buildMipmaps (vector< void *> &)

Static Public Methods

float getMaxSupportedMaxAnisotropy ()

Detailed Description

This statelet works with the GL_ARB_texture_cube_map, GL_EXT_texture_cube_map, or GL_NV_texture_cube_map extensions (they are all equivalent). Please see the official OpenGL extension documentation available at opengl.org for most of the details. This statelet is a container for the 6 images used for cube map texturing. As near as I can tell the images have the following orientations:

positive X (px):  z <----+
                         |
                   right |
                         V
                         y

negative X (nx):  +----> z
                  |
                  | left
                  V
                  y

positive Z (pz):  +----> x
                  |
                  | front
                  V
                  y

negative Z (pz):  x <----+
                         |
                    back |
                         V
                         y

positive Y (py):  z
                  ^
                  | bottom
                  |
                  +----> x

negative Y (ny):  +----> x
                  |
                  | top
                  V
                  z

Note that all six images must be the same size (square) and have the same type and external format.

Example:

   // all six images must be the same size (and square) format and type
   sglTextureCubeMap *cube_map = new sglTextureCubeMap;
   if (!cube_map->setImage(image[0], image[1], image[2], image[3],
                           image[4], image[5],
                           format, type, size, false))
   {
      cerr << "Warning: sglTextureCubeMap::setImage() failed" << endl;
   }

   sglTexGen *tgen = new sglTexGen;
   tgen->setMode(sglTexGen::eS, sglTexGen::eREFLECTION_MAP);
   tgen->setMode(sglTexGen::eT, sglTexGen::eREFLECTION_MAP);
   tgen->setMode(sglTexGen::eR, sglTexGen::eREFLECTION_MAP);

   // used to account for view position.
   tmat = new sglTextureMatrix(NULL);

   vector<sglStatelet*> state;
   state.push_back(cube_map);
   state.push_back(tgen);
   state.push_back(tmat);

Definition at line 114 of file sglTextureCubeMap.hpp.


Constructor & Destructor Documentation

sglTextureCubeMap::sglTextureCubeMap ( )
 

Default constructor. Creates an empty, invalid texture.

sglTextureCubeMap::~sglTextureCubeMap ( ) [virtual]
 

Virtual destructor.


Member Function Documentation

bool sglTextureCubeMap::setImage ( void * px_image,
void * nx_image,
void * py_image,
void * ny_image,
void * pz_image,
void * nz_image,
ExternalFormatEnum format,
TypeEnum type,
unsigned int size,
bool border = false )
 

Set the six images in the cube map. All must be same square size and in the same format. Note: this will not free the memory from the previous image. Note: this will clear the mipmap levels if not automatic.

Parameters:
px_image   The positive X image data.
nx_image   The negative X image data.
py_image   The positive Y image data.
ny_image   The negative Y image data.
pz_image   The positive Z image data.
nz_image   The negative Z image data.
format   Format of each texel in the images
type   Data type of texel data
size   Width an height of the image data (square only). Must be equal to the equation, 2^m +2b, where m is a non-negative integer (which can be different for s and t) and b is zero or one (depending on border). ??? If num_s or num_t (minus the border) are not powers of two, or if the image is too large, the image will be automatically resized ???
border   True if the image has a one pixel border
Returns:
false if the parameters are out of range.

void sglTextureCubeMap::getImage ( void *& px_image,
void *& nx_image,
void *& py_image,
void *& ny_image,
void *& pz_image,
void *& nz_image,
ExternalFormatEnum & format,
TypeEnum & type,
unsigned int & size,
bool & border ) const
 

Query the current cube map data. If the valid flag is false the image pointers will be set to NULL.

Parameters:
px_image   The positive X image data.
nx_image   The negative X image data.
py_image   The positive Y image data.
ny_image   The negative Y image data.
pz_image   The positive Z image data.
nz_image   The negative Z image data.
format   Format of each texel in the images
type   Data type of texel data
size   Width an height of the image data (square only).
border   True if the image has a one pixel border

bool sglTextureCubeMap::setMipmapLevels ( const vector< void *> & images ) [inline, virtual]
 

Set the mipmap images. This feature is currently disabled for cube maps.

Reimplemented from sglTexture.

Definition at line 182 of file sglTextureCubeMap.hpp.

unsigned int sglTextureCubeMap::getSize ( ) const [inline]
 

Query the current size of the level zero images.

Returns:
the size (width and height are the same value.

Definition at line 187 of file sglTextureCubeMap.hpp.

unsigned int sglTextureCubeMap::getIdealInternalSize ( ) const [virtual]
 

Returns the number of bytes of texture memory this texture will use if the requested internal format was honored.

Reimplemented from sglTexture.

unsigned int sglTextureCubeMap::getLikelyInternalSize ( ) const [virtual]
 

Returns the number of bytes of texture memory this texture is most likely using. Must be called by a thread with a current rendering context.

Reimplemented from sglTexture.

void sglTextureCubeMap::setWrapMode ( WrapEnum s_repeat_flag,
WrapEnum t_repeat_flag )
 

Set whether the texture repeats or is stretched by tex coords > 1.

Parameters:
s_repeat_flag   One of eREPEAT, eCLAMP, or eCLAMP_TO_EDGE (when supported) for the s dimension
t_repeat_flag   Same choices as above.

void sglTextureCubeMap::getWrapMode ( WrapEnum & s_repeat_flag,
WrapEnum & t_repeat_flag ) const
 

Query the current texture wrap mode.

Parameters:
s_repeat_flag   On return, contains the WrapEnum token for the s dimension.
t_repeat_flag   On return, contains the WrapEnum token for the t dimension.

void sglTextureCubeMap::setMaxAnisotropy ( float max )
 

Get/set the maximum degree of anisotropy to account for in texture filtering (if supported). A value of 1.0f disables anisotropic filtering. default: 1.0f

Reimplemented from sglTexture.

float sglTextureCubeMap::getMaxSupportedMaxAnisotropy ( ) [inline, static]
 

Get the maximum max-anisotropy supported on this system. Returns 1.0f if anisotropic filtering is not supported.

Reimplemented from sglTexture.

Definition at line 226 of file sglTextureCubeMap.hpp.

bool sglTextureCubeMap::checkProxy ( ) [virtual]
 

Use the GL_PROXY_TEXTURE_CUBE_MAP_ARB mechanism to check if the texture is capable of being loaded into texture memory. Returns false if the texture is too large. Must be called by a thread with a current rendering context.

Reimplemented from sglTexture.

void sglTextureCubeMap::bind ( ) [virtual]
 

Copy texture (and changes) into texture memory. If (getAutoBind() == false), this method must be called before before the texture can be applied. Must be called by a thread with a current rendering context.

Reimplemented from sglTexture.

bool sglTextureCubeMap::replaceImage ( void * new_image,
GLint level ) [inline, virtual]
 

Helper function to replace an entire image via subtexload funtionality. A previous image must first have been set with the setImage or setMipmapLevels methods. The new_image data must be the same size as the original image, and the pointer to the old image data is lost. The level parameter specifies which mipmap level to replace.

Reimplemented from sglTexture.

Definition at line 243 of file sglTextureCubeMap.hpp.

bool sglTextureCubeMap::buildMipmaps ( vector< void *> & mipmaps ) [inline, virtual]
 

Generates a set of mipmaps from the level 0 image in this texture. Existing images in the given mipmaps vector will be resized (via realloc) and excess images will be free()'d. Returns false if the mipmaps could not be built.

Reimplemented from sglTexture.

Definition at line 244 of file sglTextureCubeMap.hpp.


The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:10 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001