Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::View  (Read 1804 times)

0 Members and 1 Guest are viewing this topic.

CytraL

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • GitHub
sf::View
« 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...
dev@redneboa.es | WordPress | GitHub | YouTube

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::View
« Reply #1 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.
Laurent Gomila - SFML developer

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
sf::View
« Reply #2 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)

CytraL

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • GitHub
sf::View
« Reply #3 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??
dev@redneboa.es | WordPress | GitHub | YouTube