|
CgleTexture |
| Variables | | Description |
| |
| BOOL m_bVertInvert | |
Set this TRUE before creating the texture to flip the image vertically. Default is FALSE. |
| BOOL m_bHorzInvert | |
Set this TRUE before creating the texture to flip the image horizontally. Default is FALSE. |
| BOOL m_bStretch | |
Set this TRUE to automatically resize images whose dimensions aren't already 2^n. If the image is not 2^n and
m_bStretch is false, the image will be cropped to the next smaller 2^n dimension. Default is TRUE. |
| BOOL m_bUseCompressed | |
If this is TRUE, an attempt will be made to load the textuures with a GL_COMPRESSED internal format. You
must initialize the GL_ARB_texture_compression API separately before attempting to use this feature. Default is FALSE. |
| BOOL m_bStoreCompressed | |
Set this TRUE to enable storage of the compressed textures as local files. (m_bUseCompressed must also be TRUE.) If this is
enabled, the first time a texture is created CgleTexture will compress the texture then offload the compressed version into a file whose
name you specify. Whenever the program is run after that, CgleTexture will attempt to load the pre-compressed texture from the file.
If this fails it will load the original image and recreate the compressed file. Default is FALSE. |
| |
| Methods |
| Description |
| |
| CgleTexture() | | |
| virtual ~CgleTexture() | | |
| |
| void ReleaseResources() | |
This wraps glDeleteTextures, and resets the image dimensions to 0. It is called automatically from the destructor. |
| |
| int GetTextureIndex() | |
Returns the handle or 'name' assigned to the texture object by glGenTextures when the texture was first built. |
| int GetTextureHeight() | | Returns the height of the texture image. |
| int GetTextureWidth() | | Returns the width of the texture image. |
| void SetTexFilterMode(GLenum MinFilter, GLenum MaxFilter) | | Configure minification and magnification filters. Call this before building the texture; if you change the filter modes after creating the texture, call UpdateTexObject(). Defaults are both GL_LINEAR. |
| void SetTexWrapMode(GLenum SWrap, GLenum TWrap) | | Configure the wrap mode. As with filtering, call this before building the texture; if you change the wrap modes after creating the texture, call UpdateTexObject(). Defaults are both GL_REPEAT. |
| void SetUseMipMaps(BOOL value) | | Controls whether or not mipmaps are generated from the base image when the texture is created. Default is FALSE. Set this before creating the texture; subsequent changes require rebuilding the texture to take effect. |
| void UpdateTexObject() | | This method wraps the calls to glTexParameteri that set up the wrap and filter modes. |
| |
| void SetPlaneAlignment(float SPlane[4], float TPlane[4]) | | Call this to modify the reference planes used for texture coordinate generation. Default values are (1.0, 0.0, 0.0, 0.0) and (0.0, 1.0, 0.0, 0.0). |
| void SetCoordGenMode(GLenum SMode, GLenum TMode) | | Call this to modify the coordinate generation mode. Defaults are both GL_OBJECT_LINEAR. |
| void SetCoordGenRefPlane(GLenum SPlane, GLenum TPlane) | | Defaults are both GL_OBJECT_PLANE. |
| void TexGenEnable() | | Turns on S and T axis coordinate generation, per the parameters set earlier. |
| void TexGenDisable() | | Turns coordinate generation off. |
| |
| void BuildBarberTexture(COLORREF TexColor, COLORREF BackColor, int Density = 32, BYTE TexAlpha = 255, BYTE BackAlpha = 255, BOOL bUseAlpha = FALSE) | | Build a barber-pole stripe texture. Density refers to the density of the pattern. If bUseAlpha is TRUE, the TexAlpha and BackAlpha values will be incorporated in a 32 bit texture; if bUseAlpha is FALSE, the other two Alpha values are ignored and the texture created is 24 bit. |
| void BuildCheckerTexture(COLORREF TexColor, COLORREF BackColor, int Density = 16, BYTE TexAlpha = 255, BYTE BackAlpha = 255, BOOL bUseAlpha = FALSE) | | Checkerboard pattern - all parameters as described above. |
| void BuildGridTexture(COLORREF TexColor, COLORREF BackColor, int Density = 8, BYTE TexAlpha = 255, BYTE BackAlpha = 255, BOOL bUseAlpha = FALSE) | | Grid pattern - all parameters as described above. |
| void BuildHoundTexture(COLORREF TexColor, COLORREF BackColor, int Density = 16, BYTE TexAlpha = 255, BYTE BackAlpha = 255, BOOL bUseAlpha = FALSE) | | Hounds tooth pattern - all parameters as described above. |
| void BuildCheckerTexture(COLORREF TexColor, COLORREF BackColor, int Density = 16, BYTE TexAlpha = 255, BYTE BackAlpha = 255, BOOL bUseAlpha = FALSE) | | Checkerboard pattern - all parameters as described above. |
| void BuildPlanetTexture( BYTE TexAlpha = 255, BOOL bUseAlpha = FALSE) | | Abstract pattern - all parameters as described above. |
| void BuildStripeTexture(COLORREF TexColor, COLORREF BackColor, int Density = 32, BYTE TexAlpha = 255, BYTE BackAlpha = 255, BOOL bUseAlpha = FALSE) | | Stripes - all parameters as described above. |
| |
| void BuildTextureFromResource(HINSTANCE AppInstance, UINT ImageID) | | AppInstance should self explanatory. Image ID is the resource ID from the .rc file (IDI_ROCKWALL_IMAGE in the example above). If the image is 32 bits per pixel, the texture will be created as GL_RGBA and the alpha information will be preserved. If bUseAlpha is TRUE and the image is less than 32 bpp, the texture will be created as GL_RGBA and the TexAlpha value will be used at each pixel If bUseAlpha is FALSE, the texture will be created as GL_RGB. CompressedFileName is for use with the variables bUseCompressed and bStoreCompressed, described above. If both are TRUE, the file name supplied here will be used for the compressed texture. The extension will be '.bist'. |
| void BuildTextureFromResource(HINSTANCE AppInstance, UINT ImageID, BYTE TexAlpha, BOOL bUseAlpha) |
| void BuildTextureFromResource(HINSTANCE AppInstance, UINT ImageID, BYTE TexAlpha, BOOL bUseAlpha, LPTSTR CompressedFileName) |
| |
| void BuildTextureFromFile(LPTSTR FileName) | | FileName should be self-explanatory; bTexAlpha, bUseAlpha and CompressedFileName are the same as with BuildTextureFromResource. |
| void BuildTextureFromFile(LPTSTR FileName, BYTE TexAlpha, BOOL bUseAlpha) |
| void BuildTextureFromFile(LPTSTR FileName, BYTE TexAlpha, BOOL bUseAlpha, LPTSTR CompressedFileName) |
| |
| void BuildTextureFromBitmap(HBITMAP hBitmap) | | hBitmap is the handle to any valid bitmap. If the bit per pixel is less than 24, it will be set to either 24 or 32, depending on the bUseAlpha parameter. bTexAlpha, bUseAlpha and CompressedFileName are the same as with BuildTextureFromResource. |
| void BuildTextureFromBitmap(HBITMAP hBitmap, BYTE TexAlpha, BOOL bUseAlpha) |
| void BuildTextureFromBitmap(HBITMAP hBitmap, BYTE TexAlpha, BOOL bUseAlpha, LPTSTR CompressedFileName ) |
| |
| void BuildTextureFromRamChunk(BYTE* data, int byte_count, LPSTR cExtension) | | Creates a texture from a block of ram containing an image in tga, ppm, ppg, bmp or jpg format. bTexAlpha, bUseAlpha and CompressedFileName are the same as with BuildTextureFromResource. |
| void BuildTextureFromRamChunk(BYTE* data, int byte_count, LPSTR cExtension, BYTE TexAlpha, BOOL bUseAlpha) |
| void BuildTextureFromRamChunk(BYTE* data, int byte_count, LPSTR cExtension, BYTE TexAlpha, BOOL bUseAlpha, LPTSTR CompressedFileName) |
| |
| void BuildCustomTexture(BYTE* ImagePtr, int iBitCount, LPTSTR compressedFileName) | | This will build a texture from a byte array. iBitCount must be either 24 or 32 bpp; CompressedFileName is as described above. |
| void BuildNormalMapFromHeightMap(HBITMAP hImage, float Scale = 1.0) | | This uses Mark Kilgard's code to build a full set of mip-mapped normal maps from a grayscale heightmap. The normal maps are suitable for use with the bump-mapped objects. |