cocos2d-x  2.2.3-gd2.113-rev1ec524e
Loading...
Searching...
No Matches
CCTextureAtlas Class Reference

A class that implements a Texture Atlas. More...

#include <CCTextureAtlas.h>

Inheritance diagram for CCTextureAtlas:
[legend]
Collaboration diagram for CCTextureAtlas:
[legend]

Public Member Functions

virtual unsigned int getTotalQuads (void)
 
virtual unsigned int getCapacity (void)
 
virtual CCTexture2DgetTexture (void)
 
virtual void setTexture (CCTexture2D *var)
 
virtual ccV3F_C4B_T2F_QuadgetQuads (void)
 
virtual void setQuads (ccV3F_C4B_T2F_Quad *var)
 
 CCTextureAtlas ()
 ctor More...
 
virtual ~CCTextureAtlas ()
 NA NA. More...
 
const char * description ()
 NA NA. More...
 
bool initWithFile (const char *file, unsigned int capacity)
 initializes a TextureAtlas with a filename and with a certain capacity for Quads. More...
 
bool initWithTexture (CCTexture2D *texture, unsigned int capacity)
 initializes a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for Quads. More...
 
void updateQuad (ccV3F_C4B_T2F_Quad *quad, unsigned int index)
 updates a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1 More...
 
void insertQuad (ccV3F_C4B_T2F_Quad *quad, unsigned int index)
 Inserts a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1. More...
 
void insertQuads (ccV3F_C4B_T2F_Quad *quads, unsigned int index, unsigned int amount)
 Inserts a c array of quads at a given index index must be between 0 and the atlas capacity - 1 this method doesn't enlarge the array when amount + index > totalQuads. More...
 
void insertQuadFromIndex (unsigned int fromIndex, unsigned int newIndex)
 Removes the quad that is located at a certain index and inserts it at a new index This operation is faster than removing and inserting in a quad in 2 different steps. More...
 
void removeQuadAtIndex (unsigned int index)
 removes a quad at a given index number. More...
 
void removeQuadsAtIndex (unsigned int index, unsigned int amount)
 removes a amount of quads starting from index More...
 
void removeAllQuads ()
 removes all Quads. More...
 
bool resizeCapacity (unsigned int n)
 resize the capacity of the CCTextureAtlas. More...
 
void increaseTotalQuadsWith (unsigned int amount)
 Used internally by CCParticleBatchNode don't use this unless you know what you're doing. More...
 
void moveQuadsFromIndex (unsigned int oldIndex, unsigned int amount, unsigned int newIndex)
 Moves an amount of quads from oldIndex at newIndex. More...
 
void moveQuadsFromIndex (unsigned int index, unsigned int newIndex)
 Moves quads from index till totalQuads to the newIndex Used internally by CCParticleBatchNode This method doesn't enlarge the array if newIndex + quads to be moved > capacity. More...
 
void fillWithEmptyQuadsFromIndex (unsigned int index, unsigned int amount)
 Ensures that after a realloc quads are still empty Used internally by CCParticleBatchNode. More...
 
void drawNumberOfQuads (unsigned int n)
 draws n quads n can't be greater than the capacity of the Atlas More...
 
void drawNumberOfQuads (unsigned int n, unsigned int start)
 draws n quads from an index (offset). More...
 
void drawQuads ()
 draws all the Atlas's Quads More...
 
void listenBackToForeground (CCObject *obj)
 listen the event that coming to foreground on Android More...
 
bool isDirty (void)
 whether or not the array buffer of the VBO needs to be updated More...
 
void setDirty (bool bDirty)
 specify if the array buffer of the VBO needs to be updated More...
 
- Public Member Functions inherited from CCObject
 CCObject (void)
 
virtual ~CCObject (void)
 NA. More...
 
void release (void)
 
void retain (void)
 
CCObjectautorelease (void)
 
CCObjectcopy (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)
 
 CCObject (const CCObject &)
 
CCObjectoperator= (const CCObject &)
 
virtual void encodeWithCoder (DS_Dictionary *)
 
virtual bool canEncode ()
 
CCObjectType getObjType () const
 
virtual int getTag () const
 
virtual void setTag (int nTag)
 
void setObjType (CCObjectType)
 
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)
 

Static Public Member Functions

static CCTextureAtlascreate (const char *file, unsigned int capacity)
 creates a TextureAtlas with an filename and with an initial capacity for Quads. More...
 
static CCTextureAtlascreateWithTexture (CCTexture2D *texture, unsigned int capacity)
 creates a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for n Quads. More...
 
- Static Public Member Functions inherited from CCObject
static CCObjectcreateWithCoder (DS_Dictionary *)
 

Protected Attributes

GLushort * m_pIndices
 
GLuint m_pBuffersVBO [2]
 
bool m_bDirty
 
unsigned int m_uTotalQuads
 quantity of quads that are going to be drawn More...
 
unsigned int m_uCapacity
 quantity of quads that can be stored with the current texture atlas size More...
 
CCTexture2Dm_pTexture
 Texture of the texture atlas. More...
 
ccV3F_C4B_T2F_Quadm_pQuads
 Quads that are going to be rendered. More...
 
- Protected Attributes inherited from CCObject
unsigned int m_uReference
 
unsigned int m_uAutoReleaseCount
 
int m_nTag
 
int m_eObjType
 
unsigned int m_uObjectIdxInArray
 

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
 
int m_nLuaID
 

Detailed Description

A class that implements a Texture Atlas.

Supported features: The atlas file can be a PVRTC, PNG or any other format supported by Texture2D Quads can be updated in runtime Quads can be added in runtime Quads can be removed in runtime Quads can be re-ordered in runtime The TextureAtlas capacity can be increased or decreased in runtime OpenGL component: V3F, C4B, T2F. The quads are rendered using an OpenGL ES VBO. To render the quads using an interleaved vertex array list, you should modify the ccConfig.h file

Constructor & Destructor Documentation

◆ CCTextureAtlas()

ctor

◆ ~CCTextureAtlas()

virtual ~CCTextureAtlas ( )
virtual

NA NA.

Member Function Documentation

◆ create()

static CCTextureAtlas * create ( const char *  file,
unsigned int  capacity 
)
static

creates a TextureAtlas with an filename and with an initial capacity for Quads.

The TextureAtlas capacity can be increased in runtime.

◆ createWithTexture()

static CCTextureAtlas * createWithTexture ( CCTexture2D texture,
unsigned int  capacity 
)
static

creates a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for n Quads.

The TextureAtlas capacity can be increased in runtime.

◆ description()

const char * description ( )

NA NA.

◆ drawNumberOfQuads() [1/2]

void drawNumberOfQuads ( unsigned int  n)

draws n quads n can't be greater than the capacity of the Atlas

◆ drawNumberOfQuads() [2/2]

void drawNumberOfQuads ( unsigned int  n,
unsigned int  start 
)

draws n quads from an index (offset).

n + start can't be greater than the capacity of the atlas

Since
v1.0

◆ drawQuads()

void drawQuads ( )

draws all the Atlas's Quads

◆ fillWithEmptyQuadsFromIndex()

void fillWithEmptyQuadsFromIndex ( unsigned int  index,
unsigned int  amount 
)

Ensures that after a realloc quads are still empty Used internally by CCParticleBatchNode.

Since
1.1

◆ getCapacity()

virtual unsigned int getCapacity ( void  )
virtual

◆ getQuads()

virtual ccV3F_C4B_T2F_Quad * getQuads ( void  )
virtual

◆ getTexture()

virtual CCTexture2D * getTexture ( void  )
virtual

◆ getTotalQuads()

virtual unsigned int getTotalQuads ( void  )
virtual

◆ increaseTotalQuadsWith()

void increaseTotalQuadsWith ( unsigned int  amount)

Used internally by CCParticleBatchNode don't use this unless you know what you're doing.

Since
1.1

◆ initWithFile()

bool initWithFile ( const char *  file,
unsigned int  capacity 
)

initializes a TextureAtlas with a filename and with a certain capacity for Quads.

The TextureAtlas capacity can be increased in runtime.

WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)

◆ initWithTexture()

bool initWithTexture ( CCTexture2D texture,
unsigned int  capacity 
)

initializes a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for Quads.

The TextureAtlas capacity can be increased in runtime.

WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)

◆ insertQuad()

void insertQuad ( ccV3F_C4B_T2F_Quad quad,
unsigned int  index 
)

Inserts a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1.

Since
v0.8

◆ insertQuadFromIndex()

void insertQuadFromIndex ( unsigned int  fromIndex,
unsigned int  newIndex 
)

Removes the quad that is located at a certain index and inserts it at a new index This operation is faster than removing and inserting in a quad in 2 different steps.

Since
v0.7.2

◆ insertQuads()

void insertQuads ( ccV3F_C4B_T2F_Quad quads,
unsigned int  index,
unsigned int  amount 
)

Inserts a c array of quads at a given index index must be between 0 and the atlas capacity - 1 this method doesn't enlarge the array when amount + index > totalQuads.

Since
v1.1

◆ isDirty()

bool isDirty ( void  )
inline

whether or not the array buffer of the VBO needs to be updated

◆ listenBackToForeground()

void listenBackToForeground ( CCObject obj)

listen the event that coming to foreground on Android

◆ moveQuadsFromIndex() [1/2]

void moveQuadsFromIndex ( unsigned int  index,
unsigned int  newIndex 
)

Moves quads from index till totalQuads to the newIndex Used internally by CCParticleBatchNode This method doesn't enlarge the array if newIndex + quads to be moved > capacity.

Since
1.1

◆ moveQuadsFromIndex() [2/2]

void moveQuadsFromIndex ( unsigned int  oldIndex,
unsigned int  amount,
unsigned int  newIndex 
)

Moves an amount of quads from oldIndex at newIndex.

Since
v1.1

◆ removeAllQuads()

void removeAllQuads ( )

removes all Quads.

The TextureAtlas capacity remains untouched. No memory is freed. The total number of quads to be drawn will be 0

Since
v0.7.2

◆ removeQuadAtIndex()

void removeQuadAtIndex ( unsigned int  index)

removes a quad at a given index number.

The capacity remains the same, but the total number of quads to be drawn is reduced in 1

Since
v0.7.2

◆ removeQuadsAtIndex()

void removeQuadsAtIndex ( unsigned int  index,
unsigned int  amount 
)

removes a amount of quads starting from index

Since
1.1

◆ resizeCapacity()

bool resizeCapacity ( unsigned int  n)

resize the capacity of the CCTextureAtlas.

The new capacity can be lower or higher than the current one It returns YES if the resize was successful. If it fails to resize the capacity it will return NO with a new capacity of 0.

◆ setDirty()

void setDirty ( bool  bDirty)
inline

specify if the array buffer of the VBO needs to be updated

◆ setQuads()

virtual void setQuads ( ccV3F_C4B_T2F_Quad var)
virtual

◆ setTexture()

virtual void setTexture ( CCTexture2D var)
virtual

◆ updateQuad()

void updateQuad ( ccV3F_C4B_T2F_Quad quad,
unsigned int  index 
)

updates a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1

Since
v0.8

Member Data Documentation

◆ m_bDirty

bool m_bDirty
protected

◆ m_pBuffersVBO

GLuint m_pBuffersVBO[2]
protected

◆ m_pIndices

GLushort* m_pIndices
protected

◆ m_pQuads

ccV3F_C4B_T2F_Quad* m_pQuads
protected

Quads that are going to be rendered.

◆ m_pTexture

CCTexture2D* m_pTexture
protected

Texture of the texture atlas.

◆ m_uCapacity

unsigned int m_uCapacity
protected

quantity of quads that can be stored with the current texture atlas size

◆ m_uTotalQuads

unsigned int m_uTotalQuads
protected

quantity of quads that are going to be drawn


The documentation for this class was generated from the following file: