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

Author Topic: Stipple Pattern  (Read 4007 times)

0 Members and 1 Guest are viewing this topic.

xfixium

  • Newbie
  • *
  • Posts: 4
    • View Profile
Stipple Pattern
« on: May 19, 2014, 11:36:05 pm »
Hello everyone! First off, I have recently switched from my home brew implementation of OpenGL to SFML. I just retrofitted a c# application I have been working on for some time with SFML libraries. (https://gmare.codeplex.com/) I must admit, everything went very smoothly in the transition, plus it runs much faster, which is awesome.

More to the point. My map application draws lines that use a stipple pattern. I use the stipple pattern for a "marching ants" selection rectangle and for the grid lines on the designer. I was wondering if this feature could somehow be implemented?

I have done a search, but found nothing on this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Stipple Pattern
« Reply #1 on: May 19, 2014, 11:43:02 pm »
This feature sounds very specific and not like something that must be part of the core library.

I have not used stipple patterns before, but isn't it possible to create the resulting curve using the existing API? Have you researched how this is usually implemented?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

xfixium

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Stipple Pattern
« Reply #2 on: May 20, 2014, 12:38:12 am »
The way I implemented it prior was just to use glEnable(GLOption.LineStipple). This was through a c# OpenGL wrapper I used. So basically using OpenGL's built-in functionality. However, after reading through some things on the internet just now, it seems it has been depreciated since OpenGL3.1.  :-\

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Stipple Pattern
« Reply #3 on: May 20, 2014, 12:48:19 am »
If I understand stippling correctly, you can replicate the effect by making several smaller lines or applying a texture to a single line.  https://stackoverflow.com/questions/1937444/drawing-stippled-lines-using-opengl-es seems to go into a bit more detail.  Either way it'll be far more flexible than the old line stippling.

xfixium

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Stipple Pattern
« Reply #4 on: May 20, 2014, 02:41:03 am »
Thank you for the suggestion, but I fail to see how it's more flexible. If anything, the methods described are more involved. The cool thing about the stipple pattern is all you have to do is assign some bits that represented the stipple pattern (Which is customizable to whatever you like). Which meant you could animate it as well by shifting the bits on a timer. Draw a solid white line or rectangle underneath, and bam, Marching ants selection style.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Stipple Pattern
« Reply #5 on: May 20, 2014, 07:56:42 am »
Being more involved is not the opposite of being more flexible.  In any good API, the complex approach is always the more flexible one.

With more modern methods you could easily do everything you just described along with segments that smoothly fade out or are partially transparent or have different colors or fuzzy edges and all sorts of other things.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10916
    • View Profile
    • development blog
    • Email
Re: Stipple Pattern
« Reply #6 on: May 20, 2014, 09:11:03 am »
The cool thing about the stipple pattern is all you have to do is assign some bits that represented the stipple pattern (Which is customizable to whatever you like). Which meant you could animate it as well by shifting the bits on a timer. Draw a solid white line or rectangle underneath, and bam, Marching ants selection style.
I can't test things right now, but this sounds exactly what has been said in the SO answer above.

Use a sf::VertexArray and set the texture coordinates to a specific texture with a stripe pattern and then draw the line and pass the texture.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

xfixium

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Stipple Pattern
« Reply #7 on: May 20, 2014, 03:48:16 pm »
I don't need an answer. ;) The texture route was always an obvious option, this is not my first rodeo. This is a feature request, which I'm guessing will never happen because of its non-existence in ES, and the depreciation of it in OpenGL. But I thank you anyway.

I believe there has been some talk about clipping rectangle, that would be a good feature as well. At least from an application stand point, not so much a game engine one.

 

anything