Feature Request: Ability to add procedurally generated CCTexture2D's to CCTextureCache

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?

My simple thought ist that, cocos2d-x will keep the interfaces the same as cocos2d-iphone. At least, before 1.0.0-stable.

Good thought :slight_smile: I’ll bug the cocos2d-iphone guys instead :wink:

yep, that’s a good idea!