I’m using a bunch of procedural textures in my game. These textures are generated on the fly and re-used in many areas of the game, that’s why I generate them in a global location (to save both on memory and processing time) and get the texture from CCTextureCache wherever I need any of them.
But my procedural texture generation methods aren’t working with CCImage (it generates CCTexture2D’s) and CCTextureCache doesn’t let one add CCTexture2D’s directly. That’s why I’ve locally added the following method to CCTextureCache:
void CCTextureCache::addTexture(CCTexture2D* texture, const char* textureKeyName) {
CCAssert(texture != NULL, "Texture argument must not be NULL");
m_pDictLock->lock();
m_pTextures->setObject(texture, textureKeyName);
m_pDictLock->unlock();
}
Do you think it would be worthwhile to add this feature to the official Cocos2d-x code as well?