-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
85 lines (56 loc) · 1.72 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
74
75
76
77
78
79
80
81
82
83
84
85
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <iostream>
#include <GL/glew.h>
#include "VKDisplay.h"
#include "GLDisplay.h"
#include "Time.h"
#define TINYOBJLOADER_IMPLEMENTATION
#include <objloader\objloader.h>
#undef TINYOBJLOADER_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include <image/stb_image.h>
#undef STB_IMAGE_IMPLEMENTATION
#define WIDTH 800
#define HEIGHT 800
#define CLONE_COUNT 50
int main(int argc, char *argv[]) {
bool DO_VULKAN = true;
Time time;
unsigned int time_passed_as_micros = 0;
unsigned int seconds_passed = 0;
unsigned int frames_in_last_second = 0;
if ( ! DO_VULKAN ) {
GLDisplay displayGL( WIDTH, HEIGHT, "GL" );
while ( ! glfwWindowShouldClose( displayGL.getWindow() ) ) {
glfwPollEvents();
displayGL.updateUniformBuffer();
unsigned int delta_as_nanos = time.getDelta();
time_passed_as_micros += delta_as_nanos * 0.0001f;
if ( ( time_passed_as_micros / 100000 ) > seconds_passed + 1 ) {
std::cout << "FPS: " << frames_in_last_second << std::endl;
frames_in_last_second = 0;
seconds_passed++;
}
displayGL.drawFrame();
frames_in_last_second++;
}
} else {
VKDisplay displayVK( WIDTH, HEIGHT, "VK" );
while ( ! glfwWindowShouldClose( displayVK.getWindow() ) ) {
glfwPollEvents();
displayVK.updateUniformBuffer();
unsigned int delta_as_nanos = time.getDelta();
time_passed_as_micros += delta_as_nanos * 0.0001f;
if ( ( time_passed_as_micros / 100000 ) > seconds_passed + 1 ) {
std::cout << "FPS: " << frames_in_last_second << std::endl;
frames_in_last_second = 0;
seconds_passed++;
}
displayVK.drawFrame();
frames_in_last_second++;
}
vkDeviceWaitIdle( displayVK.device );
}
return 0;
}