Introduction

Drawing our first triangle is the Hello World of Vulkan.

Linuxviewer comes with an example application that opens a window with a size of 400x400 and draws a triangle in it. Hello_triangle is made up of the following files:

  • HelloTriangle.cxx, HelloTriangle.h: The application definition. HelloTriangle.cxx contains
    int main(int argc, char* argv[]) and initialization that is required for every linuxviewer application. HelloTriangle.h defines the application class and contains more configuration by overriding a few virtual functions.

  • Window.cxx, Window.h: The window definition. Together these define almost everything related to the Vulkan rendering; after all, the triangle that we want to draw has to appear inside this window. We could have another window with something else, so the “triangle” is not really related to the Application.

  • LogicalDevice.h: The definition of the logical device. The required Vulkan features and queues are specified here, again by overriding virtual functions of the base class.

  • TrianglePipelineCharacteristic.h: Most of the pipeline configuration. The class TrianglePipelineCharacteristic specifies a characteristic of the pipeline. It is passed to a pipeline factory that then creates the actual pipeline. Since we only have one characteristic in this case I should say it specifies all characteristic.

Note:

Each window in linuxviewer has its own target surface, swapchain and render loop. Windows can run at different FPS, even when one window is a child window of another. For example, one can create an input field that runs at 60 FPS while the rest of the window runs at 4 FPS, still maintaining a smooth input experience.

In the next chapter we’ll go over the source code of each file and add an explanation of the code.