diff --git a/AABB_tree/demo/AABB_tree/AABB_demo.cpp b/AABB_tree/demo/AABB_tree/AABB_demo.cpp index c69f7aa1281..018e0f69c14 100644 --- a/AABB_tree/demo/AABB_tree/AABB_demo.cpp +++ b/AABB_tree/demo/AABB_tree/AABB_demo.cpp @@ -19,18 +19,16 @@ #include #include #include - +#include int main(int argc, char **argv) { + + CGAL::Qt::init_ogl_context(4,3); QApplication app(argc, argv); app.setOrganizationDomain("inria.fr"); app.setOrganizationName("INRIA"); app.setApplicationName("AABB tree demo"); - //for windows -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) - app.setAttribute(Qt::AA_UseDesktopOpenGL); -#endif // Import resources from libCGALQt (Qt5). CGAL_QT_INIT_RESOURCES; diff --git a/AABB_tree/demo/AABB_tree/MainWindow.cpp b/AABB_tree/demo/AABB_tree/MainWindow.cpp index c5d00c638bb..78a8336f076 100644 --- a/AABB_tree/demo/AABB_tree/MainWindow.cpp +++ b/AABB_tree/demo/AABB_tree/MainWindow.cpp @@ -45,6 +45,7 @@ MainWindow::MainWindow(QWidget* parent) MainWindow::~MainWindow() { + m_pViewer->makeCurrent(); delete ui; } diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index 69ba683a21b..b86be7ca292 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -91,8 +91,8 @@ void Scene::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 f_matrix;\n" "void main(void)\n" @@ -103,10 +103,11 @@ void Scene::compile_shaders() //Vertex source code const char fragment_source[] = { - "#version 120 \n" + "#version 150 \n" "uniform highp vec4 color; \n" + "out highp vec4 out_color; \n" "void main(void) { \n" - "gl_FragColor = color; \n" + "out_color = color; \n" "} \n" "\n" }; @@ -139,26 +140,27 @@ void Scene::compile_shaders() //Vertex source code const char tex_vertex_source[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" - "attribute highp vec2 tex_coord; \n" + "#version 150 \n" + "in highp vec4 vertex;\n" + "in highp vec2 tex_coord; \n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 f_matrix;\n" - "varying highp vec2 texc;\n" + "out highp vec2 texc;\n" "void main(void)\n" "{\n" " gl_Position = mvp_matrix * f_matrix * vertex;\n" - " texc = tex_coord;\n" + " texc = tex_coord;\n" "}" }; //Vertex source code const char tex_fragment_source[] = { - "#version 120 \n" - "uniform sampler2D texture;\n" - "varying highp vec2 texc;\n" + "#version 150 \n" + "uniform sampler2D s_texture;\n" + "in highp vec2 texc;\n" + "out highp vec4 out_color; \n" "void main(void) { \n" - "gl_FragColor = texture2D(texture, texc.st);\n" + "out_color = vec4(texture(s_texture, texc));\n" "} \n" "\n" }; @@ -1319,12 +1321,8 @@ void Scene::deactivate_cutting_plane() } void Scene::initGL() { - gl = new QOpenGLFunctions_2_1(); - if(!gl->initializeOpenGLFunctions()) - { - qFatal("ERROR : OpenGL Functions not initialized. Check your OpenGL Verison (should be >=3.3)"); - exit(1); - } + gl = new QOpenGLFunctions(); + gl->initializeOpenGLFunctions(); gl->glGenTextures(1, &textureId); compile_shaders(); diff --git a/AABB_tree/demo/AABB_tree/Scene.h b/AABB_tree/demo/AABB_tree/Scene.h index 95ea74cdc33..44d7b8239ce 100644 --- a/AABB_tree/demo/AABB_tree/Scene.h +++ b/AABB_tree/demo/AABB_tree/Scene.h @@ -86,7 +86,7 @@ public: private: // member data - QOpenGLFunctions_2_1 *gl; + QOpenGLFunctions *gl; Bbox m_bbox; Polyhedron *m_pPolyhedron; std::list m_points; diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/Alpha_shape_3.cpp b/Alpha_shapes_3/demo/Alpha_shapes_3/Alpha_shape_3.cpp index dbe053e9824..784ee1af57f 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/Alpha_shape_3.cpp +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/Alpha_shape_3.cpp @@ -5,18 +5,16 @@ #include +#include int main(int argc, char** argv) { - QApplication application(argc,argv); + CGAL::Qt::init_ogl_context(4,3); + QApplication application(argc,argv); application.setOrganizationDomain("geometryfactory.com"); application.setOrganizationName("GeometryFactory"); application.setApplicationName("Alpha Shape Reconstruction"); - //for Windows -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) - application.setAttribute(Qt::AA_UseDesktopOpenGL); -#endif // Import resources from libCGALQt (Qt5). // See https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp index a30e7a9a133..ad0e388412c 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp @@ -29,14 +29,14 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" - "attribute highp vec3 normal;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" + "in highp vec3 normal;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" + "out highp vec4 fP; \n" + "out highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -47,15 +47,16 @@ void Viewer::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 120 \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" + "#version 150 \n" + "in highp vec4 fP; \n" + "in highp vec3 fN; \n" "uniform highp vec4 color; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" "uniform highp vec4 light_spec; \n" "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" + "out highp vec4 out_color; \n" "void main(void) { \n" @@ -70,7 +71,7 @@ void Viewer::compile_shaders() " highp vec4 diffuse = abs(dot(N,L)) * light_diff * color; \n" " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" - "gl_FragColor = light_amb*color + diffuse + specular ; \n" + "out_color = light_amb*color + diffuse + specular ; \n" "} \n" "\n" }; @@ -105,8 +106,8 @@ rendering_program.bind(); //Vertex source code const char vertex_source_points[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp float point_size;\n" @@ -119,11 +120,12 @@ const char vertex_source_points[] = //Vertex source code const char fragment_source_points[] = { - "#version 120 \n" + "#version 150 \n" "uniform highp vec4 color; \n" + "out highp vec4 out_color; \n" "void main(void) { \n" - "gl_FragColor = color; \n" + "out_color = color; \n" "} \n" "\n" }; diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h index ff19159d837..289ae385c1e 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h @@ -21,6 +21,7 @@ public: Viewer(QWidget* parent); ~Viewer() { + makeCurrent(); buffers[0].destroy(); buffers[1].destroy(); buffers[2].destroy(); diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Circular_kernel_3.cpp b/Circular_kernel_3/demo/Circular_kernel_3/Circular_kernel_3.cpp index 513722fec61..0b41052abad 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Circular_kernel_3.cpp +++ b/Circular_kernel_3/demo/Circular_kernel_3/Circular_kernel_3.cpp @@ -1,17 +1,12 @@ #include "Viewer.h" #include - +#include int main(int argc, char** argv) { - // Read command lines arguments. + CGAL::Qt::init_ogl_context(4,3); QApplication application(argc,argv); - // Instantiate the viewer. Viewer viewer; - //for Windows -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) - application.setAttribute(Qt::AA_UseDesktopOpenGL); -#endif viewer.setWindowTitle("Intersection points of randomly generated circles."); // Make the viewer window visible on screen. diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp index c026e1cce0b..aa5a06c1354 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp +++ b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp @@ -11,6 +11,14 @@ Viewer::Viewer(QWidget* parent ) { extension_is_found = false; } +Viewer::~Viewer() +{ + makeCurrent(); + for(int i=0; i<3; ++i) + vao[i].destroy(); + for(int i=0; i<9; ++i) + buffers[i].destroy(); +} void Viewer::compile_shaders() { @@ -32,16 +40,16 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" - "attribute highp vec3 normal;\n" - "attribute highp vec4 center;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" + "in highp vec3 normal;\n" + "in highp vec4 center;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" + "out highp vec4 fP; \n" + "out highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -52,15 +60,16 @@ void Viewer::compile_shaders() //Vertex source code const char fragment_source[] = { - "#version 120 \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" + "#version 150 \n" + "in highp vec4 fP; \n" + "in highp vec3 fN; \n" "uniform highp vec4 color; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" "uniform highp vec4 light_spec; \n" "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" + "out highp vec4 out_color; \n" "void main(void) { \n" @@ -75,7 +84,7 @@ void Viewer::compile_shaders() " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n" " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" - "gl_FragColor = light_amb*color + diffuse ; \n" + "out_color = light_amb*color + diffuse ; \n" "} \n" "\n" }; @@ -111,8 +120,8 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source_no_ext[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "void main(void)\n" "{\n" @@ -123,10 +132,11 @@ void Viewer::compile_shaders() //Vertex source code const char fragment_source_no_ext[] = { - "#version 120 \n" + "#version 150 \n" "uniform highp vec4 color; \n" + "out highp vec4 out_color; \n" "void main(void) { \n" - "gl_FragColor = color; \n" + "out_color = color; \n" "} \n" "\n" }; diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h index ea178e756a0..cad037ce2c8 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h +++ b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h @@ -13,6 +13,7 @@ class Viewer : public CGAL::QGLViewer { public: Viewer(QWidget* parent = 0); + ~Viewer(); GLuint dl_nb; protected : virtual void draw(); diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index 11058fe04e6..37462215e41 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -54,21 +54,20 @@ namespace CGAL { - //------------------------------------------------------------------------------ const char vertex_source_color[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" - "attribute highp vec3 normal;\n" - "attribute highp vec3 color;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" + "in highp vec3 normal;\n" + "in highp vec3 color;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" - "varying highp vec4 fColor; \n" + "out highp vec4 fP; \n" + "out highp vec3 fN; \n" + "out highp vec4 fColor; \n" "uniform highp float point_size; \n" "void main(void)\n" @@ -83,15 +82,16 @@ const char vertex_source_color[] = const char fragment_source_color[] = { - "#version 120 \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" - "varying highp vec4 fColor; \n" + "#version 150 \n" + "in highp vec4 fP; \n" + "in highp vec3 fN; \n" + "in highp vec4 fColor; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" "uniform highp vec4 light_spec; \n" "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" + "out vec4 out_color; \n" "void main(void) { \n" " highp vec3 L = light_pos.xyz - fP.xyz; \n" @@ -104,18 +104,18 @@ const char fragment_source_color[] = " highp vec3 R = reflect(-L, N); \n" " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" - " gl_FragColor = light_amb*fColor + diffuse ; \n" + " out_color = light_amb*fColor + diffuse ; \n" "} \n" "\n" }; const char vertex_source_p_l[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" - "attribute highp vec3 color;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" + "in highp vec3 color;\n" "uniform highp mat4 mvp_matrix;\n" - "varying highp vec4 fColor; \n" + "out highp vec4 fColor; \n" "uniform highp float point_size; \n" "void main(void)\n" "{\n" @@ -127,10 +127,11 @@ const char vertex_source_p_l[] = const char fragment_source_p_l[] = { - "#version 120 \n" - "varying highp vec4 fColor; \n" + "#version 150 \n" + "in highp vec4 fColor; \n" + "out vec4 out_color; \n" "void main(void) { \n" - "gl_FragColor = fColor; \n" + "out_color = fColor; \n" "} \n" "\n" }; @@ -358,6 +359,7 @@ public: ~Basic_viewer_qt() { + makeCurrent(); for (unsigned int i=0; i + + +#include +#include +namespace CGAL +{ +namespace Qt +{ +inline void init_ogl_context(int major, int minor) { + QSurfaceFormat fmt; +#ifdef Q_OS_MAC + if(major == 4) + { + fmt.setVersion(4, 1); + } + else + { + fmt.setVersion(major, minor); + } +#else + fmt.setVersion(major, minor); +#endif + fmt.setRenderableType(QSurfaceFormat::OpenGL); + fmt.setProfile(QSurfaceFormat::CoreProfile); + fmt.setOption(QSurfaceFormat::DebugContext); + QSurfaceFormat::setDefaultFormat(fmt); + + //for windows + QCoreApplication::setAttribute(::Qt::AA_UseDesktopOpenGL); + + //We set the locale to avoid any trouble with VTK + setlocale(LC_ALL, "C"); +} + +} //end Qt +} //end CGAL +#endif // CGAL_QT_CONTEXT_INITIALIZATION_H diff --git a/GraphicsView/include/CGAL/Qt/qglviewer_impl.h b/GraphicsView/include/CGAL/Qt/qglviewer_impl.h index 865f7b63a1f..7032ba5225e 100644 --- a/GraphicsView/include/CGAL/Qt/qglviewer_impl.h +++ b/GraphicsView/include/CGAL/Qt/qglviewer_impl.h @@ -217,16 +217,6 @@ void CGAL::QGLViewer::initializeGL() { || QCoreApplication::arguments().contains(QStringLiteral("--old"))) { - format.setDepthBufferSize(24); - format.setStencilBufferSize(8); - format.setVersion(2,0); - format.setRenderableType(QSurfaceFormat::OpenGLES); - format.setSamples(0); - format.setOption(QSurfaceFormat::DebugContext); - QSurfaceFormat::setDefaultFormat(format); - - needNewContext(); - qDebug()<<"GL 4.3 context initialization failed. "; is_ogl_4_3 = false; } else diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_demo.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_demo.cpp index 42713752435..cd31d859217 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_demo.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_demo.cpp @@ -14,6 +14,7 @@ #include #include #include +#include // Global random CGAL::Random myrandom; @@ -23,15 +24,12 @@ int main(int argc, char** argv) // std::cout<<"Size of dart: "<= QT_VERSION_CHECK(5, 3, 0)) - application.setAttribute(Qt::AA_UseDesktopOpenGL); -#endif // Import resources from libCGALQt5 // See https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE diff --git a/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h b/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h index db5a49f847f..b6b89a1b416 100644 --- a/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h +++ b/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -43,15 +43,15 @@ typedef Local_kernel::Vector_3 Local_vector; //Vertex source code const char vertex_source_mono[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" - "attribute highp vec3 normal;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" + "in highp vec3 normal;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" + "out highp vec4 fP; \n" + "out highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -62,17 +62,17 @@ const char vertex_source_mono[] = const char vertex_source_color[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" - "attribute highp vec3 normal;\n" - "attribute highp vec3 color;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" + "in highp vec3 normal;\n" + "in highp vec3 color;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" - "varying highp vec4 fColor; \n" + "out highp vec4 fP; \n" + "out highp vec3 fN; \n" + "out highp vec4 fColor; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -85,15 +85,16 @@ const char vertex_source_color[] = //Vertex source code const char fragment_source_mono[] = { - "#version 120 \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" + "#version 150 \n" + "in highp vec4 fP; \n" + "in highp vec3 fN; \n" "uniform highp vec4 color; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" "uniform highp vec4 light_spec; \n" "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" + "out highp vec4 out_color; \n" "void main(void) { \n" @@ -108,22 +109,23 @@ const char fragment_source_mono[] = " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n" " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" - "gl_FragColor = light_amb*color + diffuse ; \n" + "out_color = light_amb*color + diffuse ; \n" "} \n" "\n" }; const char fragment_source_color[] = { - "#version 120 \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" - "varying highp vec4 fColor; \n" + "#version 150 \n" + "in highp vec4 fP; \n" + "in highp vec3 fN; \n" + "in highp vec4 fColor; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" "uniform highp vec4 light_spec; \n" "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" + "out highp vec4 out_color; \n" "void main(void) { \n" @@ -138,7 +140,7 @@ const char fragment_source_color[] = " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" - "gl_FragColor = light_amb*fColor + diffuse ; \n" + "out_color = light_amb*fColor + diffuse ; \n" "} \n" "\n" }; @@ -146,8 +148,8 @@ const char fragment_source_color[] = //Vertex source code const char vertex_source_p_l[] = { - "#version 120 \n" - "attribute highp vec4 vertex;\n" + "#version 150 \n" + "in highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "void main(void)\n" "{\n" @@ -157,10 +159,11 @@ const char vertex_source_p_l[] = //Vertex source code const char fragment_source_p_l[] = { - "#version 120 \n" + "#version 150 \n" "uniform highp vec4 color; \n" + "out highp vec4 out_color; \n" "void main(void) { \n" - "gl_FragColor = color; \n" + "out_color = color; \n" "} \n" "\n" }; @@ -194,7 +197,7 @@ typename K::Vector_3 compute_normal_of_face(const std::vector #ifdef CGAL_USE_BASIC_VIEWER +#include #include #include @@ -405,6 +406,7 @@ void draw(const CGAL_LCC_TYPE& alcc, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"lccviewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Nef_3/include/CGAL/draw_nef_3.h b/Nef_3/include/CGAL/draw_nef_3.h index da8e01bacc8..bcdb6c61ae3 100644 --- a/Nef_3/include/CGAL/draw_nef_3.h +++ b/Nef_3/include/CGAL/draw_nef_3.h @@ -18,6 +18,7 @@ #ifdef CGAL_USE_BASIC_VIEWER +#include #include #include #include @@ -253,6 +254,7 @@ void draw(const CGAL_NEF3_TYPE &anef, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc = 1; const char *argv[2] = {"nef_polyhedron_viewer", "\0"}; QApplication app(argc, const_cast(argv)); diff --git a/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h index 909b38c0675..e4859ea033f 100644 --- a/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h @@ -17,6 +17,7 @@ #ifdef CGAL_USE_BASIC_VIEWER +#include #include #include @@ -260,6 +261,7 @@ void draw(const CGAL_P2T2_TYPE& ap2t2, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"p2t2_viewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.h b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.h index 41d4311ebe8..32f3926c802 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.h +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.h @@ -76,6 +76,7 @@ public: } ~Scene() { + ui->viewer->makeCurrent(); for(int i=0; i<24; i++) buffers[i].destroy(); for(int i=0; i<12; i++) diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/periodic_3_triangulation_3_demo.cpp b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/periodic_3_triangulation_3_demo.cpp index c93f4155487..2cf672fdb48 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/periodic_3_triangulation_3_demo.cpp +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/periodic_3_triangulation_3_demo.cpp @@ -1,9 +1,11 @@ #include "MainWindow.h" #include +#include int main(int argc, char *argv[]) { + CGAL::Qt::init_ogl_context(2,1); QApplication a(argc, argv); MainWindow w; //w.ui->setupUi(w); diff --git a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Periodic_Lloyd_3.cpp b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Periodic_Lloyd_3.cpp index 75f1f8ee396..ae0074e0bcc 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Periodic_Lloyd_3.cpp +++ b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Periodic_Lloyd_3.cpp @@ -1,18 +1,17 @@ #include "MainWindow.h" #include #include +#include int main(int argc, char** argv) { - QApplication application(argc,argv); + CGAL::Qt::init_ogl_context(2, 1); + + QApplication application(argc,argv); application.setOrganizationDomain("inria.fr"); application.setOrganizationName("INRIA"); application.setApplicationName("3D Periodic Lloyd"); - //for windows -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) - application.setAttribute(Qt::AA_UseDesktopOpenGL); -#endif // Import resources from libCGAL (QT5). // See https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE diff --git a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.h b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.h index 1ea4397cf4c..7ba3534a6d2 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.h +++ b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.h @@ -27,6 +27,7 @@ public: {} ~Viewer() { + makeCurrent(); for(int i=0; i<4; i++) { buffers[i].destroy(); diff --git a/Point_set_3/include/CGAL/draw_point_set_3.h b/Point_set_3/include/CGAL/draw_point_set_3.h index de9548c6b1b..510ba937a0c 100644 --- a/Point_set_3/include/CGAL/draw_point_set_3.h +++ b/Point_set_3/include/CGAL/draw_point_set_3.h @@ -35,6 +35,7 @@ void draw(const PS& aps); #ifdef CGAL_USE_BASIC_VIEWER +#include #include #include @@ -100,6 +101,7 @@ void draw(const Point_set_3& apointset, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"point_set_viewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Polygon/include/CGAL/draw_polygon_2.h b/Polygon/include/CGAL/draw_polygon_2.h index 0f75db09b7c..60522c9263d 100644 --- a/Polygon/include/CGAL/draw_polygon_2.h +++ b/Polygon/include/CGAL/draw_polygon_2.h @@ -38,7 +38,7 @@ void draw(const P& ap); #endif #ifdef CGAL_USE_BASIC_VIEWER - +#include #include #include @@ -122,6 +122,7 @@ void draw(const CGAL::Polygon_2& ap2, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"t2_viewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Polygon/include/CGAL/draw_polygon_with_holes_2.h b/Polygon/include/CGAL/draw_polygon_with_holes_2.h index 35f98928c7e..0781eb883f7 100644 --- a/Polygon/include/CGAL/draw_polygon_with_holes_2.h +++ b/Polygon/include/CGAL/draw_polygon_with_holes_2.h @@ -37,7 +37,7 @@ void draw(const PH& aph); #endif #ifdef CGAL_USE_BASIC_VIEWER - +#include #include #include @@ -138,6 +138,7 @@ void draw(const CGAL::Polygon_with_holes_2& ap2, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"t2_viewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index f7811021212..f62ea120333 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -380,6 +380,7 @@ Viewer::Viewer(QWidget* parent, Viewer::~Viewer() { + makeCurrent(); QSettings viewer_settings; viewer_settings.setValue("cam_pos", QString("%1,%2,%3") diff --git a/Polyhedron/include/CGAL/draw_polyhedron.h b/Polyhedron/include/CGAL/draw_polyhedron.h index d13a66dbbec..e5220aa58f3 100644 --- a/Polyhedron/include/CGAL/draw_polyhedron.h +++ b/Polyhedron/include/CGAL/draw_polyhedron.h @@ -16,7 +16,7 @@ #include #ifdef CGAL_USE_BASIC_VIEWER - +#include #include #include #include @@ -45,6 +45,7 @@ void draw(const CGAL_POLY_TYPE& apoly, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=2; const char* argv[2]={"polyhedron_viewer","--old"}; QApplication app(argc,const_cast(argv)); diff --git a/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp index 0676b175517..13dde23e2a2 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp +++ b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp @@ -48,6 +48,7 @@ MainWindow::MainWindow(QWidget* parent) MainWindow::~MainWindow() { + m_pViewer->makeCurrent(); delete ui; } diff --git a/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.cpp b/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.cpp index f1b7a78b624..04b8cf11f13 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.cpp +++ b/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.cpp @@ -18,9 +18,12 @@ #include "MainWindow.h" #include #include +#include int main(int argc, char **argv) { + CGAL::Qt::init_ogl_context(2, 1); + QApplication app(argc, argv); app.setOrganizationDomain("inria.fr"); app.setOrganizationName("INRIA"); diff --git a/Principal_component_analysis/demo/Principal_component_analysis/Scene.cpp b/Principal_component_analysis/demo/Principal_component_analysis/Scene.cpp index e75392cb62d..a4c60dd0a54 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/Scene.cpp +++ b/Principal_component_analysis/demo/Principal_component_analysis/Scene.cpp @@ -28,6 +28,7 @@ Scene::Scene() Scene::~Scene() { + delete m_pPolyhedron; } diff --git a/Surface_mesh/include/CGAL/draw_surface_mesh.h b/Surface_mesh/include/CGAL/draw_surface_mesh.h index f3866938526..c15a7a5028e 100644 --- a/Surface_mesh/include/CGAL/draw_surface_mesh.h +++ b/Surface_mesh/include/CGAL/draw_surface_mesh.h @@ -32,6 +32,7 @@ void draw(const SM& asm); #ifdef CGAL_USE_BASIC_VIEWER +#include #include #include namespace CGAL @@ -51,6 +52,7 @@ void draw(const Surface_mesh& amesh, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"surface_mesh_viewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h b/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h index 96cad072369..726cf03efd1 100644 --- a/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h +++ b/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h @@ -21,6 +21,7 @@ #ifdef CGAL_USE_BASIC_VIEWER +#include #include namespace CGAL { @@ -409,6 +410,7 @@ void draw(const Mesh& alcc, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"lccviewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Triangulation_2/include/CGAL/draw_triangulation_2.h b/Triangulation_2/include/CGAL/draw_triangulation_2.h index 60d15734b2f..fef579d2ff0 100644 --- a/Triangulation_2/include/CGAL/draw_triangulation_2.h +++ b/Triangulation_2/include/CGAL/draw_triangulation_2.h @@ -17,6 +17,7 @@ #ifdef CGAL_USE_BASIC_VIEWER +#include #include #include @@ -144,6 +145,7 @@ void draw(const CGAL_T2_TYPE& at2, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"t2_viewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Triangulation_3/demo/Triangulation_3/T3_demo.cpp b/Triangulation_3/demo/Triangulation_3/T3_demo.cpp index 7b70c57dd07..aef465639ff 100644 --- a/Triangulation_3/demo/Triangulation_3/T3_demo.cpp +++ b/Triangulation_3/demo/Triangulation_3/T3_demo.cpp @@ -13,18 +13,17 @@ #include "MainWindow.h" #include +#include int main(int argc, char** argv) { + CGAL::Qt::init_ogl_context(2, 1); + QApplication app(argc, argv); app.setOrganizationDomain("inria.fr"); app.setOrganizationName("INRIA"); app.setApplicationName("3D Triangulation Demo"); - //for windows -#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)) - app.setAttribute(Qt::AA_UseDesktopOpenGL); -#endif MainWindow mw; mw.show(); diff --git a/Triangulation_3/include/CGAL/draw_triangulation_3.h b/Triangulation_3/include/CGAL/draw_triangulation_3.h index 11d25a28f29..0c778ca08a7 100644 --- a/Triangulation_3/include/CGAL/draw_triangulation_3.h +++ b/Triangulation_3/include/CGAL/draw_triangulation_3.h @@ -17,6 +17,7 @@ #ifdef CGAL_USE_BASIC_VIEWER +#include #include #include @@ -150,6 +151,7 @@ void draw(const CGAL_T3_TYPE& at3, if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc=1; const char* argv[2]={"t3_viewer","\0"}; QApplication app(argc,const_cast(argv)); diff --git a/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h b/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h index 5e32e12d3d4..66f7d364293 100644 --- a/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h +++ b/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h @@ -17,6 +17,7 @@ #ifdef CGAL_USE_BASIC_VIEWER +#include #include #include #include @@ -316,6 +317,7 @@ void draw(const CGAL_VORONOI_TYPE &av2, #endif if (!cgal_test_suite) { + CGAL::Qt::init_ogl_context(4,3); int argc = 1; const char *argv[2] = {"voronoi_2_viewer", "\0"}; QApplication app(argc, const_cast(argv));