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

Author Topic: Drawing sections of a vertex array  (Read 1946 times)

0 Members and 1 Guest are viewing this topic.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Drawing sections of a vertex array
« on: June 29, 2015, 10:38:45 am »
I'm making a graph drawing program where I'm using an sf::VertexArray to represent the graph itself. My problem comes from graphs such as y=asin(1/x). These graphs have a gap in the middle where the value of y is undefined. My problem is, how do I stop the vertex array from drawing specific vertices? Even with a circle equation, I'll have to stop it drawing the vertices before and after the circle so is there any way to do this?

Rhimlock

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Drawing sections of a vertex array
« Reply #1 on: June 29, 2015, 11:02:52 am »
You could just add 2 additional vertices with a transparent color in the gap.

Example:

Vertices  0 |  1 |  2 | 3 | 4 | 5
X-Coord -1 |  0 |  0 | 0 | 0 | 1
Y-Coord -1 | -1 | -1 | 1 | 1 | 1

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Drawing sections of a vertex array
« Reply #2 on: June 29, 2015, 11:27:29 am »
Won't that interpolate the colour so that the lines before the gap will fade out and the line after will fade in?

EDIT: I've just realised exactly what you meant and thank you that should do what I'm trying to do. If I put the transparent vertices in exactly the same position as the opaque ones, then there will be no fade out.
« Last Edit: June 29, 2015, 11:34:38 am by shadowmouse »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Drawing sections of a vertex array
« Reply #3 on: June 29, 2015, 07:34:38 pm »
It's also possible to use sf::Lines rather than sf::LinesStrip although the alpha trick can simplify things nicely.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything