コード例 #1
0
void BillboardParticleSystem::end()
{
    _endCommand.init(_globalZOrder);
    _endCommand.func = CC_CALLBACK_0(BillboardParticleSystem::onEnd, this);

    Director* director = Director::getInstance();
    CCASSERT(nullptr != director, "Director is null when seting matrix stack");
    Renderer *renderer = director->getRenderer();
    renderer->addCommand(&_endCommand);

}
コード例 #2
0
ファイル: CCRenderTexture.cpp プロジェクト: 2276225819/Game
void RenderTexture::end()
{
    _endCommand.init(_globalZOrder);
    _endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this);

    Director* director = Director::getInstance();
    CCASSERT(nullptr != director, "Director is null when seting matrix stack");
    
    Renderer *renderer = director->getRenderer();
    renderer->addCommand(&_endCommand);
    renderer->popGroup();
    
    director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
    director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);

}
コード例 #3
0
ファイル: TextureManager.cpp プロジェクト: 289/DouPo
void TextureManager::clear() {
    Director *director = Director::getInstance();
    auto glView = director->getOpenGLView();
    auto renderer = director->getRenderer();

    long long start = currentTimeMillis();
    CCLOG("texMgr clear texModuleCount=%d", texModuleMap.size());
    renderer->render();
    CCLOG("render before success");

    int textureCosts[TEXTURE_COUNT] = {0};

    int curLoopCounter = Director::loopCounter;

    for(auto& entry : texModuleMap) {
        auto tm = entry.second;

        for(int i = 0; i < TEXTURE_COUNT; ++i) {
            if(textures[i] == tm->tex) {
                textureCosts[i] += (tm->lastCallCounter - curLoopCounter) * tm->width * tm->height;
                break;
            }
        }
    }

    int min = INT_MAX;
    int index = -1;

    for(int i = 0; i < TEXTURE_COUNT; ++i) {
        CCLOG("textureCosts[%d]=%d", i, textureCosts[i]);

        if(min > textureCosts[i]) {
            min = textureCosts[i];
            index = i;
        }
    }

    int length = TEXTURE_SIZE * TEXTURE_SIZE << 2;
    byte *data = new byte[length];
    memset(data, 0, length);
    textures[index]->initWithData(data, length, Texture2D::PixelFormat::RGBA8888, TEXTURE_SIZE, TEXTURE_SIZE, Size(TEXTURE_SIZE, TEXTURE_SIZE));
    textureBins[index]->init(TEXTURE_SIZE, TEXTURE_SIZE);

    std::vector<int> toDeletes;

    for(auto& entry : texModuleMap) {
        auto tm = entry.second;

        if(tm->tex == textures[index]) {
            CC_SAFE_DELETE(tm);
            toDeletes.push_back(entry.first);
        }
    }

    for(auto id : toDeletes) {
        texModuleMap.erase(id);
    }

	toDeletes.clear();

	for (auto& entry : texCoordCalculatedMap) {
		auto tex = entry.second;
		if (tex == textures[index]) {
			toDeletes.push_back(entry.first);
		}
	}

	for (auto id : toDeletes) {
		texCoordCalculatedMap.erase(id);
	}

    CC_SAFE_DELETE_ARRAY(data);
    CCLOG("after texMgr clear texModuleCount=%d, clearTexId=%d, recalculate count %d, cost Time=%lld", texModuleMap.size(), index, toDeletes.size(), currentTimeMillis() - start);
}