Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A little bit off topic but: GL_LINES doesn't have a performant analog on lots of other platforms, even Unity. Drawing a line properly requires turning the two endpoint vertices into a quad and optionally adding endcaps which are at least triangular but can be polygons. From my understanding, that requires a geometry shader since we're adding virtual/implicit vertices. Does anyone know if mesh shaders could accomplish the same thing?

Also I wish that GL_LINES was open-sourced for other platforms. Maybe it is in the OpenGL spec and I just haven't looked. I've attempted some other techniques like having the fragment shader draw a border around each triangle, but they all have their drawbacks.



To draw lines instead of a geometry shader you can use instancing, since you know how many vertices you need to represent a line segment's bounding box. Have one vertex buffer that just contains N vertices (the actual attribute data doesn't matter, but you can shove UVs or index values in there) and bind it alongside a buffer containing your actual line information (start, end, color, etc). The driver+GPU will replicate the 'line vertex buffer' vertices for every instance in the 'line instance buffer' that you bound.

This works for most other regular shapes too, like a relatively tight bounding box for circles if you're drawing a bunch of them.


In my experience, drawing quads with GL_POINTS in OpenGL was way faster than drawing quads with instancing in DirectX. That was noticable with the DirectX vs. OpenGL backends for WebGL, where switching between the two resulted in widely different performance.


drawing using GL_LINES is old school fixed function pipeline and it's how modern graphics hardware works. If you want a single line, draw a small rectangle between V1 and V2 using geometry. The thickness is the distance between P1 and P2 / P3 and P4 of the rectangle. A line has no thickness as it's 1 dimensional.

Draw in screen space based on projected points in world space.

set gl_Color to your desired color vec and bam, line.


hundredrabbits' game Verreciel uses a reimplementation of webgl-lines, to pretty good effect, if I may say so:

https://github.com/mattdesl/webgl-lines

https://hundredrabbits.itch.io/verreciel

PS— I still play Retro, and dream of resuscitating it :)


Ah cool, thanks for that!

Oh man, that was about 3 lifetimes ago. I'm on linkedin (every couple months hah) if you ever want to chat.

It was a fun project, but we released it just in time for the Dot Bomb to wipe us out. Our last month, my partner and I got about $600 each from shareware game sales ($1200 with inflation today), enough to pay rent and my student loans for the first time. After the pop, the next month we got one sale. $12. The fun was over and never came back in the same way.

The powers that be conspired to end the 90s climb towards FU money and UBI, and there was no tech investment for about 6-7 years until 2007 when the iPhone and Facebook came out, which started the mobile bubble. Lots of people made $100k those first years, but mostly not established players, who had too much time, effort and money sunk into the old desktop platforms.

Then Google and Facebook took the lion's share of ad money, which removed the avenues to scale a business. Everyone moved into other models like in-game ads, in-app purchases and going viral through influencers, but none of those worked for the vast majority. To leave us where we are today, where long tail effects ensure a winner-take-all sales distribution.

Now that AI is here, even apps will begin disappearing. I predict that within 3 years, nobody will be using the web or buying software anymore. We'll just ask the AI to do everything, and it will make it so. Thus ends the mobile bubble too.

I basically missed every bubble due to unfortunate life choices. So let this be a cautionary tale to any young people who read this. You need to do the opposite of what people say. Nobody gets rich pulling themselves up by their bootstraps, they get rich by borrowing someone else's money and investing it in sure things like Bitcoin 15 years ago. If you feel yourself clinging to a project or situation because you have a lot invested in it or don't want to let someone down, that's the time to explore other options. You won't make yourself poor - your empathy will. That's why the rich demonize it. But empathy is where the true meaning in life is found. You can choose to skim money off other people's backs through investment, or "earn" it yourself, but there is a karmic cost no matter how you obtain it. So just have fun and do your best and at least pay your taxes so that society can progress forward, or we'll never stop repeating these systems of control and suffering IMHO.

When I was making Retro, I was trying to capture the feeling of the golden age of arcade video games, even if I maybe missed the mark. But I didn't realize that I was in a golden age at the time. I believe that we're in one of those now, maybe the last one. But also the first one, from a certain perspective.

Maybe it's time to dust off the old compiler and make a game..


I'm not sure exactly what you mean, but you can both output line primitives directly from the mesh shader or output mitered/capped extruded lines via triangles.

As far as other platforms, there's VK_EXT_line_rasterization which is a port of opengl line drawing functionality to vulkan.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: