void monitor_callback(GLFWmonitor monitor, int event) { if (event == GLFW_CONNECTED) { GLFWvidmode mode; glfwGetVideoMode(monitor, &mode); printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n", counter++, glfwGetTime(), glfwGetMonitorName(monitor), mode.width, mode.height, glfwGetMonitorParam(monitor, GLFW_MONITOR_POS_X), glfwGetMonitorParam(monitor, GLFW_MONITOR_POS_Y), glfwGetMonitorParam(monitor, GLFW_MONITOR_WIDTH_MM), glfwGetMonitorParam(monitor, GLFW_MONITOR_HEIGHT_MM)); } else { printf("%08x at %0.3f: Monitor %s was disconnected\n", counter++, glfwGetTime(), glfwGetMonitorName(monitor)); } }
static void monitor_callback(GLFWmonitor* monitor, int event) { if (event == GLFW_CONNECTED) { int x, y, widthMM, heightMM; const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwGetMonitorPos(monitor, &x, &y); glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n", counter++, glfwGetTime(), glfwGetMonitorName(monitor), mode->width, mode->height, x, y, widthMM, heightMM); } else { printf("%08x at %0.3f: Monitor %s was disconnected\n", counter++, glfwGetTime(), glfwGetMonitorName(monitor)); } }
static GLFWwindow* open_window(int width, int height, GLFWmonitor* monitor) { double base; GLFWwindow* window; base = glfwGetTime(); window = glfwCreateWindow(width, height, "Window Re-opener", monitor, NULL); if (!window) return NULL; glfwMakeContextCurrent(window); glfwSwapInterval(1); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetWindowCloseCallback(window, window_close_callback); glfwSetKeyCallback(window, key_callback); if (monitor) { printf("Opening full screen window on monitor %s took %0.3f seconds\n", glfwGetMonitorName(monitor), glfwGetTime() - base); } else { printf("Opening regular window took %0.3f seconds\n", glfwGetTime() - base); } return window; }
GLFWwindow * createWindow(void) { int count; GLFWmonitor ** monitors = glfwGetMonitors(&count); if (count == 1) return glfwCreateWindow(INIT_WIN_WIDTH, INIT_WIN_HEIGHT, WIN_TITLE, NULL, NULL); std::cout << "Available monitors:" << std::endl; for (int i = 0; i < count; i++) { const GLFWvidmode * mode = glfwGetVideoMode(monitors[i]); std::cout << "\t" << i + 1 << ":\t" << glfwGetMonitorName(monitors[i]) << "\t" << mode->width << "x" << mode->height << std::endl; } int selectedMonitor = -1; if (SELECT_MONITOR_MAN) { std::string data; do { std::cout << "\nPlease select a monitor:" << std::endl; std::getline(std::cin, data); if (data.length() > 3) continue; selectedMonitor = (unsigned int)atoi(data.c_str()); } while (selectedMonitor < 1 || selectedMonitor > count); } else selectedMonitor = SELECT_MONITOR_DEFAULT; std::cout << "Selected monitor " << selectedMonitor << "." << std::endl; selectedMonitor--; // the monitors display as starting from 1 instead of 0 const GLFWvidmode * mode = glfwGetVideoMode(monitors[selectedMonitor]); controller.m_state.winWidth = mode->width; controller.m_state.winHeight = mode->height; glfwWindowHint(GLFW_AUTO_ICONIFY, false); return glfwCreateWindow(controller.m_state.winWidth, controller.m_state.winHeight = mode->height, WIN_TITLE, monitors[selectedMonitor], NULL); }
static void list_modes(GLFWmonitor* monitor) { int count, x, y, widthMM, heightMM, dpi, i; GLFWvidmode mode = glfwGetVideoMode(monitor); const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); glfwGetMonitorPos(monitor, &x, &y); glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); printf("Name: %s (%s)\n", glfwGetMonitorName(monitor), glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary"); printf("Current mode: %s\n", format_mode(&mode)); printf("Virtual position: %i %i\n", x, y); dpi = (int) ((float) mode.width * 25.4f / (float) widthMM); printf("Physical size: %i x %i mm (%i dpi)\n", widthMM, heightMM, dpi); printf("Modes:\n"); for (i = 0; i < count; i++) { printf("%3u: %s", (unsigned int) i, format_mode(modes + i)); if (memcmp(&mode, modes + i, sizeof(GLFWvidmode)) == 0) printf(" (current mode)"); putchar('\n'); } }
/// Dump a list of monitor info to Log and stdout. /// http://www.glfw.org/docs/3.0/monitor.html void PrintMonitorInfo() { int count; GLFWmonitor** monitors = glfwGetMonitors(&count); printf("Found %d monitors:\n", count); LOG_INFO("Found %d monitors:", count); for (int i=0; i<count; ++i) { GLFWmonitor* pMonitor = monitors[i]; if (pMonitor == NULL) continue; printf(" Monitor %d:\n", i); LOG_INFO(" Monitor %d:", i); /// Monitor name const char* pName = glfwGetMonitorName(pMonitor); printf(" Name: %s\n", pName); LOG_INFO(" Name: %s", pName); /// Monitor Physical Size int widthMM, heightMM; glfwGetMonitorPhysicalSize(pMonitor, &widthMM, &heightMM); //const double dpi = mode->width / (widthMM / 25.4); printf(" physical size: %d x %d mm\n"); LOG_INFO(" physical size: %d x %d mm"); /// Modes const GLFWvidmode* mode = glfwGetVideoMode(pMonitor); printf(" Current mode: %dx%d @ %dHz (RGB %d %d %d bits)\n", mode->width, mode->height, mode->refreshRate, mode->redBits, mode->greenBits, mode->blueBits); LOG_INFO(" Current mode: %dx%d @ %dHz (RGB %d %d %d bits)", mode->width, mode->height, mode->refreshRate, mode->redBits, mode->greenBits, mode->blueBits); #if 0 int modeCount; const GLFWvidmode* modes = glfwGetVideoModes(pMonitor, &modeCount); printf(" %d Modes:\n", modeCount); LOG_INFO(" %d Modes:", modeCount); for (int j=0; j<modeCount; ++j) { const GLFWvidmode& m = modes[j]; printf(" %dx%d @ %dHz (RGB %d %d %d bits)\n", m.width, m.height, m.refreshRate, m.redBits, m.greenBits, m.blueBits); LOG_INFO(" %dx%d @ %dHz (RGB %d %d %d bits)", m.width, m.height, m.refreshRate, m.redBits, m.greenBits, m.blueBits); } #endif } }
JNIEXPORT jstring JNICALL Java_com_badlogic_jglfw_Glfw_glfwGetMonitorName(JNIEnv* env, jclass clazz, jlong monitor) { //@line:626 return env->NewStringUTF(glfwGetMonitorName((GLFWmonitor*)monitor)); }
char* app_display_querymodes() { glfwSetErrorCallback(glfw_error_callback); if (!glfwInit()) return NULL; uint adapter_id = 0; size_t outsz; /* start json data (adapter array) */ json_t jroot = json_create_arr(); /* read adapters */ while (adapter_id == 0) { json_t jadapter = json_create_obj(); json_additem_toarr(jroot, jadapter); json_additem_toobj(jadapter, "name", json_create_str("Graphics Card #1")); json_additem_toobj(jadapter, "id", json_create_num(0)); /* enumerate monitors */ json_t joutputs = json_create_arr(); json_additem_toobj(jadapter, "monitors", joutputs); int output_cnt = 0; GLFWmonitor** monitors = glfwGetMonitors(&output_cnt); for (int i = 0; i < output_cnt; i++) { json_t joutput = json_create_obj(); json_additem_toarr(joutputs, joutput); json_additem_toobj(joutput, "id", json_create_num((fl64)i)); json_additem_toobj(joutput, "name", json_create_str(glfwGetMonitorName(monitors[i]))); /* enumerate modes */ json_t jmodes = json_create_arr(); json_additem_toobj(joutput, "modes", jmodes); int mode_cnt; const GLFWvidmode* modes = glfwGetVideoModes(monitors[i], &mode_cnt); for (int i = 0; i < mode_cnt; i++) { json_t jmode = json_create_obj(); json_additem_toobj(jmode, "width", json_create_num((fl64)modes[i].width)); json_additem_toobj(jmode, "height", json_create_num((fl64)modes[i].height)); json_additem_toobj(jmode, "refresh-rate", json_create_num((fl64)modes[i].refreshRate)); json_additem_toarr(jmodes, jmode); } } adapter_id ++; } char* r = json_savetobuffer(jroot, &outsz, FALSE); json_destroy(jroot); return r; }
Monitor::Monitor(GLFWmonitor *monitor) { if(0 != monitor) { const char *nm = glfwGetMonitorName(monitor); name = nm; int width; int height; glfwGetMonitorPhysicalSize(monitor, &width, &height); size = glm::vec2(width, height); current = Mode(glfwGetVideoMode(monitor)); int modeCount; const GLFWvidmode *vidmods = glfwGetVideoModes(monitor, &modeCount); for(int i = 0; i < modeCount; ++i) { modes.push_back(Mode(vidmods + i)); } } descriptor = monitor; }
std::string Monitor::getName() const { return glfwGetMonitorName(monitor); }
int main(int argc, char** argv) { int count = 0; double base; GLFWwindow* window; srand((unsigned int) time(NULL)); glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); for (;;) { int width, height; GLFWmonitor* monitor = NULL; GLuint vertex_shader, fragment_shader, program, vertex_buffer; GLint mvp_location, vpos_location; if (count & 1) { int monitorCount; GLFWmonitor** monitors = glfwGetMonitors(&monitorCount); monitor = monitors[rand() % monitorCount]; } if (monitor) { const GLFWvidmode* mode = glfwGetVideoMode(monitor); width = mode->width; height = mode->height; } else { width = 640; height = 480; } base = glfwGetTime(); window = glfwCreateWindow(width, height, "Window Re-opener", monitor, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } if (monitor) { printf("Opening full screen window on monitor %s took %0.3f seconds\n", glfwGetMonitorName(monitor), glfwGetTime() - base); } else { printf("Opening regular window took %0.3f seconds\n", glfwGetTime() - base); } glfwSetWindowCloseCallback(window, window_close_callback); glfwSetKeyCallback(window, key_callback); glfwMakeContextCurrent(window); gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); glfwSwapInterval(1); vertex_shader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL); glCompileShader(vertex_shader); fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL); glCompileShader(fragment_shader); program = glCreateProgram(); glAttachShader(program, vertex_shader); glAttachShader(program, fragment_shader); glLinkProgram(program); mvp_location = glGetUniformLocation(program, "MVP"); vpos_location = glGetAttribLocation(program, "vPos"); glGenBuffers(1, &vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glEnableVertexAttribArray(vpos_location); glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, sizeof(vertices[0]), (void*) 0); glfwSetTime(0.0); while (glfwGetTime() < 5.0) { float ratio; int width, height; mat4x4 m, p, mvp; glfwGetFramebufferSize(window, &width, &height); ratio = width / (float) height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 0.f, 1.f); mat4x4_identity(m); mat4x4_rotate_Z(m, m, (float) glfwGetTime()); mat4x4_mul(mvp, p, m); glUseProgram(program); glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glfwSwapBuffers(window); glfwPollEvents(); if (glfwWindowShouldClose(window)) { close_window(window); printf("User closed window\n"); glfwTerminate(); exit(EXIT_SUCCESS); } } printf("Closing window\n"); close_window(window); count++; } glfwTerminate(); }
int main() { GLFWwindow *window; char *userptr = "userptr"; glfwSetErrorCallback(errorcb); assert(glfwInit() == GL_TRUE); assert(!strcmp(glfwGetVersionString(), "3.2.1 JS WebGL Emscripten")); assert(glfwGetCurrentContext() == NULL); { int major, minor, rev; glfwGetVersion(&major, &minor, &rev); assert(major == 3); assert(minor == 2); assert(rev == 1); } { int count, x, y, w, h; GLFWmonitor **monitors = glfwGetMonitors(&count); assert(count == 1); for (int i = 0; i < count; ++i) { assert(monitors[i] != NULL); } assert(glfwGetPrimaryMonitor() != NULL); glfwGetMonitorPos(monitors[0], &x, &y); glfwGetMonitorPhysicalSize(monitors[0], &w, &h); assert(glfwGetMonitorName(monitors[0]) != NULL); glfwSetMonitorCallback(monitcb); // XXX: not implemented // assert(glfwGetVideoModes(monitors[0], &count) != NULL); // assert(glfwGetVideoMode(monitors[0]) != NULL); // glfwSetGamma(monitors[0], 1.0f); // assert(glfwGetGammaRamp(monitors[0]) != NULL); // glfwSetGammaRamp(monitors[0], ramp); } { int x, y, w, h; glfwDefaultWindowHints(); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); window = glfwCreateWindow(640, 480, "glfw3.c", NULL, NULL); assert(window != NULL); glfwSetWindowPosCallback(window, wposicb); glfwSetWindowSizeCallback(window, wsizecb); glfwSetWindowCloseCallback(window, wcloscb); glfwSetWindowRefreshCallback(window, wrfrscb); glfwSetWindowFocusCallback(window, wfocucb); glfwSetWindowIconifyCallback(window, wiconcb); glfwSetFramebufferSizeCallback(window, wfsizcb); assert(glfwWindowShouldClose(window) == 0); glfwSetWindowShouldClose(window, 1); assert(glfwWindowShouldClose(window) == 1); glfwSetWindowTitle(window, "test"); glfwSetWindowTitle(window, "glfw3.c"); // XXX: not implemented // glfwSetWindowPos(window, 1, 1); glfwGetWindowPos(window, &x, &y); // stub glfwGetWindowSize(window, &w, &h); assert(w == 640 && h == 480); glfwSetWindowSize(window, 1, 1); glfwGetWindowSize(window, &w, &h); assert(w == 1 && h == 1); glfwSetWindowSize(window, 640, 480); glfwGetFramebufferSize(window, &w, &h); // XXX: not implemented // glfwIconifyWindow(window); // glfwRestoreWindow(window); // glfwShowWindow(window); // glfwHideWindow(window); assert(glfwGetWindowMonitor(window) == NULL); glfwDestroyWindow(window); window = glfwCreateWindow(640, 480, "glfw3.c", glfwGetPrimaryMonitor(), NULL); assert(window != NULL); assert(glfwGetWindowMonitor(window) == glfwGetPrimaryMonitor()); glfwDestroyWindow(window); window = glfwCreateWindow(640, 480, "glfw3.c", NULL, NULL); assert(window != NULL); assert(glfwGetWindowAttrib(window, GLFW_CLIENT_API) == GLFW_OPENGL_ES_API); assert(glfwGetWindowUserPointer(window) == NULL); glfwSetWindowUserPointer(window, userptr); assert(glfwGetWindowUserPointer(window) == userptr); } { double x, y; glfwSetKeyCallback(window, wkeypcb); glfwSetCharCallback(window, wcharcb); glfwSetMouseButtonCallback(window, wmbutcb); glfwSetCursorPosCallback(window, wcurpcb); glfwSetCursorEnterCallback(window, wcurecb); glfwSetScrollCallback(window, wscrocb); // XXX: stub, events come immediatly // glfwPollEvents(); // glfwWaitEvents(); assert(glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_NORMAL); // XXX: not implemented // glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); glfwGetKey(window, GLFW_KEY_A); glfwGetMouseButton(window, 0); glfwGetCursorPos(window, &x, &y); // XXX: not implemented // glfwSetCursorPos(window, 0, 0); } { // XXX: not implemented // glfwJoystickPresent(joy); // glfwGetJoystickAxes(joy, &count); // glfwGetJoystickButtons(joy, &count); // glfwGetJoystickName(joy); } { // XXX: not implemented // glfwSetClipboardString(window, "string"); // glfwGetClipboardString(window); } { glfwGetTime(); glfwSetTime(0); } { glfwMakeContextCurrent(window); // stub assert(glfwGetCurrentContext() == window); glfwSwapBuffers(window); // stub glfwSwapInterval(0); // stub } { assert(glfwExtensionSupported("nonexistant") == 0); assert(glfwGetProcAddress("nonexistant") == NULL); } glfwTerminate(); #ifdef REPORT_RESULT REPORT_RESULT(1); #endif return 0; }
static void test_modes(GLFWmonitor* monitor) { int i, count; const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); for (i = 0; i < count; i++) { const GLFWvidmode* mode = modes + i; GLFWvidmode current; glfwWindowHint(GLFW_RED_BITS, mode->redBits); glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); printf("Testing mode %u on monitor %s: %s\n", (unsigned int) i, glfwGetMonitorName(monitor), format_mode(mode)); window_handle = glfwCreateWindow(mode->width, mode->height, "Video Mode Test", glfwGetPrimaryMonitor(), NULL); if (!window_handle) { printf("Failed to enter mode %u: %s\n", (unsigned int) i, format_mode(mode)); continue; } glfwSetWindowSizeCallback(window_handle, window_size_callback); glfwSetWindowCloseCallback(window_handle, window_close_callback); glfwSetKeyCallback(window_handle, key_callback); glfwMakeContextCurrent(window_handle); glfwSwapInterval(1); glfwSetTime(0.0); while (glfwGetTime() < 5.0) { glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window_handle); glfwPollEvents(); if (!window_handle) { printf("User terminated program\n"); glfwTerminate(); exit(EXIT_SUCCESS); } } glGetIntegerv(GL_RED_BITS, ¤t.redBits); glGetIntegerv(GL_GREEN_BITS, ¤t.greenBits); glGetIntegerv(GL_BLUE_BITS, ¤t.blueBits); glfwGetWindowSize(window_handle, ¤t.width, ¤t.height); if (current.redBits != mode->redBits || current.greenBits != mode->greenBits || current.blueBits != mode->blueBits) { printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n", current.redBits, current.greenBits, current.blueBits, mode->redBits, mode->greenBits, mode->blueBits); } if (current.width != mode->width || current.height != mode->height) { printf("*** Size mismatch: %ix%i instead of %ix%i\n", current.width, current.height, mode->width, mode->height); } printf("Closing window\n"); glfwDestroyWindow(window_handle); window_handle = NULL; glfwPollEvents(); } }
int main(int argc, char** argv) { Slot* slots; GLFWmonitor* monitor = NULL; int ch, i, width, height, count = 1; setlocale(LC_ALL, ""); glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); printf("Library initialized\n"); glfwSetMonitorCallback(monitor_callback); while ((ch = getopt(argc, argv, "hfn:")) != -1) { switch (ch) { case 'h': usage(); exit(EXIT_SUCCESS); case 'f': monitor = glfwGetPrimaryMonitor(); break; case 'n': count = (int) strtol(optarg, NULL, 10); break; default: usage(); exit(EXIT_FAILURE); } } if (monitor) { const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); glfwWindowHint(GLFW_RED_BITS, mode->redBits); glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); width = mode->width; height = mode->height; } else { width = 640; height = 480; } if (!count) { fprintf(stderr, "Invalid user\n"); exit(EXIT_FAILURE); } slots = calloc(count, sizeof(Slot)); for (i = 0; i < count; i++) { char title[128]; slots[i].closeable = GL_TRUE; slots[i].number = i + 1; sprintf(title, "Event Linter (Window %i)", slots[i].number); if (monitor) { printf("Creating full screen window %i (%ix%i on %s)\n", slots[i].number, width, height, glfwGetMonitorName(monitor)); } else { printf("Creating windowed mode window %i (%ix%i)\n", slots[i].number, width, height); } slots[i].window = glfwCreateWindow(width, height, title, monitor, NULL); if (!slots[i].window) { free(slots); glfwTerminate(); exit(EXIT_FAILURE); } glfwSetWindowUserPointer(slots[i].window, slots + i); glfwSetWindowPosCallback(slots[i].window, window_pos_callback); glfwSetWindowSizeCallback(slots[i].window, window_size_callback); glfwSetFramebufferSizeCallback(slots[i].window, framebuffer_size_callback); glfwSetWindowCloseCallback(slots[i].window, window_close_callback); glfwSetWindowRefreshCallback(slots[i].window, window_refresh_callback); glfwSetWindowFocusCallback(slots[i].window, window_focus_callback); glfwSetWindowIconifyCallback(slots[i].window, window_iconify_callback); glfwSetMouseButtonCallback(slots[i].window, mouse_button_callback); glfwSetCursorPosCallback(slots[i].window, cursor_position_callback); glfwSetCursorEnterCallback(slots[i].window, cursor_enter_callback); glfwSetScrollCallback(slots[i].window, scroll_callback); glfwSetKeyCallback(slots[i].window, key_callback); glfwSetCharCallback(slots[i].window, char_callback); glfwSetCharModsCallback(slots[i].window, char_mods_callback); glfwSetDropCallback(slots[i].window, drop_callback); glfwMakeContextCurrent(slots[i].window); glfwSwapInterval(1); } printf("Main loop starting\n"); for (;;) { for (i = 0; i < count; i++) { if (glfwWindowShouldClose(slots[i].window)) break; } if (i < count) break; glfwWaitEvents(); // Workaround for an issue with msvcrt and mintty fflush(stdout); } free(slots); glfwTerminate(); exit(EXIT_SUCCESS); }
const char* call(GLFWmonitor* monitor) { return glfwGetMonitorName(monitor); }
int main(int argc, char** argv) { glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); gleqInit(); GLFWwindow* window = glfwCreateWindow(640, 480, "Event Queue Test", NULL, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); glfwSwapInterval(0); gleqTrackWindow(window); while (!glfwWindowShouldClose(window)) { GLEQevent event; glfwSwapBuffers(window); glfwWaitEvents(); while (gleqNextEvent(&event)) { switch (event.type) { case GLEQ_WINDOW_MOVED: printf("Window moved to %i,%i\n", event.pos.x, event.pos.y); break; case GLEQ_WINDOW_RESIZED: printf("Window resized to %ix%i\n", event.size.width, event.size.height); break; case GLEQ_WINDOW_CLOSED: printf("Window close request\n"); break; case GLEQ_WINDOW_REFRESH: printf("Window refresh request\n"); break; case GLEQ_WINDOW_FOCUSED: printf("Window focused\n"); break; case GLEQ_WINDOW_DEFOCUSED: printf("Window defocused\n"); break; case GLEQ_WINDOW_ICONIFIED: printf("Window iconified\n"); break; case GLEQ_WINDOW_UNICONIFIED: printf("Window uniconified\n"); break; #if GLFW_VERSION_MINOR >= 3 case GLEQ_WINDOW_MAXIMIZED: printf("Window maximized\n"); break; case GLEQ_WINDOW_UNMAXIMIZED: printf("Window unmaximized\n"); break; case GLEQ_WINDOW_SCALE_CHANGED: printf("Window content scale %0.2fx%0.2f\n", event.scale.x, event.scale.y); break; #endif // GLFW_VERSION_MINOR case GLEQ_FRAMEBUFFER_RESIZED: printf("Framebuffer resized to %ix%i\n", event.size.width, event.size.height); break; case GLEQ_BUTTON_PRESSED: printf("Mouse button %i pressed (mods 0x%x)\n", event.mouse.button, event.mouse.mods); break; case GLEQ_BUTTON_RELEASED: printf("Mouse button %i released (mods 0x%x)\n", event.mouse.button, event.mouse.mods); break; case GLEQ_CURSOR_MOVED: printf("Cursor moved to %i,%i\n", event.pos.x, event.pos.y); break; case GLEQ_CURSOR_ENTERED: printf("Cursor entered window\n"); break; case GLEQ_CURSOR_LEFT: printf("Cursor left window\n"); break; case GLEQ_SCROLLED: printf("Scrolled %0.2f,%0.2f\n", event.scroll.x, event.scroll.y); break; case GLEQ_KEY_PRESSED: printf("Key 0x%02x pressed (scancode 0x%x mods 0x%x)\n", event.keyboard.key, event.keyboard.scancode, event.keyboard.mods); break; case GLEQ_KEY_REPEATED: printf("Key 0x%02x repeated (scancode 0x%x mods 0x%x)\n", event.keyboard.key, event.keyboard.scancode, event.keyboard.mods); break; case GLEQ_KEY_RELEASED: printf("Key 0x%02x released (scancode 0x%x mods 0x%x)\n", event.keyboard.key, event.keyboard.scancode, event.keyboard.mods); break; case GLEQ_CODEPOINT_INPUT: printf("Codepoint U+%05X input\n", event.codepoint); break; #if GLFW_VERSION_MINOR >= 1 case GLEQ_FILE_DROPPED: { int i; printf("%i files dropped\n", event.file.count); for (i = 0; i < event.file.count; i++) printf("\t%s\n", event.file.paths[i]); break; } #endif // GLFW_VERSION_MINOR case GLEQ_MONITOR_CONNECTED: printf("Monitor \"%s\" connected\n", glfwGetMonitorName(event.monitor)); break; case GLEQ_MONITOR_DISCONNECTED: printf("Monitor \"%s\" disconnected\n", glfwGetMonitorName(event.monitor)); break; #if GLFW_VERSION_MINOR >= 2 case GLEQ_JOYSTICK_CONNECTED: printf("Joystick %i \"%s\" connected\n", event.joystick, glfwGetJoystickName(event.joystick)); break; case GLEQ_JOYSTICK_DISCONNECTED: printf("Joystick %i disconnected\n", event.joystick); break; #endif // GLFW_VERSION_MINOR default: fprintf(stderr, "Error: Unknown event %i\n", event.type); break; } gleqFreeEvent(&event); } // Workaround for msvcrt stdout not being properly flushed by // newlines when running inside mintty fflush(stdout); } glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); }
const char* CMonitor::getName() noexcept { return glfwGetMonitorName(m_monitor); }