TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Drawing Lines is Hard (2015)

109 pointsby lebekover 8 years ago

7 comments

dahartover 8 years ago
Drawing lines in OpenGL &amp; 3d hardware in general has always had some of these issues. The best support for GL&#x2F;OpenGL line drawing I knew of was in the more expensive SGI machines. (Capitalized on purpose to indicate before they rebranded lowercase -- but this is fuzzy memory and I&#x27;m no sgi history expert.) The cheaper ones&#x27; lines definitely weren&#x27;t as good, but SGIs did have pretty nice line support back in the day, better than what you get in WebGL today.<p>One thing I didn&#x27;t see mentioned here is the line drawing API calls are typically not as well optimized as the triangle mesh calls, or so I&#x27;ve heard. Part of the reason good line drawing support was more expensive was (allegedly) only a few customers truly need antialiased lines with performance as good as the mesh API, and it&#x27;s extra silicon, lines have specific needs not shared with meshes.<p>FWIW, I&#x27;ve tried all these approaches in production and ended up just doing the meshing myself, and avoiding shader tricks. It&#x27;s not that bad, it gives the most control, and once you have an abstraction for it, you don&#x27;t need to think about it again.
评论 #13673783 未加载
Kenjiover 8 years ago
It&#x27;s pretty much impossible to draw pixel-perfect lines in OpenGL. Even the library code of SDL2 fails to do it in certain instances, when its 2D drawing functions use OpenGL - and SDL2 is super clean and solid like a rock. Sometimes, you&#x27;re even better off using images (!!) to draw lines. The sad thing is that Bresenham&#x27;s line algorithm is so very simple. Somewhere between my program and the GPU, the communication of where exactly the line starts and ends is lost.
teddyhover 8 years ago
I thought this would be about Bresenham&#x27;s line algorithm and its drawbacks.
评论 #13673461 未加载
评论 #13671562 未加载
评论 #13673292 未加载
评论 #13671508 未加载
paulddraperover 8 years ago
You can force MSAA in WebGL by using a larger canvas, and then downsizing it via CSS.<p>Not sure the performance implications, but I use this frequently if MSAA is not natively supported.
ghurtadoover 8 years ago
A while back I made this prompted by a question in Stack Overflow: <a href="http:&#x2F;&#x2F;codepen.io&#x2F;garciahurtado&#x2F;pen&#x2F;AGEsf" rel="nofollow">http:&#x2F;&#x2F;codepen.io&#x2F;garciahurtado&#x2F;pen&#x2F;AGEsf</a><p>It is a less refined version of the techniques in the article, the approach is different in that it uses post-processing to provide the line thickness.
mcpherrinmover 8 years ago
I&#x27;m really glad to see this. I attempted to draw lines when first learning OpenGL and wasn&#x27;t able to get results like I wanted.
gensover 8 years ago
Xorg seems to agree.
评论 #13675895 未加载