cocos2d-x  2.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCTextureAtlas Class Reference

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

#include <CCTextureAtlas.h>

Inheritance diagram for CCTextureAtlas:
CCObject CCCopying

Public Member Functions

virtual unsigned int getTotalQuads (void)
 getTotalQuads More...
 
virtual unsigned int getCapacity (void)
 getCapacity More...
 
local getCapacity ()
 getCapacity More...
 
virtual CCTexture2DgetTexture (void)
 getTexture More...
 
local getTexture ()
 getTexture More...
 
virtual void setTexture (CCTexture2D *var)
 setTexture More...
 
var setTexture ( var var)
 setTexture More...
 
local setTexture ( local var)
 setTexture More...
 
virtual ccV3F_C4B_T2F_QuadgetQuads (void)
 getQuads More...
 
local getQuads ()
 getQuads More...
 
virtual void setQuads (ccV3F_C4B_T2F_Quad *var)
 setQuads More...
 
var setQuads ( var var)
 setQuads More...
 
local setQuads ( local var)
 setQuads More...
 
 CCTextureAtlas ()
 CCTextureAtlas ()
virtual ~CCTextureAtlas ()
const char * description ()
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...
 
var removeQuadAtIndex ( var index)
 removes a quad at a given index number. More...
 
local removeQuadAtIndex ( local 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...
 
var removeQuadsAtIndex ( var index, var amount)
 removes a amount of quads starting from index More...
 
local removeQuadsAtIndex ( local index, local 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...
 
local resizeCapacity ( local 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...
 
var moveQuadsFromIndex ( var oldIndex, var amount, var newIndex)
 Moves an amount of quads from oldIndex at newIndex. More...
 
local moveQuadsFromIndex ( local oldIndex, local amount, local 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...
 
var drawNumberOfQuads ( var n, var start)
 draws n quads from an index (offset). More...
 
local drawNumberOfQuads ( local n, local 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...
 
var listenBackToForeground ( var obj)
 listen the event that coming to foreground on Android More...
 
local listenBackToForeground ( local 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...
 
var setDirty ( var bDirty)
 specify if the array buffer of the VBO needs to be updated More...
 
local setDirty ( local 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)
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)
- 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...
 

Protected Attributes

GLushort * m_pIndices
var m_pIndices
local m_pIndices
GLuint m_pBuffersVBO [2]
var m_pBuffersVBO ()
local m_pBuffersVBO ()
bool m_bDirty
var m_bDirty
local m_bDirty
unsigned int m_uTotalQuads
 quantity of quads that are going to be drawn More...
 
var m_uTotalQuads
 quantity of quads that are going to be drawn More...
 
local 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...
 
var m_pTexture
 Texture of the texture atlas. More...
 
local m_pTexture
 Texture of the texture atlas. More...
 
ccV3F_C4B_T2F_Quadm_pQuads
 Quads that are going to be rendered. More...
 
var m_pQuads
 Quads that are going to be rendered. More...
 
local m_pQuads
 Quads that are going to be rendered. More...
 
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

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

var ctor ( )
local CCTextureAtlas ( )
virtual ~CCTextureAtlas ( )
virtual

Member Function Documentation

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.

var create ( var  file,
var  capacity 
)
static

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

The TextureAtlas capacity can be increased in runtime.

local create ( local  file,
local  capacity 
)
static

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

The TextureAtlas capacity can be increased in runtime.

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.

var createWithTexture ( var  texture,
var  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.

local createWithTexture ( local  texture,
local  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.

const char* description ( )
void drawNumberOfQuads ( unsigned int  n)

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

var drawNumberOfQuads ( var  n)

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

local drawNumberOfQuads ( local  n)

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

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
var drawNumberOfQuads ( var  n,
var  start 
)

draws n quads from an index (offset).

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

Since
v1.0
local drawNumberOfQuads ( local  n,
local  start 
)

draws n quads from an index (offset).

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

Since
v1.0
void drawQuads ( )

draws all the Atlas's Quads

var drawQuads ( )

draws all the Atlas's Quads

local drawQuads ( )

draws all the Atlas's Quads

void fillWithEmptyQuadsFromIndex ( unsigned int  index,
unsigned int  amount 
)

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

Since
1.1
var fillWithEmptyQuadsFromIndex ( var  index,
var  amount 
)

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

Since
1.1
local fillWithEmptyQuadsFromIndex ( local  index,
local  amount 
)

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

Since
1.1
virtual unsigned int getCapacity ( void  )
virtual

getCapacity

var getCapacity (   )
virtual

getCapacity

local getCapacity (   )
virtual

getCapacity

virtual ccV3F_C4B_T2F_Quad*
getQuads
( void  )
virtual

getQuads

var getQuads (   )
virtual

getQuads

local getQuads (   )
virtual

getQuads

virtual CCTexture2D* getTexture ( void  )
virtual

getTexture

var getTexture (   )
virtual

getTexture

local getTexture (   )
virtual

getTexture

virtual unsigned int getTotalQuads ( void  )
virtual

getTotalQuads

var getTotalQuads (   )
virtual

getTotalQuads

local getTotalQuads (   )
virtual

getTotalQuads

void increaseTotalQuadsWith ( unsigned int  amount)

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

Since
1.1
var increaseTotalQuadsWith ( var  amount)

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

Since
1.1
local increaseTotalQuadsWith ( local  amount)

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

Since
1.1
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)

var initWithFile ( var  file,
var  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)

local initWithFile ( local  file,
local  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)

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)

var initWithTexture ( var  texture,
var  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)

local initWithTexture ( local  texture,
local  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)

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
var insertQuad ( var  quad,
var  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
local insertQuad ( local  quad,
local  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
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
var insertQuadFromIndex ( var  fromIndex,
var  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
local insertQuadFromIndex ( local  fromIndex,
local  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
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
var insertQuads ( var  quads,
var  index,
var  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
local insertQuads ( local  quads,
local  index,
local  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
bool isDirty ( void  )
inline

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

var isDirty (   )
inline

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

local isDirty (   )
inline

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

void listenBackToForeground ( CCObject obj)

listen the event that coming to foreground on Android

var listenBackToForeground ( var  obj)

listen the event that coming to foreground on Android

local listenBackToForeground ( local  obj)

listen the event that coming to foreground on Android

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

Moves an amount of quads from oldIndex at newIndex.

Since
v1.1
var moveQuadsFromIndex ( var  oldIndex,
var  amount,
var  newIndex 
)

Moves an amount of quads from oldIndex at newIndex.

Since
v1.1
local moveQuadsFromIndex ( local  oldIndex,
local  amount,
local  newIndex 
)

Moves an amount of quads from oldIndex at newIndex.

Since
v1.1
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
var moveQuadsFromIndex ( var  index,
var  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
local moveQuadsFromIndex ( local  index,
local  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
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
var 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
local 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
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
var removeQuadAtIndex ( var  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
local removeQuadAtIndex ( local  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
void removeQuadsAtIndex ( unsigned int  index,
unsigned int  amount 
)

removes a amount of quads starting from index

Since
1.1
var removeQuadsAtIndex ( var  index,
var  amount 
)

removes a amount of quads starting from index

Since
1.1
local removeQuadsAtIndex ( local  index,
local  amount 
)

removes a amount of quads starting from index

Since
1.1
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.

var resizeCapacity ( var  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.

local resizeCapacity ( local  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.

void setDirty ( bool  bDirty)
inline

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

var setDirty ( var  bDirty)
inline

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

local setDirty ( local  bDirty)
inline

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

virtual void setQuads ( ccV3F_C4B_T2F_Quad var)
virtual

setQuads

var setQuads ( var  var)
virtual

setQuads

local setQuads ( local  var)
virtual

setQuads

virtual void setTexture ( CCTexture2D var)
virtual

setTexture

var setTexture ( var  var)
virtual

setTexture

local setTexture ( local  var)
virtual

setTexture

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
var updateQuad ( var  quad,
var  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
local updateQuad ( local  quad,
local  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

bool m_bDirty
protected
var m_bDirty
protected
local m_bDirty
protected
GLuint m_pBuffersVBO[2]
protected
GLuint m_pBuffersVBO[2]
protected
GLuint m_pBuffersVBO[2]
protected
GLushort* m_pIndices
protected
var m_pIndices
protected
local m_pIndices
protected
ccV3F_C4B_T2F_Quad* m_pQuads
protected

Quads that are going to be rendered.

var m_pQuads
protected

Quads that are going to be rendered.

local m_pQuads
protected

Quads that are going to be rendered.

CCTexture2D* m_pTexture
protected

Texture of the texture atlas.

var m_pTexture
protected

Texture of the texture atlas.

local m_pTexture
protected

Texture of the texture atlas.

unsigned int m_uCapacity
protected

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

var m_uCapacity
protected

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

local m_uCapacity
protected

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

unsigned int m_uTotalQuads
protected

quantity of quads that are going to be drawn

var m_uTotalQuads
protected

quantity of quads that are going to be drawn

local m_uTotalQuads
protected

quantity of quads that are going to be drawn


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