SFML community forums

Help => Graphics => Topic started by: CytraL on August 31, 2010, 07:06:06 pm

Title: sf::View
Post by: CytraL on August 31, 2010, 07:06:06 pm
If using sf:: View draws only what you see on screen automatically? or need make a function for control this...
Title: sf::View
Post by: Laurent on August 31, 2010, 07:54:54 pm
It draws everything, so if you need a performances boost you can manually exclude what is outside the screen.
Title: sf::View
Post by: Spidyy on August 31, 2010, 07:55:22 pm
It will draw whether it is inside or outside the view. You need to make a control for this. (if not inside the view then no draw)
Title: sf::View
Post by: CytraL on August 31, 2010, 08:13:59 pm
ok... thx ;)


Code: [Select]

void CMap::drawLayer(int nlayer)
{
    sf::FloatRect vrect = engine.camera.GetRect();
    INFO_LAYER *layer = &layers[nlayer];

    int gX, gY;
    for(std::size_t i=0; i<layer->map.size(); ++i)
    {
        if (layer->map[i]->gid > 0)
        {
            gX = i;
            gY = int(i/info_map.w);
            if (gX > info_map.w)
                gX-=info_map.w*gY;

            if ((gX*64+32 >= vrect.Left && gX*64-32 <= vrect.Right) && (gY*64+32 >= vrect.Top && gY*64-32 <= vrect.Bottom))
                engine.screen.Draw(layer->map[i]->sprt_tile);
        }
    }
}


----------------------------------

Other question... How i can make sf::shape with alpha??