My Project
|
Texture represents a 2D texture image. More...
#include <Texture.h>
Public Member Functions | |
Texture (const uint8 *pBuffer, int width, int height, int stride, int borderSize, bool bClamp, bool useCompression, bool useAlpha=false) | |
Creates a new 2D texture image from a raw buffer of bytes. More... | |
Texture (const uint8 *pBuffer, int width, int height, int stride, int borderSize, bool bClamp, bool useCompression, int bytesPerPixel, int textureFormat) | |
Creates a new 2D texture image from raw bytes. More... | |
Texture (TextureEntity *pEntity) | |
texture from ParaEngine's texture entity. More... | |
Texture () | |
Creates an empty 2D texture image that is not yet suitable for use by Demeter. More... | |
~Texture () | |
Destroys the texture, including its image data (if still held by this time) and OpenGL texture. | |
DeviceTexturePtr_type | UploadTexture () |
Binds the 2D image data to an OpenGL texture. More... | |
void | UnloadTexture () |
Unbinds the OpenGL texture object, releasing texture memory. More... | |
uint8 * | GetBuffer () |
Gets a pointer to the 2D image data represented by this Texture object. More... | |
int | GetWidth () |
Gets the width of the 2D image in pixels. | |
int | GetHeight () |
Gets the height of the 2D image in pixels. | |
void | SetWidth (int nWidth) |
set the image width. More... | |
void | SetSharedIndex (int index) |
Marks this Texture as belonging to a Terrain's pool of textures to be used for detail texture painting. More... | |
int | GetSharedIndex () |
Gets the index of this Texture in the managing Terrain's pool of detail textures. More... | |
void | SetFilename (const char *szFilename) |
Simply tags the Texture as having come from the specified file. More... | |
const char * | GetFilename () |
Gets the filename tag for this Texture. More... | |
void | FlipVertical () |
Flips the 2D image data of this Texture vertically. More... | |
void | FlipHorizontal () |
Flips the 2D image data of this Texture horizontally. More... | |
bool | IsBound () |
Indicates whether or not this Texture has already been bound to an OpenGL texture object. | |
int | GetBitsPerPixel () |
Gets the color depth of this Texture. | |
int | GetBytesPerPixel () |
bool | IsClamped () |
Indicates whether or not this Texture uses clamp extensions when bound to an OpenGL texture object. | |
bool | UseCompression () |
Indicates whether or not this Texture uses compression extensions when bound to an OpenGL texture object. | |
int | GetBorderSize () |
Gets the OpenGL border size of this Texture. | |
int | GetFormat () |
Gets the OpenGL texture format of this Texture. For example, GL_RGBA, etc. | |
void | SetBufferPersistent (bool persist) |
Specified whether or not this Texture's 2D image data should be retained after it is bound to an OpenGL texture object. More... | |
TextureEntity * | GetTextureEntity () |
get the TextureEntity associated with this texture object. More... | |
bool | SetTextureEntity (TextureEntity *texture) |
set the TextureEnity. More... | |
DeviceTexturePtr_type | GetDevicePointer () |
get Texture device pointer | |
bool | IsEqual (ParaEngine::TextureEntity *pEntity) |
Static Public Member Functions | |
static void | SetDefaultTextureFormat (int GLTextureFormat) |
Specifies the default OpenGL texture format that textures should be created as when they are bound to OpenGL texture objects. More... | |
static void | SetAlphaTextureFormat (int GLTextureFormat) |
Specifies the default OpenGL texture format that textures containing ONLY alpha values should be created as when they are bound to OpenGL texture objects. More... | |
static void | SetRgbaTextureFormat (int GLTextureFormat) |
Specifies the default OpenGL texture format that textures should be created as when they are bound to OpenGL texture objects. The default is GL_RGBA. More... | |
static void | SetCompressedTextureFormat (int GLTextureFormat) |
Specifies the default OpenGL texture format that textures should be created as when they are bound to OpenGL texture objects. More... | |
Friends | |
class | DetailTexture |
Texture represents a 2D texture image.
Instances of this class are used for the overall terrain texture, for common textures, and for detail textures. See the Documentation at terrainengine.com for details on each of these different uses of textures. Most users simply let TextureLoaders create instances of this class for them, but you can use the static SetXXXTextureFormat methods of this class to specify which OpenGL texture formats Demeter should create even if you aren't directly creating your own instances of this class. You can create your own instances of this class for advanced texturing, such as when implementing a TextureFactory or doing detail texture painting.
Texture::Texture | ( | const uint8 * | pBuffer, |
int | width, | ||
int | height, | ||
int | stride, | ||
int | borderSize, | ||
bool | bClamp, | ||
bool | useCompression, | ||
bool | useAlpha = false |
||
) |
Creates a new 2D texture image from a raw buffer of bytes.
This constructor assumes that the buffer contains RGB byte triplets or RGBA byte quartets. It makes a copy of the buffer, so the Texture object does not attempt to own the buffer for later deleting.
pBuffer | A pointer to the RGB or RGBA bytes describing the image. |
width | The width of the image in pixels. |
height | The height of the image in pixels. |
stride | The number of triplets or quartets in each row. For simple buffers, this will be equal to the width parameter. It will only be different if the rows in your image buffer contain padding before the next row begins. |
borderSize | The border size to use when this image is converted into an OpenGL texture. This value should be zero unless you have built border pixels into your image. |
bClamp | Specifies whether or not to set texture clamping when the image is converted into an OpenGL texture. |
useCompression | Specifies whether or not to use OpenGL compression extensions when this image is converted into an OpenGL texture. |
useAlpha | Specifies whether or not the buffer passed in the pBuffer parameter contains RGBA quartets (where the 4th byte of each pixel is alpha) or not (if not, the buffer contains only RGB triplets.) |
Texture::Texture | ( | const uint8 * | pBuffer, |
int | width, | ||
int | height, | ||
int | stride, | ||
int | borderSize, | ||
bool | bClamp, | ||
bool | useCompression, | ||
int | bytesPerPixel, | ||
int | textureFormat | ||
) |
Creates a new 2D texture image from raw bytes.
This constructor assumes that the buffer contains RGB byte triplets or RGBA byte quartets. It makes a copy of the buffer, so the Texture object does not attempt to own the buffer for later deleting. Texture constructor detailed description.
pBuffer | A pointer to the RGB or RGBA bytes describing the image. |
width | The width of the image in pixels. |
height | The height of the image in pixels. |
stride | The number of triplets or quartets in each row. For simple buffers, this will be equal to the width parameter. It will only be different if the rows in your image buffer contain padding before the next row begins. |
borderSize | The border size to use when this image is converted into an OpenGL texture. This value should be zero unless you have built border pixels into your image. |
bClamp | Specifies whether or not to set texture clamping when the image is converted into an OpenGL texture. |
useCompression | Specifies whether or not to use OpenGL compression extensions when this image is converted into an OpenGL texture. |
bytesPerPixel | The number of bytes per pixel in the image buffer. Currently, only values of 3 or 4 are legal. |
textureFormat | The OpenGL texture format of the texture to be created from the image data. |
Texture::Texture | ( | TextureEntity * | pEntity | ) |
texture from ParaEngine's texture entity.
Texture::Texture | ( | ) |
Creates an empty 2D texture image that is not yet suitable for use by Demeter.
This constructor is only useful if you need to create an instance of Texture but must defer the loading of its image data until a later time.
void Texture::FlipHorizontal | ( | ) |
void Texture::FlipVertical | ( | ) |
uint8 * Texture::GetBuffer | ( | ) |
Gets a pointer to the 2D image data represented by this Texture object.
const char * Texture::GetFilename | ( | ) |
Gets the filename tag for this Texture.
int Texture::GetSharedIndex | ( | ) |
TextureEntity * Texture::GetTextureEntity | ( | ) |
get the TextureEntity associated with this texture object.
if the texture type is ParaX texture entity
|
static |
Specifies the default OpenGL texture format that textures containing ONLY alpha values should be created as when they are bound to OpenGL texture objects.
This setting is used by Demeter whenever it creates OpenGL texture objects from the 2D image data provided by your application (or when Texture Loaders are used.) Therefore, this setting allows you to specify what the format of textures will be, even if you aren't directly creating Texture objects yourself.
void Texture::SetBufferPersistent | ( | bool | persist | ) |
Specified whether or not this Texture's 2D image data should be retained after it is bound to an OpenGL texture object.
By default, when a Texture is bound by calling UploadTexture(), its 2D image buffer is deleted. If you need to dynamically modify the texture at runtime, then you must change this behavior by calling SetBufferPersisten(true). In this mode, when UploadTexture() is called, the Texture object still has its original 2D image buffer, so you can make changes to this buffer and call UploadTexture() again to make those changes visible. Of course, this makes each Texture consume approximately twice the memory.
|
static |
Specifies the default OpenGL texture format that textures should be created as when they are bound to OpenGL texture objects.
This setting is used by Demeter whenever it creates OpenGL texture objects from the 2D image data provided by your application (or when Texture Loaders are used.) Therefore, this setting allows you to specify what the format of textures will be, even if you aren't directly creating Texture objects yourself. The default value is COMPRESSED_RGB_S3TC_DXT1_EXT.
|
static |
Specifies the default OpenGL texture format that textures should be created as when they are bound to OpenGL texture objects.
This setting is used by Demeter whenever it creates OpenGL texture objects from the 2D image data provided by your application (or when Texture Loaders are used.) Therefore, this setting allows you to specify what the format of textures will be, even if you aren't directly creating Texture objects yourself. The default value is GL_RGB8.
void Texture::SetFilename | ( | const char * | szFilename | ) |
|
static |
Specifies the default OpenGL texture format that textures should be created as when they are bound to OpenGL texture objects. The default is GL_RGBA.
This setting is used by Demeter whenever it creates OpenGL texture objects from the 2D image data provided by your application (or when Texture Loaders are used.) Therefore, this setting allows you to specify what the format of textures will be, even if you aren't directly creating Texture objects yourself.
void Texture::SetSharedIndex | ( | int | index | ) |
Marks this Texture as belonging to a Terrain's pool of textures to be used for detail texture painting.
Generally, external code has little reason to ever call this method. This method is used internally by Demeter to manage texture pools.
index | The new unique ID of this Texture. You must guarantee that the ID is unique relative to all other Textures in the pool. SetSharedIndex function detailed description. |
bool Texture::SetTextureEntity | ( | TextureEntity * | texture | ) |
set the TextureEnity.
The function only succeed, if the texture type is ParaX texture entity. this function can be called multiple times to replace old textures.
void Texture::SetWidth | ( | int | nWidth | ) |
set the image width.
height is also changed. it will resize the buffer (shrink or enlarge the image) if necessary.
void Texture::UnloadTexture | ( | ) |
Unbinds the OpenGL texture object, releasing texture memory.
If SetBufferPersistent() has been called on this Texture object, it can be rebound by calling UploadTexture(). UnloadTexture function detailed description.
DeviceTexturePtr_type Texture::UploadTexture | ( | ) |
Binds the 2D image data to an OpenGL texture.
If SetBufferPersistent() has been called on this Texture object, then the associated 2D image data is maintained in system RAM for later calls to UploadTexture(). Otherwise, the image data is freed from system RAM and only the OpenGL texture remains (hopefully residing in video RAM.)
create d3d managed texture
create texture using the normal way from memory buffer.