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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - senhor

Pages: [1]
1
General / Re: How Can I limit what to draw
« on: October 26, 2013, 10:04:21 pm »
I think lag is all about drawing the map for now. I will change my code with vertex arrays as soon as possible and will tell you the result. Thanks for your helps.

2
General / Re: How Can I limit what to draw
« on: October 25, 2013, 03:41:16 pm »
thanks for your advice Ghosa but that problem still isn't solved  :(

3
General / How Can I limit what to draw
« on: October 23, 2013, 06:11:20 pm »
I am working on a RTS game and game gets laggy with big maps so I need to limit which parts of map to draw.
I want to draw only visible part of map so I coded like that:

 
void Node::draw( sf::RenderWindow& window )
{
    sf::Vector2f  node_position_in_coords;
    sf::View      view = window.getView();
    sf::Rect<float> rt;

    rt.left = view.getCenter().x - view.getSize().x/2.f;
    rt.top  = view.getCenter().y - view.getSize().y/2.f;
    rt.width  = view.getSize().x;
    rt.height = view.getSize().y;

    node_position_in_coords = window.mapPixelToCoords( sf::Vector2i( _x, _y) );

    if( rt.contains( node_position_in_coords ) )
        window.draw( _s_tile );
}
 

But it only draws a specific part of map.

Pages: [1]
anything