Class CCTextureAtlas

#include <Geode/cocos/textures/CCTextureAtlas.h>
classCCTextureAtlas:publiccocos2d::CCObject{ ... }

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

Examples0
Public static methods2
staticcocos2d::CCTextureAtlas*create(,
uintcapacity
)

creates a TextureAtlas with an filename and with an initial capacity for Quads. The TextureAtlas capacity can be increased in runtime.

staticcocos2d::CCTextureAtlas*createWithTexture(,
uintcapacity
)

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.

Public member functions27
virtualuintgetTotalQuads()

quantity of quads that are going to be drawn

virtualuintgetCapacity()

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

virtualcocos2d::CCTexture2D*getTexture()

Texture of the texture atlas

virtualvoidsetTexture()

Texture of the texture atlas

virtualcocos2d::ccV3F_C4B_T2F_Quad*getQuads()

Quads that are going to be rendered

virtualvoidsetQuads()

Quads that are going to be rendered

charconst*description()
No description provided
boolinitWithFile(,
uintcapacity
)

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)

boolinitWithTexture(,
uintcapacity
)

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)

voidupdateQuad(,
uintindex
)

Since v0.8

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

voidinsertQuad(,
uintindex
)

Since v0.8

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

voidinsertQuads(,
uintindex
,
uintamount
)

Since v1.1

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

voidinsertQuadFromIndex(
uintfromIndex
,
uintnewIndex
)

Since v0.7.2

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

voidremoveQuadAtIndex(
uintindex
)

Since v0.7.2

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

voidremoveQuadsAtIndex(
uintindex
,
uintamount
)

Since 1.1

removes a amount of quads starting from index

voidremoveAllQuads()

Since v0.7.2

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

boolresizeCapacity()

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.

voidincreaseTotalQuadsWith(
uintamount
)

Since 1.1

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

voidmoveQuadsFromIndex(
uintoldIndex
,
uintamount
,
uintnewIndex
)

Since v1.1

Moves an amount of quads from oldIndex at newIndex

voidmoveQuadsFromIndex(
uintindex
,
uintnewIndex
)

Since 1.1

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

voidfillWithEmptyQuadsFromIndex(
uintindex
,
uintamount
)

Since 1.1

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

voiddrawNumberOfQuads()

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

voiddrawNumberOfQuads(,
uintstart
)

Since v1.0

draws n quads from an index (offset). n + start can’t be greater than the capacity of the atlas

voiddrawQuads()

draws all the Atlas’s Quads

voidlistenBackToForeground()

listen the event that coming to foreground on Android

boolisDirty()

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

voidsetDirty(
boolbDirty
)

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

Fields0
Protected member functions0
Protected fields7
_::GLushort*m_pIndices
;
No description provided
GLuint[2]m_pBuffersVBO
;
No description provided
boolm_bDirty
;
No description provided
uintm_uTotalQuads
;

quantity of quads that are going to be drawn

uintm_uCapacity
;

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

;

Texture of the texture atlas

;

Quads that are going to be rendered