Hacker News new | ask | show | jobs
by segfaultbuserr 907 days ago
> It wasn’t just that we’d managed to get a triangle onto the screen. That could be done in about a day. It was the journey the triangle had taken to get up on the screen.

If anyone wants to experience something like that today, just follow an introductory tutorial on Vulkan programming. Vulkan is a programming model that gives so much low-level control directly to programmers. As a result, this "Hello Triangle" example became (in)famous for its need to implement a skeleton of a full 3D engine in thousands of lines of code before you can render a triangle on the screen.

https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Base_co...

3 comments

If you RTA, that’s a perfect example of drawing a black triangle versus “A Black Triangle Moment”.

That tutorial is a general overview of all the possible boilerplate you would expect to see in a template project, and just happens to end in a triangle being drawn on the screen.

You could skip a lot of those steps. Is that 5 page section on constructing validation layers and fine tuning the debugger really necessary if your end goal was a triangle?

You can draw a triangle in Metal in thousands of lines of code too. And it’s common to have several hundred lines of pipeline descriptors, buffer management, and debug tooling before you even started encoding into your shaders. But it’s not necessary for _just a triangle_.

That tutorial sets up a complete rendering system, and demonstrates that it works by drawing a triangle... the exact thing described in the black triangle story.

Drawing a triangle is not the end goal. That's nonsense.

Yeah we’re saying the same thing. It’s not a “Hello Triangle” tutorial.
It kind of sounds like we're saying opposite things.

You're talking about the minimum necessary for just drawing a triangle, as if that's what "hello triangle" means. That's nothing. That's pointless.

The construction of hello triangle program marks the end of setup, and the beginning of actual work.

Skipping parts because they're boilerplate, or don't directly serve to draw the triangle, defeats the purpose. That's like typing the words "hello world" into notepad because it's faster than setting up an IDE.

The first OpenGL tutorial from 30 years ago was called “Hello Triangle”. It was uselessly simple, just like the iconic “Hello World”.

The point is that the tutorial is not in the same spirit as the classic Hellos. You can draw a triangle without all that scaffolding.

(New to comment thread) The article is about setting up all the core infrastructure to start bringing content into the engine, validated by the triangle.

Even tho the Vulkan tutorial might seem like work, it’s not actually preparing you to build anything significant on top of it. This just an overview of the API, not much of a building block.

I think both sides have a point, it's just a matter of perspective. One person's "drawing a black triangle" can be another's "black triangle moment". It's turtles all the way down.

From the perspective of an experienced Vulkan programmer, it's only a basic tutorial on creating an empty stub project, which is useless in itself as the real work of creating a powerful 3D engine has yet to start. But from the perspective of a new graphics programmer without any prior Vulkan knowledge, creating a stub project capable of drawing a triangle is already an accomplishment in itself. In OpenGL, the same thing is possible in 50 lines of code, compared to a stub Vulkan project that explicitly defines every component using thousands lines of code. Upon finishing it, one would finally have an understanding of how every part comes together, which enables further development. It would be then possible to draw many different kinds of object on top of this stub framework. In this sense, it fits the definition of:

> accomplishments that take a lot of effort to achieve, but upon completion you don’t have much to show for it only that more work can now proceed.

It's fun to see the evolution in e.g. these examples of image loading for Dear Imgui:

https://github.com/ocornut/imgui/wiki/Image-Loading-and-Disp...

DirectX9 will even load the image for you, DirectX11 okay we get a few more structures to fill out, DirectX12 is where it goes off the rails and we are filling out a bunch of UNKNOWN DONT_CARE JUST_DO_IT. Then of course Vulkan is the one that gets the big fat "this probably won't actually work for you" warning.

I understand whats happening, but you know sometimes I just want to display a fucking image.

Thanks for sharing this, I was thoroughly tickled. The optimistic tone of the tutorial stands in stark contrast of the convoluted path to drawing an object.