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

Author Topic: Drawing simple lines  (Read 6788 times)

0 Members and 1 Guest are viewing this topic.

Chocolatesheep

  • Newbie
  • *
  • Posts: 17
    • View Profile
Drawing simple lines
« on: July 25, 2012, 06:26:16 pm »
is there a simple way to draw lines/paths with SFML. Let's say I wanted to move the mouse around the window and make it leave a trail. I tried using vertecies and vertex arrays, but they always seem to connect the first and last point  creating a convex shape. The same, of course happens with sf::ConvexShape. So is there a simple way of doing this or should I move on and think of a different way using rectangles and directional quotients.
With vertexes drawing them using sf::LineStrip.
Sorry if I sound nooby, or ignorant.
Thanks in advance

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11028
    • View Profile
    • development blog
    • Email
Re: Drawing simple lines
« Reply #1 on: July 25, 2012, 06:52:26 pm »
Have you taken a look at the documentation, specially the part about sf::PrimitiveType?

Quote
Lines    List of individual lines.
LinesStrip    List of connected lines, a point uses the previous point to form a line.

Just switch them out and you get individual lines. There's no simpler and easier solution than this in SFML. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Chocolatesheep

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Drawing simple lines
« Reply #2 on: July 25, 2012, 07:05:17 pm »
Quote
Just switch them out and you get individual lines
I tried that, but it seems to create a dotted line instead of a continuous one.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11028
    • View Profile
    • development blog
    • Email
Re: Drawing simple lines
« Reply #3 on: July 25, 2012, 07:28:57 pm »
You actually want to use sf::LineStrip (connecting all lines = trail) and using the example in the docs does exactly that! If the beginning and end point get connected on your end then it's a problem in your mouse capture/vertex creating code. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Chocolatesheep

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Drawing simple lines
« Reply #4 on: July 25, 2012, 07:49:48 pm »
Quote
If the beginning and end point get connected on your end then it's a problem in your mouse capture/vertex creating code.

Just tried the code given in the documentation. I guess I have an error in my code. I will look through it right now. Thanks for your help ;D

 

anything