CCTexture2D class. More...
#include <CCTexture2D.h>
Public Member Functions | |
CCTexture2D () | |
virtual | ~CCTexture2D () |
const char * | description (void) |
void | releaseData (void *data) |
These functions are needed to create mutable textures. More... | |
void * | keepData (void *data, unsigned int length) |
bool | initWithData (const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const CCSize &contentSize) |
Initializes with a texture2d with data. More... | |
void | drawAtPoint (const CCPoint &point) |
Drawing extensions to make it easy to draw basic quads using a CCTexture2D object. More... | |
void | drawInRect (const CCRect &rect) |
draws a texture inside a rect More... | |
bool | initWithImage (CCImage *uiImage) |
Extensions to make it easy to create a CCTexture2D object from an image file. More... | |
bool | initWithString (const char *text, const char *fontName, float fontSize, const CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment) |
Initializes a texture from a string with dimensions, alignment, font name and font size. More... | |
bool | initWithString (const char *text, const char *fontName, float fontSize) |
Initializes a texture from a string with font name and font size. More... | |
bool | initWithString (const char *text, ccFontDefinition *textDefinition) |
Initializes a texture from a string using a text definition. More... | |
bool | initWithPVRFile (const char *file) |
Initializes a texture from a PVR file. More... | |
bool | initWithETCFile (const char *file) |
Initializes a texture from a ETC file. More... | |
void | setTexParameters (ccTexParams *texParams) |
sets the min filter, mag filter, wrap s and wrap t texture parameters. More... | |
void | setAntiAliasTexParameters () |
sets antialias texture parameters: More... | |
void | setAliasTexParameters () |
sets alias texture parameters: More... | |
void | generateMipmap () |
Generates mipmap images for the texture. More... | |
const char * | stringForFormat () |
returns the pixel format. More... | |
unsigned int | bitsPerPixelForFormat () |
returns the bits-per-pixel of the in-memory OpenGL texture More... | |
unsigned int | bitsPerPixelForFormat (CCTexture2DPixelFormat format) |
Helper functions that returns bits per pixels for a given format. More... | |
const CCSize & | getContentSizeInPixels () |
content size More... | |
bool | hasPremultipliedAlpha () |
bool | hasMipmaps () |
virtual CCTexture2DPixelFormat | getPixelFormat (void) |
getPixelFormat More... | |
virtual unsigned int | getPixelsWide (void) |
getPixelsWide More... | |
virtual unsigned int | getPixelsHigh (void) |
getPixelsHigh More... | |
virtual GLuint | getName (void) |
getName More... | |
virtual GLfloat | getMaxS (void) |
getMaxS More... | |
virtual void | setMaxS (GLfloat var) |
setMaxS More... | |
virtual GLfloat | getMaxT (void) |
getMaxT More... | |
virtual void | setMaxT (GLfloat var) |
setMaxT More... | |
virtual CCSize | getContentSize (void) |
getContentSize More... | |
virtual CCGLProgram * | getShaderProgram (void) |
getShaderProgram More... | |
virtual void | setShaderProgram (CCGLProgram *var) |
setShaderProgram More... | |
![]() | |
CCObject (void) | |
virtual | ~CCObject (void) |
void | release (void) |
void | retain (void) |
CCObject * | autorelease (void) |
CCObject * | copy (void) |
bool | isSingleReference (void) const |
unsigned int | retainCount (void) const |
virtual bool | isEqual (const CCObject *pObject) |
virtual void | acceptVisitor (CCDataVisitor &visitor) |
virtual void | update (float dt) |
![]() | |
virtual CCObject * | copyWithZone (CCZone *pZone) |
Static Public Member Functions | |
static void | setDefaultAlphaPixelFormat (CCTexture2DPixelFormat format) |
sets the default pixel format for UIImagescontains alpha channel. More... | |
static CCTexture2DPixelFormat | defaultAlphaPixelFormat () |
returns the alpha pixel format More... | |
static void | PVRImagesHavePremultipliedAlpha (bool haveAlphaPremultiplied) |
treats (or not) PVR files as if they have alpha premultiplied. More... | |
Public Attributes | |
bool | m_bHasPremultipliedAlpha |
whether or not the texture has their Alpha premultiplied More... | |
bool | m_bHasMipmaps |
![]() | |
unsigned int | m_uID |
int | m_nLuaID |
Protected Attributes | |
CCTexture2DPixelFormat | m_ePixelFormat |
pixel format of the texture More... | |
unsigned int | m_uPixelsWide |
width in pixels More... | |
unsigned int | m_uPixelsHigh |
height in pixels More... | |
GLuint | m_uName |
texture name More... | |
GLfloat | m_fMaxS |
texture max S More... | |
GLfloat | m_fMaxT |
texture max T More... | |
CCSize | m_tContentSize |
content size More... | |
CCGLProgram * | m_pShaderProgram |
shader program used by drawAtPoint and drawInRect More... | |
![]() | |
unsigned int | m_uReference |
unsigned int | m_uAutoReleaseCount |
CCTexture2D class.
This class allows to easily create OpenGL 2D textures from images, text or raw data. The created CCTexture2D object will always have power-of-two dimensions. Depending on how you create the CCTexture2D object, the actual image area of the texture might be smaller than the texture dimensions i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). Be aware that the content of the generated textures will be upside-down!
CCTexture2D | ( | ) |
|
virtual |
unsigned int bitsPerPixelForFormat | ( | ) |
returns the bits-per-pixel of the in-memory OpenGL texture
unsigned int bitsPerPixelForFormat | ( | CCTexture2DPixelFormat | format | ) |
Helper functions that returns bits per pixels for a given format.
|
static |
returns the alpha pixel format
const char* description | ( | void | ) |
void drawAtPoint | ( | const CCPoint & | point | ) |
Drawing extensions to make it easy to draw basic quads using a CCTexture2D object.
These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled.draws a texture at a given point
void drawInRect | ( | const CCRect & | rect | ) |
draws a texture inside a rect
void generateMipmap | ( | ) |
Generates mipmap images for the texture.
It only works if the texture size is POT (power of 2).
|
virtual |
getContentSize
const CCSize& getContentSizeInPixels |
( | ) |
content size
|
virtual |
getMaxS
|
virtual |
getMaxT
|
virtual |
getName
|
virtual |
getPixelFormat
|
virtual |
getPixelsHigh
|
virtual |
getPixelsWide
|
virtual |
getShaderProgram
bool hasMipmaps | ( | ) |
bool hasPremultipliedAlpha | ( | ) |
bool initWithData | ( | const void * | data, |
CCTexture2DPixelFormat | pixelFormat, | ||
unsigned int | pixelsWide, | ||
unsigned int | pixelsHigh, | ||
const CCSize & | contentSize | ||
) |
Initializes with a texture2d with data.
bool initWithETCFile | ( | const char * | file | ) |
Initializes a texture from a ETC file.
bool initWithImage | ( | CCImage * | uiImage | ) |
Extensions to make it easy to create a CCTexture2D object from an image file.
Note that RGBA type textures will have their alpha premultiplied - use the blending mode (GL_ONE, GL_ONE_MINUS_SRC_ALPHA).Initializes a texture from a UIImage object
bool initWithPVRFile | ( | const char * | file | ) |
Initializes a texture from a PVR file.
bool initWithString | ( | const char * | text, |
const char * | fontName, | ||
float | fontSize, | ||
const CCSize & | dimensions, | ||
CCTextAlignment | hAlignment, | ||
CCVerticalTextAlignment | vAlignment | ||
) |
Initializes a texture from a string with dimensions, alignment, font name and font size.
bool initWithString | ( | const char * | text, |
const char * | fontName, | ||
float | fontSize | ||
) |
Initializes a texture from a string with font name and font size.
bool initWithString | ( | const char * | text, |
ccFontDefinition * | textDefinition | ||
) |
Initializes a texture from a string using a text definition.
void* keepData | ( | void * | data, |
unsigned int | length | ||
) |
|
static |
treats (or not) PVR files as if they have alpha premultiplied.
Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is possible load them as if they have (or not) the alpha channel premultiplied.
By default it is disabled.
void releaseData | ( | void * | data | ) |
These functions are needed to create mutable textures.
void setAliasTexParameters | ( | ) |
sets alias texture parameters:
void setAntiAliasTexParameters | ( | ) |
sets antialias texture parameters:
|
static |
sets the default pixel format for UIImagescontains alpha channel.
If the UIImage contains alpha channel, then the options are:
How does it work ?
This parameter is not valid for PVR / PVR.CCZ images.
|
virtual |
setMaxS
|
virtual |
setMaxT
|
virtual |
setShaderProgram
void setTexParameters | ( | ccTexParams * | texParams | ) |
sets the min filter, mag filter, wrap s and wrap t texture parameters.
If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.
const char* stringForFormat | ( | ) |
returns the pixel format.
bool m_bHasMipmaps |
bool m_bHasPremultipliedAlpha |
whether or not the texture has their Alpha premultiplied
|
protected |
pixel format of the texture
|
protected |
texture max S
|
protected |
texture max T
|
protected |
shader program used by drawAtPoint and drawInRect
|
protected |
content size
|
protected |
texture name
|
protected |
height in pixels
|
protected |
width in pixels