/* Hello World - affichage d'un rectangle avec GLFW CC BY-SA Edouard.Thiel@univ-amu.fr - 24/12/2024 */ #include #include void displayGL (GLFWwindow* window) { std::cout << __func__ << std::endl; glClear (GL_COLOR_BUFFER_BIT); glRectd (-0.5, -0.5, 0.5, 0.5); } void error_callback (int error, const char* description) { std::cerr << "Error: " << description << std::endl; } int main() { if (!glfwInit()) { std::cerr << "GLFW: initialization failed" << std::endl; exit (1); } glfwSetErrorCallback (error_callback); GLFWwindow* window = glfwCreateWindow (640, 480, "Hello World!", NULL, NULL); if (!window) { std::cerr << "GLFW: window creation failed" << std::endl; glfwTerminate(); exit (1); } glfwMakeContextCurrent (window); while (!glfwWindowShouldClose (window)) { displayGL (window); glfwSwapBuffers (window); glfwWaitEvents(); } glfwDestroyWindow (window); glfwTerminate(); }