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
Class CCTextureAtlas
#include <Geode/cocos/textures/CCTextureAtlas.h>
Examples0
Public static methods2
staticcocos2d::CCTextureAtlas*create(charconst*file,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(cocos2d::CCTexture2D*texture,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()
boolinitWithFile(charconst*file,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(cocos2d::CCTexture2D*texture,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)
updates a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1
voidinsertQuad(,uintindex)
Inserts a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1
voidinsertQuads(,uintindex,uintamount)
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)
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)
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
voidremoveAllQuads()
removes all Quads. The TextureAtlas capacity remains untouched. No memory is freed. The total number of quads to be drawn will be 0
boolresizeCapacity(uintn)
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)
Used internally by CCParticleBatchNode don’t use this unless you know what you’re doing
voidmoveQuadsFromIndex(uintoldIndex,uintamount,uintnewIndex)
Moves an amount of quads from oldIndex at newIndex
voidmoveQuadsFromIndex(uintindex,uintnewIndex)
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)
Ensures that after a realloc quads are still empty Used internally by CCParticleBatchNode
voiddrawNumberOfQuads(uintn,uintstart)
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
Fields0
Protected member functions0
Protected fields7
_::GLushort*m_pIndices;
GLuint[2]m_pBuffersVBO;
boolm_bDirty;
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
cocos2d::CCTexture2D*m_pTexture;
Texture of the texture atlas
cocos2d::ccV3F_C4B_T2F_Quad*m_pQuads;
Quads that are going to be rendered