Skip to content

lonelydevil/Vulkan-Triangle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About this project

This is the C-implementation code of vulkan triangle based on vulkan-tutorial.com.

NOTE

An old, archived single-C-source-file version can be found here.

Why use C instead of C++?

Because some newcomers don't know C++ or STL. Implement the code with C will help them have a better understanding with the tutorial.

How many chapters this code had actually implemented?

From chapter 1 to chapter 16, you can view comments from the source code to see how they're implemented.

How to build it?

FOR WINDOWS USERS

You need to install VulkanSDK, mingw-w64(Optional but Recommended)(GNU C/C++ Compiler for Windows), CMake. Then download and extract GLFW prebuild library for windows (and move it under C:/ if possible).

Now fetch this source code through Git or Direct-Download.

Then you should read carefully through CMakeLists.txt and modify everything that suit your needs.

Then open the project folder press Shift + Right Click and select open in terminal, Type the following command(change argument with <> to what you want):


# using mingw-w64(Recommended)

cmake -G "MinGW Makefiles" -B <your-build-dir>

# using visual C++

cmake -G "Visual Studio 16 2019" -A x64 -B <your-build-dir>

cmake --build <your-build-dir> --target all -j<numbers-of-threads>

If you don't like typing command line, Double Click 'Windows_Build.bat' and it will automatically build inside a subdirectory named 'build'.

FOR LINUX USERS

You need to install a Desktop Environment, vulkan driver for your GPU, gcc, glslang, cmake and glfw, they should be included inside your package manager if you're using popular distro. If not, fetch their source code, build and install them manually.

Now fetch this source code through Git or Direct-Download.

Then read carefully through CMakeLists.txt, confirm that the path was absolutely correct.

Then open the terminal by pressing Ctrl + Alt + T to open the terminal(If your Desktop Environment doesn't support this shortcut, open it manually through application launcher), Type the following command:


cd <project-path>

cmake -B <your-build-dir>

cmake --build <your-build-dir> --target all -j<numbers-of-threads>

Where is the program after the build steps?

Open file manager(or use cd if you like typing command) and open your build folder, double click the program named 'vulkan-triangle', a colorful triangle with purple background will pop up.

NOTE FOR WINDOWS USERS

Everything is placed under <your-build-dir>/Debug if you build it with Visual C++.

How to change the color of The Background or The Triangle ?

BACKGROUND COLOR:

Search "VkClearValue" in Sources/vk_command.c, the four-floating-number-array after clear_val is the background color, represents "R", "G", "B" and "A", curretly only RGB value has effect.

TRIANGLE COLOR:

Search "vec3 colors" in Shaders/triangle.vert, there are three three-floating-number-array after that. It's the RGB value of three vertex colors of the triangle.

About

A good-scheuled C implementation of vulkan-tutorial.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages