Cocos2d-x  v3.11
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
TextureAtlas Class Reference

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

Inherits Ref.

Public Member Functions

bool initWithFile (const std::string &file, ssize_t capacity)
 Initializes a TextureAtlas with a filename and with a certain capacity for Quads. More...
 
local initWithFile ( local file, local capacity)
 Initializes a TextureAtlas with a filename and with a certain capacity for Quads. More...
 
bool initWithTexture (Texture2D *texture, ssize_t 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, ssize_t index)
 Updates a Quad (texture, vertex and color) at a certain index. More...
 
void insertQuad (V3F_C4B_T2F_Quad *quad, ssize_t index)
 Inserts a Quad (texture, vertex and color) at a certain index. More...
 
void insertQuads (V3F_C4B_T2F_Quad *quads, ssize_t index, ssize_t amount)
 Inserts a c array of quads at a given index. More...
 
local insertQuads ( local quads, local index, local amount)
 Inserts a c array of quads at a given index. More...
 
void insertQuadFromIndex (ssize_t fromIndex, ssize_t newIndex)
 Removes the quad that is located at a certain index and inserts it at a new index. More...
 
void removeQuadAtIndex (ssize_t index)
 Removes a quad at a given index number. More...
 
void removeQuadsAtIndex (ssize_t index, ssize_t amount)
 Removes a amount of quads starting from index. More...
 
void removeAllQuads ()
 Removes all Quads. More...
 
bool resizeCapacity (ssize_t capacity)
 Resize the capacity of the TextureAtlas. More...
 
void increaseTotalQuadsWith (ssize_t amount)
 Used internally by ParticleBatchNode. More...
 
void moveQuadsFromIndex (ssize_t oldIndex, ssize_t amount, ssize_t newIndex)
 Moves an amount of quads from oldIndex at newIndex. More...
 
void moveQuadsFromIndex (ssize_t index, ssize_t newIndex)
 Moves quads from index till totalQuads to the newIndex. More...
 
void fillWithEmptyQuadsFromIndex (ssize_t index, ssize_t amount)
 Ensures that after a realloc quads are still empty. More...
 
void drawNumberOfQuads (ssize_t n)
 Draws n quads. More...
 
void drawNumberOfQuads (ssize_t numberOfQuads, ssize_t start)
 Draws n quads from an index (offset). More...
 
void drawQuads ()
 Draws all the Atlas's Quads.
 
void listenRendererRecreated (EventCustom *event)
 Listen the event that renderer was recreated on Android.
 
bool isDirty (void)
 Whether or not the array buffer of the VBO needs to be updated. More...
 
var isDirty ()
 Whether or not the array buffer of the VBO needs to be updated. More...
 
local isDirty ()
 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...
 
virtual std::string getDescription () const
 Get the description of the object.
 
ssize_t getTotalQuads () const
 Gets the quantity of quads that are going to be drawn. More...
 
ssize_t 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...
 
local getTexture ()
 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 Ref
void retain ()
 Retains the ownership. More...
 
local retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor.
 

Static Public Member Functions

static TextureAtlascreate (const std::string &file, ssize_t capacity)
 Creates a TextureAtlas with an filename and with an initial capacity for Quads. More...
 
static TextureAtlascreateWithTexture (Texture2D *texture, ssize_t capacity)
 Creates a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for n Quads. More...
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 
bool _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 
local _scriptOwned
 The life of the object is scrolled by the scripting engine. 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 If you want to use TextureAtlas, you'd better setup GL status before it's rendered. Otherwise, the effect of TextureAtlas will be affected by the GL status of other nodes.

Member Function Documentation

static TextureAtlas* create ( const std::string &  file,
ssize_t  capacity 
)
static

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

The TextureAtlas capacity can be increased in runtime. The absolute/related path of file. Capacity for Quads. A TextureAtlas object.

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. The absolute/related path of file. Capacity for Quads. A TextureAtlas object.

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. The absolute/related path of file. Capacity for Quads. A TextureAtlas object.

static TextureAtlas*
createWithTexture
( Texture2D texture,
ssize_t  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. A texture2D object pointer. Capacity for Quads. A TextureAtlas object.

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. A texture2D object pointer. Capacity for Quads. A TextureAtlas object.

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. A texture2D object pointer. Capacity for Quads. A TextureAtlas object.

bool initWithFile ( const std::string &  file,
ssize_t  capacity 
)

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

The TextureAtlas capacity can be increased in runtime. Do not reinitialize the TextureAtlas because it will leak memory (issue #706). The absolute/related path of file. Capacity for Quads. If the initialization is successful, return true; else return false.

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. Do not reinitialize the TextureAtlas because it will leak memory (issue #706). The absolute/related path of file. Capacity for Quads. If the initialization is successful, return true; else return false.

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. Do not reinitialize the TextureAtlas because it will leak memory (issue #706). The absolute/related path of file. Capacity for Quads. If the initialization is successful, return true; else return false.

bool initWithTexture ( Texture2D texture,
ssize_t  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. Do not reinitialize the TextureAtlas because it will leak memory (issue #706). A texture2D object pointer. Capacity for Quads. If the initialization is successful, return true; else return false.

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. Do not reinitialize the TextureAtlas because it will leak memory (issue #706). A texture2D object pointer. Capacity for Quads. If the initialization is successful, return true; else return false.

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. Do not reinitialize the TextureAtlas because it will leak memory (issue #706). A texture2D object pointer. Capacity for Quads. If the initialization is successful, return true; else return false.

void updateQuad ( V3F_C4B_T2F_Quad quad,
ssize_t  index 
)

Updates a Quad (texture, vertex and color) at a certain index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1.

var updateQuad ( var  quad,
var  index 
)

Updates a Quad (texture, vertex and color) at a certain index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1.

local updateQuad ( local  quad,
local  index 
)

Updates a Quad (texture, vertex and color) at a certain index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1.

void insertQuad ( V3F_C4B_T2F_Quad quad,
ssize_t  index 
)

Inserts a Quad (texture, vertex and color) at a certain index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1.

var insertQuad ( var  quad,
var  index 
)

Inserts a Quad (texture, vertex and color) at a certain index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1.

local insertQuad ( local  quad,
local  index 
)

Inserts a Quad (texture, vertex and color) at a certain index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1.

void insertQuads ( V3F_C4B_T2F_Quad quads,
ssize_t  index,
ssize_t  amount 
)

Inserts a c array of quads at a given index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1. The quads array amount. This method doesn't enlarge the array when amount + index > totalQuads.

var insertQuads ( var  quads,
var  index,
var  amount 
)

Inserts a c array of quads at a given index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1. The quads array amount. This method doesn't enlarge the array when amount + index > totalQuads.

local insertQuads ( local  quads,
local  index,
local  amount 
)

Inserts a c array of quads at a given index.

Quad that are going to be rendered. Index must be between 0 and the atlas capacity - 1. The quads array amount. This method doesn't enlarge the array when amount + index > totalQuads.

void insertQuadFromIndex ( ssize_t  fromIndex,
ssize_t  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. The index where the quad is from. The index where the quad will be inserted.

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. The index where the quad is from. The index where the quad will be inserted.

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. The index where the quad is from. The index where the quad will be inserted.

void removeQuadAtIndex ( ssize_t  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. The index of the quad will be removed.

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. The index of the quad will be removed.

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. The index of the quad will be removed.

void removeQuadsAtIndex ( ssize_t  index,
ssize_t  amount 
)

Removes a amount of quads starting from index.

The start index of the quads will be removed. The amount of the quads will be removed.

var removeQuadsAtIndex ( var  index,
var  amount 
)

Removes a amount of quads starting from index.

The start index of the quads will be removed. The amount of the quads will be removed.

local removeQuadsAtIndex ( local  index,
local  amount 
)

Removes a amount of quads starting from index.

The start index of the quads will be removed. The amount of the quads will be removed.

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.

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.

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.

bool resizeCapacity ( ssize_t  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. Capacity for Quads. It returns true if the resize was successful; else return false.

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. Capacity for Quads. It returns true if the resize was successful; else return false.

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. Capacity for Quads. It returns true if the resize was successful; else return false.

void increaseTotalQuadsWith ( ssize_t  amount)

Used internally by ParticleBatchNode.

don't use this unless you know what you're doing.

var increaseTotalQuadsWith ( var  amount)

Used internally by ParticleBatchNode.

don't use this unless you know what you're doing.

local increaseTotalQuadsWith ( local  amount)

Used internally by ParticleBatchNode.

don't use this unless you know what you're doing.

void moveQuadsFromIndex ( ssize_t  oldIndex,
ssize_t  amount,
ssize_t  newIndex 
)

Moves an amount of quads from oldIndex at newIndex.

The current index of the quads will be moved from. The amount of the quads will be moved. The new index of the quads will be moved to.

var moveQuadsFromIndex ( var  oldIndex,
var  amount,
var  newIndex 
)

Moves an amount of quads from oldIndex at newIndex.

The current index of the quads will be moved from. The amount of the quads will be moved. The new index of the quads will be moved to.

local moveQuadsFromIndex ( local  oldIndex,
local  amount,
local  newIndex 
)

Moves an amount of quads from oldIndex at newIndex.

The current index of the quads will be moved from. The amount of the quads will be moved. The new index of the quads will be moved to.

void moveQuadsFromIndex ( ssize_t  index,
ssize_t  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. The current index of the quads will be moved from. The new index of the quads will be moved to.

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. The current index of the quads will be moved from. The new index of the quads will be moved to.

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. The current index of the quads will be moved from. The new index of the quads will be moved to.

void fillWithEmptyQuadsFromIndex ( ssize_t  index,
ssize_t  amount 
)

Ensures that after a realloc quads are still empty.

Used internally by ParticleBatchNode. The start index of the empty quads will be filled in. The amount of the quads will be filled.

var fillWithEmptyQuadsFromIndex ( var  index,
var  amount 
)

Ensures that after a realloc quads are still empty.

Used internally by ParticleBatchNode. The start index of the empty quads will be filled in. The amount of the quads will be filled.

local fillWithEmptyQuadsFromIndex ( local  index,
local  amount 
)

Ensures that after a realloc quads are still empty.

Used internally by ParticleBatchNode. The start index of the empty quads will be filled in. The amount of the quads will be filled.

void drawNumberOfQuads ( ssize_t  n)

Draws n quads.

n can't be greater than the capacity of the Atlas. The amount of the quads will be drawn.

var drawNumberOfQuads ( var  n)

Draws n quads.

n can't be greater than the capacity of the Atlas. The amount of the quads will be drawn.

local drawNumberOfQuads ( local  n)

Draws n quads.

n can't be greater than the capacity of the Atlas. The amount of the quads will be drawn.

void drawNumberOfQuads ( ssize_t  numberOfQuads,
ssize_t  start 
)

Draws n quads from an index (offset).

n + start can't be greater than the capacity of the atlas. The amount of the quads will be drawn. The start index of the quads will be drawn.

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. The amount of the quads will be drawn. The start index of the quads will be drawn.

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. The amount of the quads will be drawn. The start index of the quads will be drawn.

bool isDirty ( void  )
inline

Whether or not the array buffer of the VBO needs to be updated.

If need update return true; else return false.

var isDirty (   )
inline

Whether or not the array buffer of the VBO needs to be updated.

If need update return true; else return false.

local isDirty (   )
inline

Whether or not the array buffer of the VBO needs to be updated.

If need update return true; else return false.

void setDirty ( bool  bDirty)
inline

Specify if the array buffer of the VBO needs to be updated.

If it's need update, use true; else use false.

var setDirty ( var  bDirty)
inline

Specify if the array buffer of the VBO needs to be updated.

If it's need update, use true; else use false.

local setDirty ( local  bDirty)
inline

Specify if the array buffer of the VBO needs to be updated.

If it's need update, use true; else use false.

ssize_t getTotalQuads ( ) const

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

Return the amount of the quads.

var getTotalQuads ( )

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

Return the amount of the quads.

local getTotalQuads ( )

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

Return the amount of the quads.

ssize_t getCapacity ( ) const

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

Return the capacity of the quads.

var getCapacity ( )

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

Return the capacity of the quads.

local getCapacity ( )

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

Return the capacity of the quads.

Texture2D* getTexture ( ) const

Gets the texture of the texture atlas.

Return the texture object is using.

var getTexture ( )

Gets the texture of the texture atlas.

Return the texture object is using.

local getTexture ( )

Gets the texture of the texture atlas.

Return the texture object is using.

void setTexture ( Texture2D texture)

Sets the texture for the texture atlas.

The texture will be used.

var setTexture ( var  texture)

Sets the texture for the texture atlas.

The texture will be used.

local setTexture ( local  texture)

Sets the texture for the texture atlas.

The texture will be used.

V3F_C4B_T2F_Quad* getQuads ( )

Gets the quads that are going to be rendered.

The quads will be rendered.

var getQuads ( )

Gets the quads that are going to be rendered.

The quads will be rendered.

local getQuads ( )

Gets the quads that are going to be rendered.

The quads will be rendered.

void setQuads ( V3F_C4B_T2F_Quad quads)

Sets the quads that are going to be rendered.

The quads will be rendered.

var setQuads ( var  quads)

Sets the quads that are going to be rendered.

The quads will be rendered.

local setQuads ( local  quads)

Sets the quads that are going to be rendered.

The quads will be rendered.


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