diff --git a/Polyhedron/demo/Polyhedron/Classification.cpp b/Polyhedron/demo/Polyhedron/Classification.cpp index acbb39eb536..aaa7d30116d 100644 --- a/Polyhedron/demo/Polyhedron/Classification.cpp +++ b/Polyhedron/demo/Polyhedron/Classification.cpp @@ -10,20 +10,9 @@ */ int main(int argc, char **argv) { - QSurfaceFormat fmt; - - fmt.setVersion(4, 3); - fmt.setRenderableType(QSurfaceFormat::OpenGL); - fmt.setProfile(QSurfaceFormat::CoreProfile); - fmt.setOption(QSurfaceFormat::DebugContext); - QSurfaceFormat::setDefaultFormat(fmt); - QStringList keywords; - keywords << "Classification"; - Polyhedron_demo app(argc, argv, + Polyhedron_demo app(argc, argv, "Classification demo", "CGAL Classification Demo", - keywords); - //We set the locale to avoid any trouble with VTK - std::setlocale(LC_ALL, "C"); + QStringList() << "Classification"); return app.try_exec(); } diff --git a/Polyhedron/demo/Polyhedron/Mesh_3.cpp b/Polyhedron/demo/Polyhedron/Mesh_3.cpp index 10070f21a59..e29026b1ade 100644 --- a/Polyhedron/demo/Polyhedron/Mesh_3.cpp +++ b/Polyhedron/demo/Polyhedron/Mesh_3.cpp @@ -10,20 +10,9 @@ */ int main(int argc, char **argv) { - QSurfaceFormat fmt; - - fmt.setVersion(4, 3); - fmt.setRenderableType(QSurfaceFormat::OpenGL); - fmt.setProfile(QSurfaceFormat::CoreProfile); - fmt.setOption(QSurfaceFormat::DebugContext); - QSurfaceFormat::setDefaultFormat(fmt); - QStringList keywords; - keywords << "Mesh_3"; - Polyhedron_demo app(argc, argv, + Polyhedron_demo app(argc, argv, "Mesh_3 demo", "CGAL Mesh_3 Demo", - keywords); - //We set the locale to avoid any trouble with VTK - std::setlocale(LC_ALL, "C"); + QStringList() << "Mesh_3"); return app.try_exec(); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_3.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_3.cpp index dec2e51de7a..f15675749d7 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_3.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_3.cpp @@ -1,8 +1,4 @@ #include "Polyhedron_demo.h" -#include -#include -#include - /*! * \brief Defines the entry point of the demo. @@ -10,17 +6,8 @@ */ int main(int argc, char **argv) { - QSurfaceFormat fmt; - - fmt.setVersion(4, 3); - fmt.setRenderableType(QSurfaceFormat::OpenGL); - fmt.setProfile(QSurfaceFormat::CoreProfile); - fmt.setOption(QSurfaceFormat::DebugContext); - QSurfaceFormat::setDefaultFormat(fmt); - Polyhedron_demo app(argc, argv, + Polyhedron_demo app(argc, argv, "Polyhedron_3 demo", "CGAL Polyhedron Demo"); - //We set the locale to avoid any trouble with VTK - std::setlocale(LC_ALL, "C"); return app.try_exec(); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo.cpp index c0e957bd645..6fd6bb4865a 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo.cpp @@ -8,6 +8,7 @@ #include #include #include +#include struct Polyhedron_demo_impl { @@ -17,11 +18,34 @@ struct Polyhedron_demo_impl { Polyhedron_demo_impl() : catch_exceptions(true) {} }; // end struct Polyhedron_demo_impl +int& code_to_call_before_creation_of_QCoreApplication(int& i) { + QSurfaceFormat fmt; + + fmt.setVersion(4, 3); + fmt.setRenderableType(QSurfaceFormat::OpenGL); + fmt.setProfile(QSurfaceFormat::CoreProfile); + fmt.setOption(QSurfaceFormat::DebugContext); + QSurfaceFormat::setDefaultFormat(fmt); + + //for windows +#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) + QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); +#endif + + //We set the locale to avoid any trouble with VTK + std::setlocale(LC_ALL, "C"); + return i; +} + Polyhedron_demo::Polyhedron_demo(int& argc, char **argv, QString application_name, QString main_window_title, QStringList input_keywords) - : QApplication(argc, argv) + : QApplication(code_to_call_before_creation_of_QCoreApplication(argc), + // This trick in the previous line ensure that code + // is called before the creation of the QApplication + // object. + argv) , d_ptr_is_initialized(false) , d_ptr(new Polyhedron_demo_impl) { @@ -30,11 +54,6 @@ Polyhedron_demo::Polyhedron_demo(int& argc, char **argv, std::cout.precision(17); std::clog.precision(17); - //for windows -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) - this->setAttribute(Qt::AA_UseDesktopOpenGL); -#endif - // Import resources from libCGAL (Qt5). CGAL_QT_INIT_RESOURCES;