Now that we have completed the prerequisites, let's draw a triangle:
- In source.cpp, include Camera.h and ObjectRenderer.h:
#define GLFW_INCLUDE_VULKAN #include<GLFW/glfw3.h> #include "VulkanContext.h" #include "Camera.h" #include "ObjectRenderer.h"
- In the main function, after initializing VulkanContext, create a new camera and an object to render, as follows:
int main() { glfwInit(); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); GLFWwindow* window = glfwCreateWindow(1280, 720,
"HELLO VULKAN ", nullptr, nullptr); VulkanContext::getInstance()->initVulkan(window); Camera camera; camera.init(45.0f, 1280.0f, 720.0f, 0.1f, 10000.0f); camera.setCameraPosition(glm::vec3(0.0f, 0.0f, 4.0f)); ...