gmlGL_TTexture Class Reference

#include <gml_GL_Texture.h>

Collaboration diagram for gmlGL_TTexture:

Collaboration graph
[legend]
List of all members.

Detailed Description

Abstraction of OpenGL textures, that allows texture uploading from GML bitmaps.

Todo:
isolate the GL implementation of the texture from an abstract texture type. The abstract type should only have "Init", "Dispose", "SetBitmap", "Update", and "Exists" methods. The other ones are GL specific.


Public Member Functions

gml_TError Init ()
 Zero the structure. No side effects.
void Dispose ()
 Release the GL resources used by this texture, if any.
gml_TError Upload (gml_TBitmap *bitmap, gml_TRect *roi=(gml_TRect *) NULL, gml_TBoolean persistent=gml_cFalse, gml_TBoolean alphaTexture=gml_cFalse)
 Copy the specified region roi of the bitmap to the texture. The OpenGL texture may need to be re-created.
gml_TError Download (gml_TBitmap *bitmap, gml_TRect *source=(gml_TRect *) NULL, gml_TRect *dest=(gml_TRect *) NULL)
 Copy the specified source region of the texture to the dest region of the bitmap. Fails for non-RGB texture encodings. Fast only if both the texture and the destination bitmap are 32-bit RGB.
gml_TError BeginRenderTo ()
 Setup the sharing context so that GL operations draw to the texture. As a side effect, the current context is set to the sharing context.
gml_TError EndRenderTo ()
 Commit render-to-texture operations.
void UpdateFromBitmap ()
 Notify the texture that the bitmap's pixels have been modified and so / the texture should update itseld from the bitmap.
gml_TError Copy (gmlGL_TTexture *other, gml_TRect *source=NULL, gml_TRect *dest=NULL, Float32 *transfo=NULL)
 Copy region source of the texture to region dest of texture other. Any of the two regions may be passed as NULL, in which case the whole texture will be used. The regions will be clamped to the bounding rectangles. The regions need not be of the same size; the texture will be scaled appropriately.
gml_TBoolean Exists ()
 Return true if Upload() has successfully been called at least once.
void Enable ()
 Prepare to render the texture to OpenGL primitives.
void Disable ()
 Stop rendering the texture to OpenGL primitives. Equivalent to a call to glDisable with the appropriate target.
void Coords (GLfloat ix, GLfloat iy, GLfloat &ox, GLfloat &oy)
 Given pixel coordinates ix and iy in the bitmap, return in ox and oy the coordinates to be used in glTexCoord.
void NormalCoords (GLfloat ix, GLfloat iy, GLfloat &ox, GLfloat &oy)
 Same as Coords, but with input coordinates normalized to the size of the bitmap's region of interest.
Float32 Alpha (Float32 x, Float32 y)
 Returns the transparency parameter of the bitmap pixel at coordinates x, y.
GLuint GLName ()
void Rect (gml_TRect &rect)

Member Function Documentation

void Dispose (  ) 

Release the GL resources used by this texture, if any.

Can be called at any time.

gml_TError Upload ( gml_TBitmap bitmap,
gml_TRect roi = (gml_TRect *) NULL,
gml_TBoolean  persistent = gml_cFalse,
gml_TBoolean  alphaTexture = gml_cFalse 
)

Copy the specified region roi of the bitmap to the texture. The OpenGL texture may need to be re-created.

If roi is NULL, use the whole bitmap.

If persistent is false, this means that bitmap is not persistent and a private copy is made by the texture object. If true, the bitmap is considered persistent until the deletion of the texture object. Its early destruction will result un undefined behavior.

Return an error code if the bitmap has unsupported characteristics.

Can be called at any time.

void UpdateFromBitmap (  ) 

Notify the texture that the bitmap's pixels have been modified and so / the texture should update itseld from the bitmap.

Upload() must have been called since Init().

DEPRECATED.

Todo:
replace gml_Bitmap_Copy with gml_TScannerCopy::Process?

void Enable (  ) 

Prepare to render the texture to OpenGL primitives.

Equivalent to a call to glEnable and glBindTexture with the appropriate target.

Note: if the current context is different from the last call to Enable(), the texture will be uploaded again.

void Disable (  ) 

Stop rendering the texture to OpenGL primitives. Equivalent to a call to glDisable with the appropriate target.

The OpenGL context current when Enable() was called must be current.

void Coords ( GLfloat  ix,
GLfloat  iy,
GLfloat &  ox,
GLfloat &  oy 
)

Given pixel coordinates ix and iy in the bitmap, return in ox and oy the coordinates to be used in glTexCoord.

Note: this is to take ordering and possible padding of the texture lines into account, as well as different coordinate conventions depending on the texture target used (GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_EXT).

Can only be called after Upload().

void NormalCoords ( GLfloat  ix,
GLfloat  iy,
GLfloat &  ox,
GLfloat &  oy 
)

Same as Coords, but with input coordinates normalized to the size of the bitmap's region of interest.

Can only be called after Upload().

Float32 Alpha ( Float32  x,
Float32  y 
)

Returns the transparency parameter of the bitmap pixel at coordinates x, y.

If x, y is out of range of the texture, return 0 (fully transparent). If the texture has no transparency information, return 1 (fully opaque).

Note: The origin of bitmap coordinates is at the top left corner of the texture .

Can only be called after Upload().

Todo:
replace lround() with LRound()


The documentation for this class was generated from the following files:
Generated on Tue Jun 12 14:03:28 2007 for gml by Doxygen 1.5.2.