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

Author Topic: how do i draw lines/polygons?  (Read 3838 times)

0 Members and 1 Guest are viewing this topic.

Assassinbeast

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
    • Email
how do i draw lines/polygons?
« 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

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: how do i draw lines/polygons?
« Reply #1 on: December 10, 2012, 11:49:50 pm »
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.
Back to C++ gamedev with SFML in May 2023

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Assassinbeast

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
    • Email
Re: how do i draw lines/polygons?
« Reply #3 on: December 11, 2012, 12:13:31 am »
Thanks alot man.
Just what i needed :)

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: how do i draw lines/polygons?
« Reply #4 on: December 11, 2012, 12:23:06 am »
Quote
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.
Back to C++ gamedev with SFML in May 2023

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: how do i draw lines/polygons?
« Reply #5 on: December 11, 2012, 01:13:13 am »
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

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.
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: how do i draw lines/polygons?
« Reply #6 on: December 11, 2012, 04:14:54 pm »
I just knew you'd come and say that. ;D
So why didn't you write it directly? :P
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything