#include #include #include void errorCallback(int id, const char* message) { printf("Error code=%d, message=%s\n", id, message); } int main(void) { GLFWwindow* window; glfwSetErrorCallback(errorCallback); /* Initialize the library */ if (!glfwInit()) { printf("init failed\n"); return -1; } /* Create a windowed mode window and its OpenGL context */ window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); if (!window) { printf("failed to create window\n"); glfwTerminate(); return -1; } /* Make the window's context current */ glfwMakeContextCurrent(window); /* Loop until the user closes the window */ while (!glfwWindowShouldClose(window)) { /* Render here */ glClear(GL_COLOR_BUFFER_BIT); /* Swap front and back buffers */ glfwSwapBuffers(window); /* Poll for and process events */ glfwPollEvents(); } glfwTerminate(); printf("closing window normally!\n"); return 0; }