Class to transparently deal with 3D textures. Allocates the texture directly from graphics system and provides functions for binding, unbinding and updating the texture.
More...
|
| gcgTEXTURE2D () |
| Constructs a valid gcgTEXTURE instance but no actual texture is created. More...
|
|
virtual | ~gcgTEXTURE2D () |
| Frees all texture resources by calling destroyTexture(). More...
|
|
bool | destroyTexture () |
| Frees all texture resources. Invocations to the object methods become innocuous. A call to createTexture() or uploadImage() turns the texture usable again. More...
|
|
bool | createTexture (unsigned int width, unsigned int height, unsigned char bpp, bool usealpha, bool mipmapped=false) |
| Creates a new texture filled with black pixels (zeros). It releases all resources of the previous texture. The actual texture allocated in the graphics systems has power of 2. Thus, if width or height are not powers of 2, they are adjusted to the smallest power of 2 greater than them. The bits per pixel bpp may be 4, 8, 16, 24 or 32 bits, and the internal graphics system attributes are selected accordingly, also depending on the usealpha parameter. More...
|
|
bool | uploadImage (gcgIMAGE *srcimage, int destposX=0, int destposY=0, unsigned int level=0, bool mipmapped=false) |
| Loads the contents of an image into an existing texture. If the current texture is not compatible with srcimage, it returns false. If the texture was not allocated yet, it creates a new texture compatible with srcimage and with its contents. The actual texture allocated in the graphics systems has power of 2. Thus, it uses the smallest power of 2 greater than the width and height of srcimage. The srcimage's bits per pixel, or bpp, may be 4, 8, 16, 24 or 32 bits, and the internal graphics system attributes are selected accordingly, depending if srcimage has an alpha channel. If bpp is 4 or 8, then the texture indicates luminance (pixel brightness) given by srcimage's palette colors. If bpp is 16 (with no alpha channel), 5 bits are allocated for red and blue channels, and 6 bits for the green channel. If bpp is 32 (with no alpha channel), 8 bits are allocated for red, green and blue channels and the remaining 8 bits are ignored. If an alpha channel is present in srcimage, some of the bits of the texture are reserved for it. This works ONLY for 16 and 32 bits. If bpp = 16, there are 2 possible mappings (depending on srcimage) for red, green, blue and alpha respectively: (4, 4, 4, 4) or (5, 5, 5, 1). If bpp is 32, 8 bits are allocated for each of the four channels. If bpp is 24, no alpha channel is possible. More...
|
|
bool | isCompatibleWith (gcgIMAGE *srcimage) |
| Checks if the current texture is compatible with the srcimage. They are compatible if the internal parameters of the graphics system needed to store the image and the texture are the same. It depends on the image's bits per pixel and if it has an alpha channel. Checking the compatibility is useful for copying the image's content into the texture by using uploadImage(). More...
|
|
bool | bind () |
| Binds a texture in the graphics system. Subsequent references to a texture will be addressed to the current texture. A later call to unbind() is mandatory to keep the system stable. More...
|
|
bool | unbind () |
| Unbinds a texture from the graphics system. It is called after a call to bind(). If this is not the case, the result is unpredictable. More...
|
|
void * | operator new (size_t size) |
| Defines a new operator to be used by instatiations of GCGlib classes instead the global one. More...
|
|
void * | operator new (size_t size, const std::nothrow_t &) throw () |
| Defines a new operator to be used by instantiations of GCGlib classes instead the global one. Returns a NULL pointer instead of throwing an exception if an error occurs. More...
|
|
void * | operator new[] (size_t size) |
| Defines a new operator to be used by GCGlib array allocations instead the global one. More...
|
|
void * | operator new[] (size_t size, const std::nothrow_t &) throw () |
| Defines a new operator to be used by vector allocations instead the global one. More...
|
|
void | operator delete (void *p) |
| Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More...
|
|
void | operator delete (void *p, const std::nothrow_t &) throw () |
| Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More...
|
|
void | operator delete[] (void *p) |
| Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More...
|
|
void | operator delete[] (void *p, const std::nothrow_t &) throw () |
| Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More...
|
|
|
unsigned int | width |
| Width effectively used by the texture. It must be <= actualwidth.
|
|
unsigned int | height |
| Height effectively used by the texture. It must be <= actualheight.
|
|
unsigned int | actualwidth |
| Real width of the texture inside the graphics system: must be a power of 2.
|
|
unsigned int | actualheight |
| Real Height of the texture inside the graphics system: must be a power of 2.
|
|
unsigned int | idOpengl |
| OpenGL texture internal identification.
|
|
int | internalformat |
| OpenGL internal format: GL_LUMINANCE4, GL_LUMINANCE8, GL_RGB5, GL_RGB5_A1, GL_RGBA8, GL_RGB8 or GL_RGB4, depending on the texture creation parameters.
|
|
int | format |
| OpenGL format: GL_LUMINANCE, GL_BGRA, GL_RGB or GL_RGBA, depending on the texture creation parameters.
|
|
int | type |
| OpenGL format: GL_UNSIGNED_BYTE, GL_BITMAP, GL_UNSIGNED_BYTE_4, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_SHORT_5_6_5, or GL_UNSIGNED_SHORT_4_4_4_4_REV, depending on the texture creation parameters.
|
|
Class to transparently deal with 3D textures. Allocates the texture directly from graphics system and provides functions for binding, unbinding and updating the texture.
- Since
- 0.01.6
bool gcgTEXTURE2D::uploadImage |
( |
gcgIMAGE * |
srcimage, |
|
|
int |
destposX = 0 , |
|
|
int |
destposY = 0 , |
|
|
unsigned int |
level = 0 , |
|
|
bool |
mipmapped = false |
|
) |
| |
Loads the contents of an image into an existing texture. If the current texture is not compatible with srcimage, it returns false. If the texture was not allocated yet, it creates a new texture compatible with srcimage and with its contents. The actual texture allocated in the graphics systems has power of 2. Thus, it uses the smallest power of 2 greater than the width and height of srcimage. The srcimage's bits per pixel, or bpp, may be 4, 8, 16, 24 or 32 bits, and the internal graphics system attributes are selected accordingly, depending if srcimage has an alpha channel. If bpp is 4 or 8, then the texture indicates luminance (pixel brightness) given by srcimage's palette colors. If bpp is 16 (with no alpha channel), 5 bits are allocated for red and blue channels, and 6 bits for the green channel. If bpp is 32 (with no alpha channel), 8 bits are allocated for red, green and blue channels and the remaining 8 bits are ignored. If an alpha channel is present in srcimage, some of the bits of the texture are reserved for it. This works ONLY for 16 and 32 bits. If bpp = 16, there are 2 possible mappings (depending on srcimage) for red, green, blue and alpha respectively: (4, 4, 4, 4) or (5, 5, 5, 1). If bpp is 32, 8 bits are allocated for each of the four channels. If bpp is 24, no alpha channel is possible.
- Parameters
-
[in] | srcimage | A valid gcgIMAGE object whose pixel contents are to be copied into the texture. |
[in] | destposX | Column coordinate of the texture to where srcimage's column 0 has to be copied. |
[in] | destposY | Row coordinate of the texture to where srcimage's row 0 has to be copied. |
[in] | level | Indicates the mipmap level of the current texture to where srcimage must be copied, if the current texture is mipmapped. |
[in] | mipmapped | If true, a pyramid of images are generated from srcimage and stored in each level of a mipmap. |
- Returns
- true if the image's content is copied into the graphics system's texture, or a new texture was created.
- See also
- createTexture()
-
isCompatibleWith()
- Since
- 0.01.6