SFML community forums
Help => Graphics => Topic started by: Assassinbeast on December 10, 2012, 11:47:48 pm
-
Hey folks :)
How do i draw all kinds of primitives?
I know circleshape and rectangleshape, that was pretty easy,
but cant seem to figure out how to draw lines and polygons
ive looked at the documentation but i cant figure it out,
and also the 1.6 tutorials... but it doesnt work the same as 2.0 :(
I will be grateful for any help you guys can provide :D
-
sf::ConvexShape for convex shapes
sf::Vertex or sf::VertexArray for 1 pixel wide lines
For concave shapes and wide lines you'll have to write or find some other code.
-
concave shapes
thor::ConcaveShape (http://www.bromeon.ch/libraries/thor/v2.0/doc/classthor_1_1_concave_shape.html)
wide lines
sf::RectangleShape (http://www.sfml-dev.org/documentation/2.0/classsf_1_1RectangleShape.php)
-
Thanks alot man.
Just what i needed :)
-
thor::ConcaveShape
I just knew you'd come and say that. ;D
Rectangles let you draw only vertical or horizontal lines though, unless you do the math and rotate it properly but then it's easier to write own, proper line class. :P
There is round ended line class floating on wiki or forum somewhere too I think.
-
If you want to go further by knowing how thor's concave shapes work or eventually implement a bold line or something similar yourself you can check this topic:
http://en.sfml-dev.org/forums/index.php?topic=9902.0 (http://en.sfml-dev.org/forums/index.php?topic=9902.0)
I gave a small explanation of how to do it, requires a lot of math and all, but it's good to have that knowledge around.
-
I just knew you'd come and say that. ;D
So why didn't you write it directly? :P