0

In OpenGLES or Metal, I render something to the screen using vertex/fragment shaders. But immediately after fragment shader is done I need to pass few vertices and draw polylines connecting those vertices. How do I do this? In other words, is it possible to chain output of shaders and basic OpenGL commands that draws polygons? I could in principal draw the lines by implementing additional logic in the fragment shader and it will involve lot of calculation and if-then-else, which I think is not very clean approach.

BDL
  • 21,052
  • 22
  • 49
  • 55
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
  • You can just issue additional draw commands. Those can draw lines instead of triangles, or whatever. As Rabbid76 says, you *may* need different shaders if the ones you use for the earlier drawing aren't also appropriate for the lines. – Ken Thomases May 21 '18 at 14:33
  • What is the best way to generate an image like this in fragment shader - https://en.wikipedia.org/wiki/Vectorscope#/media/File:Vectorscope_graticule.png – Deepak Sharma May 21 '18 at 20:06
  • That question is too broad for SO. You don't typically "generate" an image like that in a fragment shader. You could use that image itself as a texture or you could draw all of the individual elements as lines or, for the text, quads (made up of triangles). In any case, that's how to proceed: break the desired result down into its individual components and draw each. For repeated elements like the ticks around the circumference, you could use instanced line drawing. Etc. – Ken Thomases May 22 '18 at 14:11

0 Answers0