issue #2378: Setter/Getter for TextureAtlas, removing CC_PROPERTY_XXX macros.

This commit is contained in:
James Chen 2013-07-23 14:18:35 +08:00
parent 75a0cb6a29
commit d6f15bc79f
2 changed files with 30 additions and 14 deletions

View File

@ -81,7 +81,7 @@ int TextureAtlas::getCapacity() const
return _capacity;
}
Texture2D* TextureAtlas::getTexture()
Texture2D* TextureAtlas::getTexture() const
{
return _texture;
}
@ -100,22 +100,22 @@ V3F_C4B_T2F_Quad* TextureAtlas::getQuads()
return _quads;
}
void TextureAtlas::setQuads(V3F_C4B_T2F_Quad *var)
void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads)
{
_quads = var;
_quads = quads;
}
// TextureAtlas - alloc & init
TextureAtlas * TextureAtlas::create(const char* file, int capacity)
{
TextureAtlas * pTextureAtlas = new TextureAtlas();
if(pTextureAtlas && pTextureAtlas->initWithFile(file, capacity))
TextureAtlas * textureAtlas = new TextureAtlas();
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
{
pTextureAtlas->autorelease();
return pTextureAtlas;
textureAtlas->autorelease();
return textureAtlas;
}
CC_SAFE_DELETE(pTextureAtlas);
CC_SAFE_DELETE(textureAtlas);
return NULL;
}

View File

@ -187,6 +187,24 @@ public:
const char* description() const;
/** Gets the quantity of quads that are going to be drawn */
int getTotalQuads() const;
/** Gets the quantity of quads that can be stored with the current texture atlas size */
int getCapacity() const;
/** Gets the texture of the texture atlas */
Texture2D* getTexture() const;
/** Sets the texture for the texture atlas */
void setTexture(Texture2D* texture);
/** Gets the quads that are going to be rendered */
V3F_C4B_T2F_Quad* getQuads();
/** Sets the quads that are going to be rendered */
void setQuads(V3F_C4B_T2F_Quad* quads);
private:
void setupIndices();
void mapBuffers();
@ -203,16 +221,14 @@ protected:
#endif
GLuint _buffersVBO[2]; //0: vertex 1: indices
bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated
/** quantity of quads that are going to be drawn */
CC_PROPERTY_READONLY(int, _totalQuads, TotalQuads)
int _totalQuads;
/** quantity of quads that can be stored with the current texture atlas size */
CC_PROPERTY_READONLY(int, _capacity, Capacity)
int _capacity;
/** Texture of the texture atlas */
CC_PROPERTY(Texture2D *, _texture, Texture)
Texture2D* _texture;
/** Quads that are going to be rendered */
CC_PROPERTY(V3F_C4B_T2F_Quad *, _quads, Quads)
V3F_C4B_T2F_Quad* _quads;
};
// end of textures group