-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
73 lines (52 loc) · 1.58 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#define STB_IMAGE_IMPLEMENTATION
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <stdexcept>
#include <vector>
#include <iostream>
#include "VulkanRenderer.h"
GLFWwindow * window;
VulkanRenderer vulkanRenderer;
void initWindow(std::string wName = "Test Window", const int width = 800, const int height = 600)
{
// Initialise GLFW
glfwInit();
// Set GLFW to NOT work with OpenGL
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
window = glfwCreateWindow(width, height, wName.c_str(), nullptr, nullptr);
}
int main()
{
// Create Window
initWindow("Test Window", 1366, 768);
// Create Vulkan Renderer instance
if (vulkanRenderer.init(window) == EXIT_FAILURE)
{
return EXIT_FAILURE;
}
float angle = 0.0f;
float deltaTime = 0.0f;
float lastTime = 0.0f;
int modelListPosition = vulkanRenderer.createMeshModel("Models/13463_Australian_Cattle_Dog_v3.obj");
// Loop until closed
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
float now = glfwGetTime();
deltaTime = now - lastTime;
lastTime = now;
angle += 10.0f * deltaTime;
if (angle > 360.0f) { angle -= 360.0f; }
glm::mat4 testMat = glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
testMat = glm::rotate(testMat, glm::radians(angle * 5.0f), glm::vec3(0.0f, 0.0f, 1.0f));
vulkanRenderer.updateModel(modelListPosition, testMat);
vulkanRenderer.draw();
}
vulkanRenderer.cleanup();
// Destroy GLFW window and stop GLFW
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}