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

Author Topic: Won't Display Polygon  (Read 3468 times)

0 Members and 1 Guest are viewing this topic.

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Won't Display Polygon
« on: August 14, 2010, 11:13:35 am »
I'm trying to draw a polygon here, but the points I put in won't display.


Code: [Select]
#include <iostream>
#include <SFML/Graphics.hpp>


using namespace std;

int main()
{
    sf::RenderWindow App(sf::VideoMode::GetMode(0), "Laz's Interactive Map :: The Wrath... :: PvP Created");

    // Creates the PE map :: 7000x3000
    sf::Shape Map;
    Map.AddPoint(0,100,sf::Color(100,100,200));
    Map.AddPoint(100,100,sf::Color(100,100,200));
    Map.EnableFill(true);
    Map.EnableOutline(false);
    //Map.Rotate(45);
    //Map.Move(0,354);

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        float ElapsedTime = App.GetFrameTime();

        App.Clear();

        App.Draw(Map);

        App.Display();

    }



    return 0;
}
-Wander

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Won't Display Polygon
« Reply #1 on: August 14, 2010, 11:30:27 am »
Your "polygon" has two points, don't expect to see anything ;)
Laurent Gomila - SFML developer

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Won't Display Polygon
« Reply #2 on: August 15, 2010, 03:03:38 am »
Oh okay, well if you can't make it display lines like that, how can I make it display points? Like single dots.
-Wander

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Won't Display Polygon
« Reply #3 on: August 15, 2010, 04:21:45 am »
You'll have to make a rectangle or use sf::Shape::Line, I'm pretty sure that's a rectangle as well, just with a handy method for creating it.

If you want to draw individual pixels you may be better served by manipulating an image. Otherwise you'll just have to make really small polygons.

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Won't Display Polygon
« Reply #4 on: August 15, 2010, 04:22:35 am »
So there is not way to actually draw single points?
-Wander

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Won't Display Polygon
« Reply #5 on: August 15, 2010, 06:50:35 am »
I'm not entirely sure what you mean by single points. You should be able to make an sf::Shape the size of one pixel. If not, or if that's not suitable, you can play with individual pixels on an sf::Image (through LoadFromMemory and an array) that you use like a buffer that you draw to before actually drawing it to your window (with a sprite).

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Won't Display Polygon
« Reply #6 on: August 15, 2010, 06:52:47 am »
Oh okay. Thank you very much.
-Wander

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Won't Display Polygon
« Reply #7 on: August 17, 2010, 04:01:10 pm »
or a couple of if statements =)

if (points==1)
draw_rectangle of 1pixel
if (points==2)
draw a line
if (points>2)
draw polygon

 

anything