cocos2d-x  3.0-alpha0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TextureAtlas Class Reference

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

#include <CCTextureAtlas.h>

Inheritance diagram for TextureAtlas:
Object

Public Member Functions

 TextureAtlas ()
virtual ~TextureAtlas ()
bool initWithFile (const char *file, int capacity)
 initializes a TextureAtlas with a filename and with a certain capacity for Quads. More...
 
bool initWithTexture (Texture2D *texture, int capacity)
 initializes a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for Quads. More...
 
var initWithTexture ( var texture, var capacity)
 initializes a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for Quads. More...
 
local initWithTexture ( local texture, local capacity)
 initializes a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for Quads. More...
 
void updateQuad (V3F_C4B_T2F_Quad *quad, 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 (V3F_C4B_T2F_Quad *quad, 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 (V3F_C4B_T2F_Quad *quads, int index, 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...
 
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. More...
 
void insertQuadFromIndex (int fromIndex, 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 (int index)
 removes a quad at a given index number. More...
 
void removeQuadsAtIndex (int index, int amount)
 removes a amount of quads starting from index More...
 
void removeAllQuads ()
 removes all Quads. More...
 
bool resizeCapacity (int capacity)
 resize the capacity of the TextureAtlas. More...
 
void increaseTotalQuadsWith (int amount)
 Used internally by ParticleBatchNode don't use this unless you know what you're doing. More...
 
void moveQuadsFromIndex (int oldIndex, int amount, int newIndex)
 Moves an amount of quads from oldIndex at newIndex. More...
 
void moveQuadsFromIndex (int index, int newIndex)
 Moves quads from index till totalQuads to the newIndex Used internally by ParticleBatchNode This method doesn't enlarge the array if newIndex + quads to be moved > capacity. More...
 
void fillWithEmptyQuadsFromIndex (int index, int amount)
 Ensures that after a realloc quads are still empty Used internally by ParticleBatchNode. More...
 
void drawNumberOfQuads (int n)
 draws n quads n can't be greater than the capacity of the Atlas More...
 
void drawNumberOfQuads (int numberOfQuads, int start)
 draws n quads from an index (offset). More...
 
var drawNumberOfQuads ( var numberOfQuads, var start)
 draws n quads from an index (offset). More...
 
local drawNumberOfQuads ( local numberOfQuads, local start)
 draws n quads from an index (offset). More...
 
void drawQuads ()
 draws all the Atlas's Quads More...
 
void listenBackToForeground (Object *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...
 
const char * description () const
int getTotalQuads () const
 Gets the quantity of quads that are going to be drawn. More...
 
int getCapacity () const
 Gets the quantity of quads that can be stored with the current texture atlas size. More...
 
Texture2DgetTexture () const
 Gets the texture of the texture atlas. More...
 
void setTexture (Texture2D *texture)
 Sets the texture for the texture atlas. More...
 
V3F_C4B_T2F_QuadgetQuads ()
 Gets the quads that are going to be rendered. More...
 
void setQuads (V3F_C4B_T2F_Quad *quads)
 Sets the quads that are going to be rendered. More...
 
- Public Member Functions inherited from Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
void release ()
 Release the ownership immediately. More...
 
void retain ()
 Retains the ownership. More...
 
Objectautorelease ()
 Release the ownership sometime soon automatically. More...
 
bool isSingleReference () const
 Returns a boolean value that indicates whether there is only one reference to the object. More...
 
unsigned int retainCount () const
 Returns the object's current reference count. More...
 
virtual bool isEqual (const Object *object)
 Returns a boolean value that indicates whether this object and a given object are equal. More...
 
virtual void acceptVisitor (DataVisitor &visitor)
virtual void update (float dt)

Static Public Member Functions

static TextureAtlascreate (const char *file, int capacity)
 creates a TextureAtlas with an filename and with an initial capacity for Quads. More...
 
local create ( local file, local capacity)
 creates a TextureAtlas with an filename and with an initial capacity for Quads. More...
 
static TextureAtlascreateWithTexture (Texture2D *texture, int capacity)
 creates a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for n Quads. More...
 
var createWithTexture ( var texture, var capacity)
 creates a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for n Quads. More...
 
local createWithTexture ( local texture, local capacity)
 creates a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for n Quads. More...
 

Protected Attributes

GLushort * _indices
GLuint _buffersVBO [2]
var _buffersVBO ()
local _buffersVBO ()
bool _dirty
int _totalQuads
 quantity of quads that are going to be drawn More...
 
var _totalQuads
 quantity of quads that are going to be drawn More...
 
local _totalQuads
 quantity of quads that are going to be drawn More...
 
int _capacity
 quantity of quads that can be stored with the current texture atlas size More...
 
Texture2D_texture
 Texture of the texture atlas. More...
 
var _texture
 Texture of the texture atlas. More...
 
local _texture
 Texture of the texture atlas. More...
 
V3F_C4B_T2F_Quad_quads
 Quads that are going to be rendered. More...
 
var _quads
 Quads that are going to be rendered. More...
 
local _quads
 Quads that are going to be rendered. More...
 
- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
var _reference
 count of references More...
 
local _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 
var _autoReleaseCount
 count of autorelease More...
 
local _autoReleaseCount
 count of autorelease More...
 

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 

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 TextureAtlas ( )
virtual ~TextureAtlas ( )
virtual

Member Function Documentation

static TextureAtlas* create ( const char *  file,
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 TextureAtlas*
createWithTexture
( Texture2D texture,
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 ( ) const
void drawNumberOfQuads ( 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 ( int  numberOfQuads,
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  numberOfQuads,
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  numberOfQuads,
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 ( int  index,
int  amount 
)

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

Since
1.1
var fillWithEmptyQuadsFromIndex ( var  index,
var  amount 
)

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

Since
1.1
local fillWithEmptyQuadsFromIndex ( local  index,
local  amount 
)

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

Since
1.1
int getCapacity ( ) const

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

var getCapacity ( )

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

local getCapacity ( )

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

V3F_C4B_T2F_Quad* getQuads ( )

Gets the quads that are going to be rendered.

var getQuads ( )

Gets the quads that are going to be rendered.

local getQuads ( )

Gets the quads that are going to be rendered.

Texture2D* getTexture ( ) const

Gets the texture of the texture atlas.

var getTexture ( )

Gets the texture of the texture atlas.

local getTexture ( )

Gets the texture of the texture atlas.

int getTotalQuads ( ) const

Gets the quantity of quads that are going to be drawn.

var getTotalQuads ( )

Gets the quantity of quads that are going to be drawn.

local getTotalQuads ( )

Gets the quantity of quads that are going to be drawn.

void increaseTotalQuadsWith ( int  amount)

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

Since
1.1
var increaseTotalQuadsWith ( var  amount)

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

Since
1.1
local increaseTotalQuadsWith ( local  amount)

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

Since
1.1
bool initWithFile ( const char *  file,
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 ( Texture2D texture,
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 ( V3F_C4B_T2F_Quad quad,
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 ( int  fromIndex,
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 ( V3F_C4B_T2F_Quad quads,
int  index,
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 ( Object 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 ( int  oldIndex,
int  amount,
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 ( int  index,
int  newIndex 
)

Moves quads from index till totalQuads to the newIndex Used internally by ParticleBatchNode 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 ParticleBatchNode 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 ParticleBatchNode 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 ( 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 ( int  index,
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 ( int  capacity)

resize the capacity of the TextureAtlas.

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

var resizeCapacity ( var  capacity)

resize the capacity of the TextureAtlas.

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

local resizeCapacity ( local  capacity)

resize the capacity of the TextureAtlas.

The new capacity can be lower or higher than the current one It returns true if the resize was successful. If it fails to resize the capacity it will return false 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

void setQuads ( V3F_C4B_T2F_Quad quads)

Sets the quads that are going to be rendered.

var setQuads ( var  quads)

Sets the quads that are going to be rendered.

local setQuads ( local  quads)

Sets the quads that are going to be rendered.

void setTexture ( Texture2D texture)

Sets the texture for the texture atlas.

var setTexture ( var  texture)

Sets the texture for the texture atlas.

local setTexture ( local  texture)

Sets the texture for the texture atlas.

void updateQuad ( V3F_C4B_T2F_Quad quad,
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

GLuint _buffersVBO[2]
protected
GLuint _buffersVBO[2]
protected
GLuint _buffersVBO[2]
protected
int _capacity
protected

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

var _capacity
protected

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

local _capacity
protected

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

bool _dirty
protected
var _dirty
protected
local _dirty
protected
GLushort* _indices
protected
var _indices
protected
local _indices
protected
V3F_C4B_T2F_Quad* _quads
protected

Quads that are going to be rendered.

var _quads
protected

Quads that are going to be rendered.

local _quads
protected

Quads that are going to be rendered.

Texture2D* _texture
protected

Texture of the texture atlas.

var _texture
protected

Texture of the texture atlas.

local _texture
protected

Texture of the texture atlas.

int _totalQuads
protected

quantity of quads that are going to be drawn

var _totalQuads
protected

quantity of quads that are going to be drawn

local _totalQuads
protected

quantity of quads that are going to be drawn


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