ScrapExplorer - events.c

Home / ext / glfw / tests Lines: 39 | Size: 22629 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1//======================================================================== 2// Event linter (event spewer) 3// Copyright (c) Camilla Löwy <[email protected]> 4// 5// This software is provided 'as-is', without any express or implied 6// warranty. In no event will the authors be held liable for any damages 7// arising from the use of this software. 8// 9// Permission is granted to anyone to use this software for any purpose, 10// including commercial applications, and to alter it and redistribute it 11// freely, subject to the following restrictions: 12// 13// 1. The origin of this software must not be misrepresented; you must not 14// claim that you wrote the original software. If you use this software 15// in a product, an acknowledgment in the product documentation would 16// be appreciated but is not required. 17// 18// 2. Altered source versions must be plainly marked as such, and must not 19// be misrepresented as being the original software. 20// 21// 3. This notice may not be removed or altered from any source 22// distribution. 23// 24//======================================================================== 25// 26// This test hooks every available callback and outputs their arguments 27// 28// Log messages go to stdout, error messages to stderr 29// 30// Every event also gets a (sequential) number to aid discussion of logs 31// 32//======================================================================== 33 34#define GLAD_GL_IMPLEMENTATION 35#include <glad/gl.h> 36#define GLFW_INCLUDE_NONE 37#include <GLFW/glfw3.h> 38 39#include <stdio.h> 40#include <stdlib.h> 41#include <ctype.h> 42#include <string.h> 43#include <locale.h> 44 45#include "getopt.h" 46 47// Event index 48static unsigned int counter = 0; 49 50typedef struct 51{ 52 GLFWwindow* window; 53 int number; 54 int closeable; 55} Slot; 56 57static void usage(void) 58{ 59 printf("Usage: events [-f] [-h] [-n WINDOWS]\n"); 60 printf("Options:\n"); 61 printf(" -f use full screen\n"); 62 printf(" -h show this help\n"); 63 printf(" -n the number of windows to create\n"); 64} 65 66static const char* get_key_name(int key) 67{ 68 switch (key) 69 { 70 // Printable keys 71 case GLFW_KEY_A: return "A"; 72 case GLFW_KEY_B: return "B"; 73 case GLFW_KEY_C: return "C"; 74 case GLFW_KEY_D: return "D"; 75 case GLFW_KEY_E: return "E"; 76 case GLFW_KEY_F: return "F"; 77 case GLFW_KEY_G: return "G"; 78 case GLFW_KEY_H: return "H"; 79 case GLFW_KEY_I: return "I"; 80 case GLFW_KEY_J: return "J"; 81 case GLFW_KEY_K: return "K"; 82 case GLFW_KEY_L: return "L"; 83 case GLFW_KEY_M: return "M"; 84 case GLFW_KEY_N: return "N"; 85 case GLFW_KEY_O: return "O"; 86 case GLFW_KEY_P: return "P"; 87 case GLFW_KEY_Q: return "Q"; 88 case GLFW_KEY_R: return "R"; 89 case GLFW_KEY_S: return "S"; 90 case GLFW_KEY_T: return "T"; 91 case GLFW_KEY_U: return "U"; 92 case GLFW_KEY_V: return "V"; 93 case GLFW_KEY_W: return "W"; 94 case GLFW_KEY_X: return "X"; 95 case GLFW_KEY_Y: return "Y"; 96 case GLFW_KEY_Z: return "Z"; 97 case GLFW_KEY_1: return "1"; 98 case GLFW_KEY_2: return "2"; 99 case GLFW_KEY_3: return "3"; 100 case GLFW_KEY_4: return "4"; 101 case GLFW_KEY_5: return "5"; 102 case GLFW_KEY_6: return "6"; 103 case GLFW_KEY_7: return "7"; 104 case GLFW_KEY_8: return "8"; 105 case GLFW_KEY_9: return "9"; 106 case GLFW_KEY_0: return "0"; 107 case GLFW_KEY_SPACE: return "SPACE"; 108 case GLFW_KEY_MINUS: return "MINUS"; 109 case GLFW_KEY_EQUAL: return "EQUAL"; 110 case GLFW_KEY_LEFT_BRACKET: return "LEFT BRACKET"; 111 case GLFW_KEY_RIGHT_BRACKET: return "RIGHT BRACKET"; 112 case GLFW_KEY_BACKSLASH: return "BACKSLASH"; 113 case GLFW_KEY_SEMICOLON: return "SEMICOLON"; 114 case GLFW_KEY_APOSTROPHE: return "APOSTROPHE"; 115 case GLFW_KEY_GRAVE_ACCENT: return "GRAVE ACCENT"; 116 case GLFW_KEY_COMMA: return "COMMA"; 117 case GLFW_KEY_PERIOD: return "PERIOD"; 118 case GLFW_KEY_SLASH: return "SLASH"; 119 case GLFW_KEY_WORLD_1: return "WORLD 1"; 120 case GLFW_KEY_WORLD_2: return "WORLD 2"; 121 122 // Function keys 123 case GLFW_KEY_ESCAPE: return "ESCAPE"; 124 case GLFW_KEY_F1: return "F1"; 125 case GLFW_KEY_F2: return "F2"; 126 case GLFW_KEY_F3: return "F3"; 127 case GLFW_KEY_F4: return "F4"; 128 case GLFW_KEY_F5: return "F5"; 129 case GLFW_KEY_F6: return "F6"; 130 case GLFW_KEY_F7: return "F7"; 131 case GLFW_KEY_F8: return "F8"; 132 case GLFW_KEY_F9: return "F9"; 133 case GLFW_KEY_F10: return "F10"; 134 case GLFW_KEY_F11: return "F11"; 135 case GLFW_KEY_F12: return "F12"; 136 case GLFW_KEY_F13: return "F13"; 137 case GLFW_KEY_F14: return "F14"; 138 case GLFW_KEY_F15: return "F15"; 139 case GLFW_KEY_F16: return "F16"; 140 case GLFW_KEY_F17: return "F17"; 141 case GLFW_KEY_F18: return "F18"; 142 case GLFW_KEY_F19: return "F19"; 143 case GLFW_KEY_F20: return "F20"; 144 case GLFW_KEY_F21: return "F21"; 145 case GLFW_KEY_F22: return "F22"; 146 case GLFW_KEY_F23: return "F23"; 147 case GLFW_KEY_F24: return "F24"; 148 case GLFW_KEY_F25: return "F25"; 149 case GLFW_KEY_UP: return "UP"; 150 case GLFW_KEY_DOWN: return "DOWN"; 151 case GLFW_KEY_LEFT: return "LEFT"; 152 case GLFW_KEY_RIGHT: return "RIGHT"; 153 case GLFW_KEY_LEFT_SHIFT: return "LEFT SHIFT"; 154 case GLFW_KEY_RIGHT_SHIFT: return "RIGHT SHIFT"; 155 case GLFW_KEY_LEFT_CONTROL: return "LEFT CONTROL"; 156 case GLFW_KEY_RIGHT_CONTROL: return "RIGHT CONTROL"; 157 case GLFW_KEY_LEFT_ALT: return "LEFT ALT"; 158 case GLFW_KEY_RIGHT_ALT: return "RIGHT ALT"; 159 case GLFW_KEY_TAB: return "TAB"; 160 case GLFW_KEY_ENTER: return "ENTER"; 161 case GLFW_KEY_BACKSPACE: return "BACKSPACE"; 162 case GLFW_KEY_INSERT: return "INSERT"; 163 case GLFW_KEY_DELETE: return "DELETE"; 164 case GLFW_KEY_PAGE_UP: return "PAGE UP"; 165 case GLFW_KEY_PAGE_DOWN: return "PAGE DOWN"; 166 case GLFW_KEY_HOME: return "HOME"; 167 case GLFW_KEY_END: return "END"; 168 case GLFW_KEY_KP_0: return "KEYPAD 0"; 169 case GLFW_KEY_KP_1: return "KEYPAD 1"; 170 case GLFW_KEY_KP_2: return "KEYPAD 2"; 171 case GLFW_KEY_KP_3: return "KEYPAD 3"; 172 case GLFW_KEY_KP_4: return "KEYPAD 4"; 173 case GLFW_KEY_KP_5: return "KEYPAD 5"; 174 case GLFW_KEY_KP_6: return "KEYPAD 6"; 175 case GLFW_KEY_KP_7: return "KEYPAD 7"; 176 case GLFW_KEY_KP_8: return "KEYPAD 8"; 177 case GLFW_KEY_KP_9: return "KEYPAD 9"; 178 case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE"; 179 case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTIPLY"; 180 case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT"; 181 case GLFW_KEY_KP_ADD: return "KEYPAD ADD"; 182 case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL"; 183 case GLFW_KEY_KP_EQUAL: return "KEYPAD EQUAL"; 184 case GLFW_KEY_KP_ENTER: return "KEYPAD ENTER"; 185 case GLFW_KEY_PRINT_SCREEN: return "PRINT SCREEN"; 186 case GLFW_KEY_NUM_LOCK: return "NUM LOCK"; 187 case GLFW_KEY_CAPS_LOCK: return "CAPS LOCK"; 188 case GLFW_KEY_SCROLL_LOCK: return "SCROLL LOCK"; 189 case GLFW_KEY_PAUSE: return "PAUSE"; 190 case GLFW_KEY_LEFT_SUPER: return "LEFT SUPER"; 191 case GLFW_KEY_RIGHT_SUPER: return "RIGHT SUPER"; 192 case GLFW_KEY_MENU: return "MENU"; 193 194 default: return "UNKNOWN"; 195 } 196} 197 198static const char* get_action_name(int action) 199{ 200 switch (action) 201 { 202 case GLFW_PRESS: 203 return "pressed"; 204 case GLFW_RELEASE: 205 return "released"; 206 case GLFW_REPEAT: 207 return "repeated"; 208 } 209 210 return "caused unknown action"; 211} 212 213static const char* get_button_name(int button) 214{ 215 switch (button) 216 { 217 case GLFW_MOUSE_BUTTON_LEFT: 218 return "left"; 219 case GLFW_MOUSE_BUTTON_RIGHT: 220 return "right"; 221 case GLFW_MOUSE_BUTTON_MIDDLE: 222 return "middle"; 223 default: 224 { 225 static char name[16]; 226 snprintf(name, sizeof(name), "%i", button); 227 return name; 228 } 229 } 230} 231 232static const char* get_mods_name(int mods) 233{ 234 static char name[512]; 235 236 if (mods == 0) 237 return " no mods"; 238 239 name[0] = '\0'; 240 241 if (mods & GLFW_MOD_SHIFT) 242 strcat(name, " shift"); 243 if (mods & GLFW_MOD_CONTROL) 244 strcat(name, " control"); 245 if (mods & GLFW_MOD_ALT) 246 strcat(name, " alt"); 247 if (mods & GLFW_MOD_SUPER) 248 strcat(name, " super"); 249 if (mods & GLFW_MOD_CAPS_LOCK) 250 strcat(name, " capslock-on"); 251 if (mods & GLFW_MOD_NUM_LOCK) 252 strcat(name, " numlock-on"); 253 254 return name; 255} 256 257static size_t encode_utf8(char* s, unsigned int ch) 258{ 259 size_t count = 0; 260 261 if (ch < 0x80) 262 s[count++] = (char) ch; 263 else if (ch < 0x800) 264 { 265 s[count++] = (ch >> 6) | 0xc0; 266 s[count++] = (ch & 0x3f) | 0x80; 267 } 268 else if (ch < 0x10000) 269 { 270 s[count++] = (ch >> 12) | 0xe0; 271 s[count++] = ((ch >> 6) & 0x3f) | 0x80; 272 s[count++] = (ch & 0x3f) | 0x80; 273 } 274 else if (ch < 0x110000) 275 { 276 s[count++] = (ch >> 18) | 0xf0; 277 s[count++] = ((ch >> 12) & 0x3f) | 0x80; 278 s[count++] = ((ch >> 6) & 0x3f) | 0x80; 279 s[count++] = (ch & 0x3f) | 0x80; 280 } 281 282 return count; 283} 284 285static void error_callback(int error, const char* description) 286{ 287 fprintf(stderr, "Error: %s\n", description); 288} 289 290static void window_pos_callback(GLFWwindow* window, int x, int y) 291{ 292 Slot* slot = glfwGetWindowUserPointer(window); 293 printf("%08x to %i at %0.3f: Window position: %i %i\n", 294 counter++, slot->number, glfwGetTime(), x, y); 295} 296 297static void window_size_callback(GLFWwindow* window, int width, int height) 298{ 299 Slot* slot = glfwGetWindowUserPointer(window); 300 printf("%08x to %i at %0.3f: Window size: %i %i\n", 301 counter++, slot->number, glfwGetTime(), width, height); 302} 303 304static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 305{ 306 Slot* slot = glfwGetWindowUserPointer(window); 307 printf("%08x to %i at %0.3f: Framebuffer size: %i %i\n", 308 counter++, slot->number, glfwGetTime(), width, height); 309} 310 311static void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale) 312{ 313 Slot* slot = glfwGetWindowUserPointer(window); 314 printf("%08x to %i at %0.3f: Window content scale: %0.3f %0.3f\n", 315 counter++, slot->number, glfwGetTime(), xscale, yscale); 316} 317 318static void window_close_callback(GLFWwindow* window) 319{ 320 Slot* slot = glfwGetWindowUserPointer(window); 321 printf("%08x to %i at %0.3f: Window close\n", 322 counter++, slot->number, glfwGetTime()); 323 324 if (!slot->closeable) 325 { 326 printf("(( closing is disabled, press %s to re-enable )\n", 327 glfwGetKeyName(GLFW_KEY_C, 0)); 328 } 329 330 glfwSetWindowShouldClose(window, slot->closeable); 331} 332 333static void window_refresh_callback(GLFWwindow* window) 334{ 335 Slot* slot = glfwGetWindowUserPointer(window); 336 printf("%08x to %i at %0.3f: Window refresh\n", 337 counter++, slot->number, glfwGetTime()); 338 339 glfwMakeContextCurrent(window); 340 glClear(GL_COLOR_BUFFER_BIT); 341 glfwSwapBuffers(window); 342} 343 344static void window_focus_callback(GLFWwindow* window, int focused) 345{ 346 Slot* slot = glfwGetWindowUserPointer(window); 347 printf("%08x to %i at %0.3f: Window %s\n", 348 counter++, slot->number, glfwGetTime(), 349 focused ? "focused" : "defocused"); 350} 351 352static void window_iconify_callback(GLFWwindow* window, int iconified) 353{ 354 Slot* slot = glfwGetWindowUserPointer(window); 355 printf("%08x to %i at %0.3f: Window was %s\n", 356 counter++, slot->number, glfwGetTime(), 357 iconified ? "iconified" : "uniconified"); 358} 359 360static void window_maximize_callback(GLFWwindow* window, int maximized) 361{ 362 Slot* slot = glfwGetWindowUserPointer(window); 363 printf("%08x to %i at %0.3f: Window was %s\n", 364 counter++, slot->number, glfwGetTime(), 365 maximized ? "maximized" : "unmaximized"); 366} 367 368static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) 369{ 370 Slot* slot = glfwGetWindowUserPointer(window); 371 printf("%08x to %i at %0.3f: Mouse button %i (%s) (with%s) was %s\n", 372 counter++, slot->number, glfwGetTime(), button, 373 get_button_name(button), 374 get_mods_name(mods), 375 get_action_name(action)); 376} 377 378static void cursor_position_callback(GLFWwindow* window, double x, double y) 379{ 380 Slot* slot = glfwGetWindowUserPointer(window); 381 printf("%08x to %i at %0.3f: Cursor position: %f %f\n", 382 counter++, slot->number, glfwGetTime(), x, y); 383} 384 385static void cursor_enter_callback(GLFWwindow* window, int entered) 386{ 387 Slot* slot = glfwGetWindowUserPointer(window); 388 printf("%08x to %i at %0.3f: Cursor %s window\n", 389 counter++, slot->number, glfwGetTime(), 390 entered ? "entered" : "left"); 391} 392 393static void scroll_callback(GLFWwindow* window, double x, double y) 394{ 395 Slot* slot = glfwGetWindowUserPointer(window); 396 printf("%08x to %i at %0.3f: Scroll: %0.3f %0.3f\n", 397 counter++, slot->number, glfwGetTime(), x, y); 398} 399 400static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 401{ 402 Slot* slot = glfwGetWindowUserPointer(window); 403 404 if (key == GLFW_KEY_UNKNOWN) 405 { 406 printf("%08x to %i at %0.3f: Key (%s) Scancode 0x%04x (with%s) was %s\n", 407 counter++, slot->number, glfwGetTime(), 408 get_key_name(key), scancode, 409 get_mods_name(mods), 410 get_action_name(action)); 411 } 412 else 413 { 414 const char* name = glfwGetKeyName(key, scancode); 415 if (name) 416 { 417 printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x Name %s (with%s) was %s\n", 418 counter++, slot->number, glfwGetTime(), 419 key, get_key_name(key), scancode, name, 420 get_mods_name(mods), 421 get_action_name(action)); 422 } 423 else 424 { 425 printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x (with%s) was %s\n", 426 counter++, slot->number, glfwGetTime(), 427 key, get_key_name(key), scancode, 428 get_mods_name(mods), 429 get_action_name(action)); 430 } 431 } 432 433 if (action != GLFW_PRESS) 434 return; 435 436 switch (key) 437 { 438 case GLFW_KEY_C: 439 { 440 slot->closeable = !slot->closeable; 441 442 printf("(( closing %s ))\n", slot->closeable ? "enabled" : "disabled"); 443 break; 444 } 445 446 case GLFW_KEY_L: 447 { 448 const int state = glfwGetInputMode(window, GLFW_LOCK_KEY_MODS); 449 glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, !state); 450 451 printf("(( lock key mods %s ))\n", !state ? "enabled" : "disabled"); 452 break; 453 } 454 } 455} 456 457static void char_callback(GLFWwindow* window, unsigned int codepoint) 458{ 459 Slot* slot = glfwGetWindowUserPointer(window); 460 char string[5] = ""; 461 462 encode_utf8(string, codepoint); 463 printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n", 464 counter++, slot->number, glfwGetTime(), codepoint, string); 465} 466 467static void drop_callback(GLFWwindow* window, int count, const char* paths[]) 468{ 469 int i; 470 Slot* slot = glfwGetWindowUserPointer(window); 471 472 printf("%08x to %i at %0.3f: Drop input\n", 473 counter++, slot->number, glfwGetTime()); 474 475 for (i = 0; i < count; i++) 476 printf(" %i: \"%s\"\n", i, paths[i]); 477} 478 479static void monitor_callback(GLFWmonitor* monitor, int event) 480{ 481 if (event == GLFW_CONNECTED) 482 { 483 int x, y, widthMM, heightMM; 484 const GLFWvidmode* mode = glfwGetVideoMode(monitor); 485 486 glfwGetMonitorPos(monitor, &x, &y); 487 glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); 488 489 printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n", 490 counter++, 491 glfwGetTime(), 492 glfwGetMonitorName(monitor), 493 mode->width, mode->height, 494 x, y, 495 widthMM, heightMM); 496 } 497 else if (event == GLFW_DISCONNECTED) 498 { 499 printf("%08x at %0.3f: Monitor %s was disconnected\n", 500 counter++, 501 glfwGetTime(), 502 glfwGetMonitorName(monitor)); 503 } 504} 505 506static void joystick_callback(int jid, int event) 507{ 508 if (event == GLFW_CONNECTED) 509 { 510 int axisCount, buttonCount, hatCount; 511 512 glfwGetJoystickAxes(jid, &axisCount); 513 glfwGetJoystickButtons(jid, &buttonCount); 514 glfwGetJoystickHats(jid, &hatCount); 515 516 printf("%08x at %0.3f: Joystick %i (%s) was connected with %i axes, %i buttons, and %i hats\n", 517 counter++, glfwGetTime(), 518 jid, 519 glfwGetJoystickName(jid), 520 axisCount, 521 buttonCount, 522 hatCount); 523 524 if (glfwJoystickIsGamepad(jid)) 525 { 526 printf(" Joystick %i (%s) has a gamepad mapping (%s)\n", 527 jid, 528 glfwGetJoystickGUID(jid), 529 glfwGetGamepadName(jid)); 530 } 531 else 532 { 533 printf(" Joystick %i (%s) has no gamepad mapping\n", 534 jid, 535 glfwGetJoystickGUID(jid)); 536 } 537 } 538 else 539 { 540 printf("%08x at %0.3f: Joystick %i was disconnected\n", 541 counter++, glfwGetTime(), jid); 542 } 543} 544 545int main(int argc, char** argv) 546{ 547 Slot* slots; 548 GLFWmonitor* monitor = NULL; 549 int ch, i, width, height, count = 1; 550 551 glfwSetErrorCallback(error_callback); 552 553 if (!glfwInit()) 554 exit(EXIT_FAILURE); 555 556 printf("Library initialized\n"); 557 558 glfwSetMonitorCallback(monitor_callback); 559 glfwSetJoystickCallback(joystick_callback); 560 561 while ((ch = getopt(argc, argv, "hfn:")) != -1) 562 { 563 switch (ch) 564 { 565 case 'h': 566 usage(); 567 exit(EXIT_SUCCESS); 568 569 case 'f': 570 monitor = glfwGetPrimaryMonitor(); 571 break; 572 573 case 'n': 574 count = (int) strtoul(optarg, NULL, 10); 575 break; 576 577 default: 578 usage(); 579 exit(EXIT_FAILURE); 580 } 581 } 582 583 if (monitor) 584 { 585 const GLFWvidmode* mode = glfwGetVideoMode(monitor); 586 587 glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); 588 glfwWindowHint(GLFW_RED_BITS, mode->redBits); 589 glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); 590 glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); 591 592 width = mode->width; 593 height = mode->height; 594 } 595 else 596 { 597 width = 640; 598 height = 480; 599 } 600 601 slots = calloc(count, sizeof(Slot)); 602 603 for (i = 0; i < count; i++) 604 { 605 char title[128]; 606 607 slots[i].closeable = GLFW_TRUE; 608 slots[i].number = i + 1; 609 610 snprintf(title, sizeof(title), "Event Linter (Window %i)", slots[i].number); 611 612 if (monitor) 613 { 614 printf("Creating full screen window %i (%ix%i on %s)\n", 615 slots[i].number, 616 width, height, 617 glfwGetMonitorName(monitor)); 618 } 619 else 620 { 621 printf("Creating windowed mode window %i (%ix%i)\n", 622 slots[i].number, 623 width, height); 624 } 625 626 slots[i].window = glfwCreateWindow(width, height, title, monitor, NULL); 627 if (!slots[i].window) 628 { 629 free(slots); 630 glfwTerminate(); 631 exit(EXIT_FAILURE); 632 } 633 glfwSetInputMode(slots[i].window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE); 634 635 glfwSetWindowUserPointer(slots[i].window, slots + i); 636 637 glfwSetWindowPosCallback(slots[i].window, window_pos_callback); 638 glfwSetWindowSizeCallback(slots[i].window, window_size_callback); 639 glfwSetFramebufferSizeCallback(slots[i].window, framebuffer_size_callback); 640 glfwSetWindowContentScaleCallback(slots[i].window, window_content_scale_callback); 641 glfwSetWindowCloseCallback(slots[i].window, window_close_callback); 642 glfwSetWindowRefreshCallback(slots[i].window, window_refresh_callback); 643 glfwSetWindowFocusCallback(slots[i].window, window_focus_callback); 644 glfwSetWindowIconifyCallback(slots[i].window, window_iconify_callback); 645 glfwSetWindowMaximizeCallback(slots[i].window, window_maximize_callback); 646 glfwSetMouseButtonCallback(slots[i].window, mouse_button_callback); 647 glfwSetCursorPosCallback(slots[i].window, cursor_position_callback); 648 glfwSetCursorEnterCallback(slots[i].window, cursor_enter_callback); 649 glfwSetScrollCallback(slots[i].window, scroll_callback); 650 glfwSetKeyCallback(slots[i].window, key_callback); 651 glfwSetCharCallback(slots[i].window, char_callback); 652 glfwSetDropCallback(slots[i].window, drop_callback); 653 654 glfwMakeContextCurrent(slots[i].window); 655 gladLoadGL(glfwGetProcAddress); 656 glfwSwapBuffers(slots[i].window); 657 } 658 659 printf("Main loop starting\n"); 660 661 for (;;) 662 { 663 for (i = 0; i < count; i++) 664 { 665 if (glfwWindowShouldClose(slots[i].window)) 666 break; 667 } 668 669 if (i < count) 670 break; 671 672 glfwWaitEvents(); 673 674 // Workaround for an issue with msvcrt and mintty 675 fflush(stdout); 676 } 677 678 free(slots); 679 glfwTerminate(); 680 exit(EXIT_SUCCESS); 681} 682 683
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.