SFML community forums
Help => Graphics => Topic started by: Wander 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.
#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;
}
-
Your "polygon" has two points, don't expect to see anything ;)
-
Oh okay, well if you can't make it display lines like that, how can I make it display points? Like single dots.
-
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.
-
So there is not way to actually draw single points?
-
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).
-
Oh okay. Thank you very much.
-
or a couple of if statements =)
if (points==1)
draw_rectangle of 1pixel
if (points==2)
draw a line
if (points>2)
draw polygon