MCPcopy Create free account
hub / github.com/JetBrains/skija / loop

Method loop

examples/lwjgl/src/Main.java:147–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

145 }
146
147 private void loop() {
148 GL.createCapabilities();
149 if ("false".equals(System.getProperty("skija.staticLoad")))
150 Library.load();
151 context = DirectContext.makeGL();
152
153 GLFW.glfwSetWindowSizeCallback(window, (window, width, height) -> {
154 updateDimensions();
155 initSkia();
156 draw();
157 });
158
159 glfwSetCursorPosCallback(window, (window, xpos, ypos) -> {
160 if(os.contains("mac") || os.contains("darwin")) {
161 this.xpos = (int) xpos;
162 this.ypos = (int) ypos;
163 } else {
164 this.xpos = (int) (xpos / dpi);
165 this.ypos = (int) (ypos / dpi);
166 }
167 });
168
169 glfwSetMouseButtonCallback(window, (window, button, action, mods) -> {
170 // System.out.println("Button " + button + " " + (action == 0 ? "released" : "pressed"));
171 });
172
173 glfwSetScrollCallback(window, (window, xoffset, yoffset) -> {
174 Scenes.currentScene().onScroll((float) xoffset * dpi, (float) yoffset * dpi);
175 });
176
177 glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
178 if (action == GLFW_PRESS) {
179 switch (key) {
180 case GLFW_KEY_LEFT:
181 Scenes.prevScene();
182 break;
183 case GLFW_KEY_RIGHT:
184 Scenes.nextScene();
185 break;
186 case GLFW_KEY_UP:
187 Scenes.currentScene().changeVariant(-1);
188 break;
189 case GLFW_KEY_DOWN:
190 Scenes.currentScene().changeVariant(1);
191 break;
192 case GLFW_KEY_V:
193 vsync = !vsync;
194 glfwSwapInterval(vsync ? 1 : 0);
195 HUD.extras.set(0, new Pair("V", "VSync: " + (vsync ? "ON" : "OFF")));
196 break;
197 case GLFW_KEY_S:
198 Scenes.stats = !Scenes.stats;
199 Stats.enabled = Scenes.stats;
200 break;
201 case GLFW_KEY_G:
202 System.out.println("Before GC " + Stats.allocated);
203 System.gc();
204 break;

Callers 1

runMethod · 0.95

Calls 14

loadMethod · 0.95
makeGLMethod · 0.95
updateDimensionsMethod · 0.95
initSkiaMethod · 0.95
drawMethod · 0.95
currentSceneMethod · 0.95
prevSceneMethod · 0.95
nextSceneMethod · 0.95
getPropertyMethod · 0.80
setMethod · 0.80
equalsMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected