Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17109

Why DrawNode outside of screen increase GL calls?

$
0
0

@CrazyHappyGame wrote:

Why DrawNode outside of screen increase GL calls?
For below code I have “GL calls:1000” but only 7 draw node are on screen.

    float step = 100;
    for (int i = 0; i < 1000; ++i)
    {
        auto posXY = static_cast<float>(i);
        auto s1 = cocos2d::DrawNode::create();
        s1->drawDot({}, 1, cocos2d::Color4F::BLACK);
        s1->setPosition(cocos2d::Vec2{posXY, posXY} * step);
        auto s = s1->getContentSize();
        layer->addChild(s1);
    }

For the same code with Sprite everything works as expected “GL calls:14” (only 14 Sprite are drawn rest are outside of screen)

    float step = 100;
    for (int i = 0; i < 1000; ++i)
    {
        auto posXY = static_cast<float>(i) * step;
        auto s1 = cocos2d::Sprite::create("arrow.png");
        s1->setPosition(cocos2d::Vec2{posXY, posXY});
        layer->addChild(s1);
        // second sprite to break batching
        auto s2 = cocos2d::Sprite::create("back_button.png");
        s2->setPosition(cocos2d::Vec2{posXY, posXY});
        layer->addChild(s2);
    }

Regards,
Chp

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 17109

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>