Hacker News new | ask | show | jobs
by 29athrowaway 2040 days ago
Rendering a triangle in Vulkan will make you cry.
6 comments

With OpenGL you draw a triangle, and eventually write a pipeline.

With Vulkan you write a pipeline, and eventually draw a triangle.

Best explanation of the two APIs I've ever heard.

OpenGL "hello triangle" is short only if you cut corners. If you do it the way you'd do in a production app, you're not that far off from the lines of code it takes to do it in Vulkan. It's still less, but on the same order of magnitude.

OpenGL gives you a Toyota, Vulkan gives you the parts to a Ferrari
That's because Vulkan is designed to render millions of triangles, not one.

You wouldn't use Vulkan to render a single triangle for the same reasons why you wouldn't use a helicopter to get a bottle of milk from your local shop.

What's your point? So will writing your own custom UI toolkit, or manually doing your own font rendering, or implementing a custom equivalent to TensorFlow, or writing your own implementation of the C standard library, or ...

If you don't need low level control, you should be using middleware or a full blown engine (Godot, Unity, Unreal, etc).

Eh, it's an investment.

Debugging your first segfault will also make you cry, but it's good for you. It builds character, and prepares you for the more insidious segfaults that are lurking out in the tall grasses.

This is why you use a game/rendering framework/engine if you want to render a single triangle to play around.

This kind of "hardcore requirements to render a single triangle" is what is needed if you wish to have AAA game titles with realistic graphics at 60fps as it gives developers the freedom to do anything they wish.

More freedom -> better graphics at higher performance but more difficult to draw a single triangle.

Less freedom -> easier for beginners to draw a triangle but that is irrelevant in practice because that is not what those APIs are for.

wasn't that same joke made about OpenGL? plus ça change :)
OpenGL 1 was very straightforward, and if you want, you can still use it.

Recent version of OpenGL are more difficult. But compared to OpenGL, Vulkan is in an entirely different class of difficulty.

I wouldn't call it difficulty, or even complexity. Verbose is more apt.

It's daunting for a beginner but for a seasoned graphics programmer it is fairly straightforward. But still really verbose.

It's not straightforward even for seasoned graphics programmers. It's definitely easier for them because they have good grasp on advanced concepts such as barriers, image layouts, synchronization (things you don't really have to deal with in OpenGL/DX11 style APIs), but even they make hard to debug mistakes in AAA games/engines.
Plus ça reste pareil! Plus, it's not even that hard, and if you really find it that hard you can always use a wrapper library.