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

Author Topic: Drawing lines in sfml.  (Read 14358 times)

0 Members and 1 Guest are viewing this topic.

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Drawing lines in sfml.
« on: April 10, 2012, 02:44:49 pm »
Hello,

Can someone please explain me how to draw lines? I guess it can be done by creating a 1 px high rectangleshape and rotating it but is there a clena solution for this? I *thought* the was a Line class in SFML but I can't seem to find it.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11045
    • View Profile
    • development blog
    • Email
Re: Drawing lines in sfml.
« Reply #1 on: April 10, 2012, 02:48:38 pm »
You know there's a search function for this forum (and every other forum you'll ever visit). ;)

Since you're talking about rectangleshape I suppose you're using SFML 2, which is already a good thing.
A line can be done simply with to vertices (sf::Vertex) and a vertex array (sf::VertexArray).
As primitve type you can choose sf::Lines.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
Re: Drawing lines in sfml.
« Reply #2 on: April 11, 2012, 08:01:36 am »
I *thought* the was a Line class in SFML but I can't seem to find it.
The line class was removed; since it didn't do anything that a rotated rectangle couldn't do anyway.

Jamin Grey

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Of Stranger Flames
Re: Drawing lines in sfml.
« Reply #3 on: August 02, 2013, 03:08:04 am »
Just incase someone doesn't realize thePyro_13 is joking, the old (SFML 1.6) removed function was called:
sf::Shape::Line and drew a single line slowly.

The new method (SFML 2.x), using sf::VertexArray, as eXpl0it3r mentioned, draws many lines at once (a much faster way to draw, if you're drawing more than one line).
« Last Edit: August 02, 2013, 03:41:50 am by Jamin Grey »
Of Stranger Flames - My work-in-progress para-historical (and classically-inspired) 2D rpg.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11045
    • View Profile
    • development blog
    • Email
Re: Drawing lines in sfml.
« Reply #4 on: August 02, 2013, 04:48:30 am »
Nice nekroing there... ;D

And no thePyro_13 was not joking. There is not line class in SFML 2.x anymore. The use of vertex array does not equal as a class, so the answer is correct. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything