Feature Request: support for drawing glow::POINTS and glow::LINES #310
-
Thanks for the great project. I was wondering if you have plans to add support for POINTS and LINES. This would be really helpful for building data visualization tools. For reference, kiss3d has examples of this. https://github.com/sebcrozet/kiss3d/blob/master/examples/lines.rs |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
Thanks for the kind words 🙏 Points and lines are actually already supported, just draw a sphere (or whatever shape you want) for each point and a cylinder (or whatever) for each line using a Also, it seems like kiss3d actually uses the legacy way of drawing points and lines, which might be what you're asking for. However, it is much better supported and much more flexible to draw a 3D object that resembles a point/line. It's always difficult to say something about performance since it very much depends on hardware, but it shouldn't be much slower to do it like this (might be faster on some hardware). What is important is to use |
Beta Was this translation helpful? Give feedback.
-
Makes sense. If I understand correctly, the key difference between the "legacy way" of drawing a line and simply representing it as a cylinder, is that a true line is scale-independent whereas a cylinder is not. No matter how much I zoom in or out, it's still a line with the same fixed width. This is because the width is defined in pixels, not an actual 3d geometry. Say you want to visualize a graph of connections between 3d points (which can be very close together or far apart, in an absolute sense) with an Does this use case make sense? I know lines and points might be "legacy" on some graphics backends, but we can perhaps let the backend-abstraction layer worry about that, and |
Beta Was this translation helpful? Give feedback.
-
Yeah, wanting fixed width lines makes a lot of sense. However, to me at least, that sounds like you want 2D lines, not 3D lines. My reasoning is that if you draw a line with fixed width, then you loose the third dimension, ie. you have no idea if a line is close or far away. So if I understand you correctly (please correct me if I'm wrong), you can use the And I agree, you shouldn't worry about what is legacy and what is not (I probably shouldn't have brought it up). So if you want 2D lines - which is exactly what is supported by legacy OpenGL - just use the |
Beta Was this translation helpful? Give feedback.
-
Added |
Beta Was this translation helpful? Give feedback.
-
This sees very reasonable; I'll try it out. Thanks for the response! |
Beta Was this translation helpful? Give feedback.
-
To add a 3D use-case to the original author, I am focusing on having a viewer for 3D geometries such as toolpath planning in a CAM software (computer-aided manufacturing). There it is quite common, to have scale-invariant 3D lines primitives which show the planned path of the tool processing a surface / part. As the number of lines in a toolpath is solely dependent on the curve approximation and number of tool passes, the line count may be huge (100.000+ lines is quite common), I could imagine that the 3D approach of rendering a cylinder for each line may bring additional costs and make the viewer quite laggy. I will investigate this.From the perspective of the software architecture of |
Beta Was this translation helpful? Give feedback.
Yeah, wanting fixed width lines makes a lot of sense. However, to me at least, that sounds like you want 2D lines, not 3D lines. My reasoning is that if you draw a line with fixed width, then you loose the third dimension, ie. you have no idea if a line is close or far away. So if I understand you correctly (please correct me if I'm wrong), you can use the
Line
struct for drawing 2D lines (se the shapes2D example). To find the end points of the line on the screen, you can use the uv_coordinates_at_position method on theCamera
to get the uv coordinates on the screen for a given 3D position. To go to a pixel position, just multiply the uv coordinates with the width/height of the viewport a…