/* Classe MyApp CC BY-SA Edouard.Thiel@univ-amu.fr - 24/12/2024 */ #include #include class MyApp { bool m_ok = false; GLFWwindow* m_window = nullptr; void displayGL() { std::cout << __func__ << std::endl; glClear (GL_COLOR_BUFFER_BIT); glRectd (-0.5, -0.5, 0.5, 0.5); } static void on_error_func (int error, const char* description) { std::cerr << "Error: " << description << std::endl; } public: MyApp() { if (!glfwInit()) { std::cerr << "GLFW: initialization failed" << std::endl; return; } glfwSetErrorCallback (on_error_func); m_window = glfwCreateWindow (640, 480, "Classe MyApp", NULL, NULL); if (!m_window) { std::cerr << "GLFW: window creation failed" << std::endl; return; } glfwMakeContextCurrent (m_window); m_ok = true; } void run() { while (m_ok && !glfwWindowShouldClose (m_window)) { displayGL(); glfwSwapBuffers (m_window); glfwWaitEvents(); } } ~MyApp() { if (m_window) glfwDestroyWindow (m_window); glfwTerminate(); } }; // MyApp int main() { MyApp app; app.run(); }