-
Notifications
You must be signed in to change notification settings - Fork 27
/
Ch00BaseCode.java
72 lines (45 loc) · 1.5 KB
/
Ch00BaseCode.java
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
package javavulkantutorial;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.system.MemoryUtil.NULL;
public class Ch00BaseCode {
private static class HelloTriangleApplication {
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
// ======= FIELDS ======= //
private long window;
// ======= METHODS ======= //
public void run() {
initWindow();
initVulkan();
mainLoop();
cleanup();
}
private void initWindow() {
if(!glfwInit()) {
throw new RuntimeException("Cannot initialize GLFW");
}
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
String title = getClass().getEnclosingClass().getSimpleName();
window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, NULL);
if(window == NULL) {
throw new RuntimeException("Cannot create window");
}
}
private void initVulkan() {
}
private void mainLoop() {
while(!glfwWindowShouldClose(window)) {
glfwPollEvents();
}
}
private void cleanup() {
glfwDestroyWindow(window);
glfwTerminate();
}
}
public static void main(String[] args) {
HelloTriangleApplication app = new HelloTriangleApplication();
app.run();
}
}