#include #include #include #include #include static void char_callback(GLFWwindow* window, unsigned int ch) { printf ("Char: \"%lc\"\n", (int) ch); } static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (action != GLFW_PRESS) return; switch (key) { case GLFW_KEY_ESCAPE: glfwSetWindowShouldClose(window, GLFW_TRUE); break; } } int main(int argc, char** argv) { setlocale(LC_ALL, ""); GLFWwindow* window; if (!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW\n"); exit(EXIT_FAILURE); } window = glfwCreateWindow(200, 200, "Window Icon", NULL, NULL); if (!window) { glfwTerminate(); fprintf(stderr, "Failed to open GLFW window\n"); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, key_callback); glfwSetCharCallback(window, char_callback); while (!glfwWindowShouldClose(window)) { glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window); glfwWaitEvents(); } glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); }