MCPcopy Create free account
hub / github.com/HumbleUI/Skija / initWindow

Method initWindow

examples/vulkan/src/Main.java:70–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68 }
69
70 private static void initWindow() {
71 if (System.getenv("WAYLAND_DISPLAY") != null) {
72 glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
73 }
74 if (!glfwInit()) throw new IllegalStateException("Unable to initialize GLFW");
75 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
76 glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
77 glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
78 window = glfwCreateWindow(width, height, "Skija Vulkan Example", NULL, NULL);
79
80 glfwSetWindowSizeCallback(window, (window, w, h) -> {
81 updateDimensions();
82 recreateSwapchain();
83 });
84
85 glfwSetCursorPosCallback(window, (window, x, y) -> {
86 xpos = (int) (x / dpi);
87 ypos = (int) (y / dpi);
88 });
89
90 glfwSetScrollCallback(window, (window, xoffset, yoffset) -> {
91 Scenes.currentScene().onScroll((float) xoffset * dpi, (float) yoffset * dpi);
92 });
93
94 glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
95 if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE)
96 glfwSetWindowShouldClose(window, true);
97 if (action == GLFW_PRESS) {
98 switch (key) {
99 case GLFW_KEY_LEFT:
100 Scenes.prevScene();
101 break;
102 case GLFW_KEY_RIGHT:
103 Scenes.nextScene();
104 break;
105 case GLFW_KEY_UP:
106 Scenes.currentScene().changeVariant(-1);
107 break;
108 case GLFW_KEY_DOWN:
109 Scenes.currentScene().changeVariant(1);
110 break;
111 case GLFW_KEY_S:
112 Scenes.stats = !Scenes.stats;
113 break;
114 case GLFW_KEY_G:
115 System.gc();
116 break;
117 }
118 }
119 });
120
121 updateDimensions();
122 glfwShowWindow(window);
123 }
124
125 private static void updateDimensions() {
126 try (MemoryStack stack = MemoryStack.stackPush()) {

Callers 1

mainMethod · 0.95

Calls 7

updateDimensionsMethod · 0.95
recreateSwapchainMethod · 0.95
currentSceneMethod · 0.95
prevSceneMethod · 0.95
nextSceneMethod · 0.95
onScrollMethod · 0.45
changeVariantMethod · 0.45

Tested by

no test coverage detected