From 156b267d85dd2f8a5d92c944716138a501c7cb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 7 Aug 2015 14:37:57 +0200 Subject: [PATCH 01/35] add a dependency on the Qt5::QSQLiteDriverPlugin --- .../demo/Periodic_3_triangulation_3/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt index 1da698a23fd..21db624457d 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt @@ -14,7 +14,7 @@ find_package(CGAL COMPONENTS Qt5) include( ${CGAL_USE_FILE} ) # Find Qt5 itself -find_package(Qt5 QUIET COMPONENTS Xml OpenGL Help Core) +find_package(Qt5 COMPONENTS Xml OpenGL Help Core Sql) # Find OpenGL find_package(OpenGL) @@ -25,7 +25,7 @@ if(Qt5_FOUND) find_package(QGLViewer) endif(Qt5_FOUND) -if (CGAL_FOUND AND CGAL_Qt5_FOUND AND OPENGL_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND TARGET Qt5::qcollectiongenerator) +if (CGAL_FOUND AND CGAL_Qt5_FOUND AND OPENGL_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND TARGET Qt5::qcollectiongenerator AND TARGET Qt5::QSQLiteDriverPlugin) include_directories( ${QGLVIEWER_INCLUDE_DIR} ) @@ -97,6 +97,10 @@ else () set(PERIODIC_TRIANGULATION_MISSING_DEPS "qcollectiongenerator, ${PERIODIC_TRIANGULATION_MISSING_DEPS}") endif() + if (NOT TARGET Qt5::QSQLiteDriverPlugin) + set(PERIODIC_TRIANGULATION_MISSING_DEPS "SQLite driver plugin, ${PERIODIC_TRIANGULATION_MISSING_DEPS}") + endif() + message(STATUS "NOTICE: This demo requires ${PERIODIC_TRIANGULATION_MISSING_DEPS}and will not be compiled.") endif () From 16da0d60ea39f6360541efad60468dba8b25e4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 7 Aug 2015 14:40:01 +0200 Subject: [PATCH 02/35] readd QUIET to be consistant with other packages --- .../demo/Periodic_3_triangulation_3/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt index 21db624457d..a0d4b6416ad 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt @@ -14,7 +14,7 @@ find_package(CGAL COMPONENTS Qt5) include( ${CGAL_USE_FILE} ) # Find Qt5 itself -find_package(Qt5 COMPONENTS Xml OpenGL Help Core Sql) +find_package(Qt5 QUIET COMPONENTS Xml OpenGL Help Core Sql) # Find OpenGL find_package(OpenGL) From 999c123be1e1653638135711f7445511d094f331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 7 Aug 2015 14:47:00 +0200 Subject: [PATCH 03/35] document use of qcollectiongenerator and sqlite plugin driver --- Documentation/doc/Documentation/Installation.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/doc/Documentation/Installation.txt b/Documentation/doc/Documentation/Installation.txt index 9864272873d..f97e1a58731 100644 --- a/Documentation/doc/Documentation/Installation.txt +++ b/Documentation/doc/Documentation/Installation.txt @@ -423,7 +423,8 @@ it from `http://qt-project.org/`. Older demos of \cgal use libCGAL_Qt3 and \sc{Qt}3, while newer and newly developed demos require libCGAL_Qt5 and \sc{Qt}5. The exhaustive list of \sc{Qt}5 components used in demos is: -`Core`, `Gui`, `Help`, `OpenGL`, `Script`, `ScriptTools`, `Svg`, `Widgets` and `Xml`. +`Core`, `Gui`, `Help`, `OpenGL`, `Script`, `ScriptTools`, `Svg`, `Widgets`, +`qcollectiongenerator` (with `sqlite` driver plugin) and `Xml`. Having \sc{Qt}5 version 5.3.0 is recommended. From 57b8f164f411641a63f61a7bc4004648f49c4cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 7 Aug 2015 15:56:40 +0200 Subject: [PATCH 04/35] change the plane definition to match the detection of parallel planes --- .../Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp index a8825d7659b..7fb2f93a929 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp @@ -229,6 +229,7 @@ void Polyhedron_demo_polyhedron_slicer_plugin::on_Generate_button_clicked() get_base_1_2(bases); // no need to check since we call on_Update_plane_button_clicked Epic_kernel::Vector_3 base_1(bases[0], bases[1], bases[2]); Epic_kernel::Vector_3 base_2(bases[3], bases[4], bases[5]); + const Epic_kernel::Vector_3 normal = CGAL::cross_product(base_1, base_2); // get distance between planes bool to_double_ok = true; @@ -255,7 +256,7 @@ void Polyhedron_demo_polyhedron_slicer_plugin::on_Generate_button_clicked() //Epic_kernel::Plane_3 plane(n[0], n[1], n[2], - n * new_pos); Epic_kernel::Point_3 new_pos_cgal(new_pos[0], new_pos[1], new_pos[2]); - Epic_kernel::Plane_3 plane(new_pos_cgal, new_pos_cgal + base_1, new_pos_cgal + base_2); + Epic_kernel::Plane_3 plane(new_pos_cgal, normal); if(!CGAL::do_intersect(cgal_bbox, plane)) { if(dir == -1) { break; } From 71b0fd8d3169fa3f294ae2446ec26bd61262072a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 08:46:09 +0200 Subject: [PATCH 05/35] Replaced the OpenGL 3 3 Core context by a 2_1 context. --- AABB_tree/demo/AABB_tree/Scene.cpp | 3 +-- AABB_tree/demo/AABB_tree/Scene.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index 96ebef00ecf..0e184a84ae0 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include #include "Viewer.h" @@ -1318,7 +1317,7 @@ void Scene::deactivate_cutting_plane() } void Scene::initGL(Viewer * /* viewer */) { - gl = new QOpenGLFunctions_3_3_Core(); + gl = new QOpenGLFunctions_2_1(); if(!gl->initializeOpenGLFunctions()) { qFatal("ERROR : OpenGL Functions not initialized. Check your OpenGL Verison (should be >=3.3)"); diff --git a/AABB_tree/demo/AABB_tree/Scene.h b/AABB_tree/demo/AABB_tree/Scene.h index 450559af232..1175ad4700a 100644 --- a/AABB_tree/demo/AABB_tree/Scene.h +++ b/AABB_tree/demo/AABB_tree/Scene.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,7 +86,7 @@ public: private: // member data - QOpenGLFunctions_3_3_Core *gl; + QOpenGLFunctions_2_1 *gl; Bbox m_bbox; Polyhedron *m_pPolyhedron; std::list m_points; From 7d220d3da86ecfc8b0ad03fba26ca9300d1e26ab Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 08:59:54 +0200 Subject: [PATCH 06/35] Context 3.3 Core changed into 2.1 --- Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp | 12 ++++++------ Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h | 4 ++-- GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp index e276df8661e..dd13883e3df 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 330 \n" + "#version 120 \n" "in highp vec4 vertex;\n" "in highp vec3 normal;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -47,7 +47,7 @@ void Viewer::compile_shaders() //Vertex source code const char fragment_source[] = { - "#version 330 \n" + "#version 120 \n" "in highp vec4 fP; \n" "in highp vec3 fN; \n" "uniform highp vec4 color; \n" @@ -105,7 +105,7 @@ rendering_program.bind(); //Vertex source code const char vertex_source_points[] = { - "#version 330 \n" + "#version 120 \n" "in highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" @@ -117,7 +117,7 @@ const char vertex_source_points[] = //Vertex source code const char fragment_source_points[] = { - "#version 330 \n" + "#version 120 \n" "uniform highp vec4 color; \n" "void main(void) { \n" diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h index a5cc54aa490..5280aa622b3 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.h @@ -3,13 +3,13 @@ #include "typedefs.h" #include -#include +#include #include #include #include -class Viewer : public QGLViewer, protected QOpenGLFunctions_3_3_Core{ +class Viewer : public QGLViewer, protected QOpenGLFunctions_2_1{ Q_OBJECT CGAL::Timer timer; diff --git a/GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h b/GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h index 514b6e8007e..7e321582f36 100644 --- a/GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h +++ b/GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h @@ -27,7 +27,7 @@ inline QGLContext* createOpenGLContext() { QOpenGLContext *context = new QOpenGLContext(); QSurfaceFormat format; - format.setVersion(3,3); + format.setVersion(2,1); format.setProfile(QSurfaceFormat::CompatibilityProfile); context->setFormat(format); return QGLContext::fromOpenGLContext(context); From 61072a8e75194963f284e9eb9abadcfafcce7a84 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 09:04:01 +0200 Subject: [PATCH 07/35] Clean-up --- AABB_tree/demo/AABB_tree/Scene.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index 0e184a84ae0..4b4bb4e69af 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -91,9 +91,8 @@ void Scene::compile_shaders() //Vertex source code const char vertex_source[] = { - // "#version 330 \n" + "#version 120 \n" "attribute highp vec4 vertex;\n" - // "uniform highp mat4 ortho_matrix;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 f_matrix;\n" "void main(void)\n" @@ -104,7 +103,7 @@ void Scene::compile_shaders() //Vertex source code const char fragment_source[] = { - //"#version 330 \n" + "#version 120 \n" "uniform highp vec4 color; \n" "void main(void) { \n" "gl_FragColor = color; \n" @@ -140,7 +139,7 @@ void Scene::compile_shaders() //Vertex source code const char tex_vertex_source[] = { - // "#version 330 \n" + "#version 120 \n" "attribute highp vec4 vertex;\n" "attribute highp vec2 tex_coord; \n" "uniform highp mat4 mvp_matrix;\n" @@ -155,7 +154,7 @@ void Scene::compile_shaders() //Vertex source code const char tex_fragment_source[] = { - //"#version 330 \n" + "#version 120 \n" "uniform sampler2D texture;\n" "varying highp vec2 texc;\n" "void main(void) { \n" From 8680431afc5417c5fb71f191c72758321c5fe4c3 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 10:02:30 +0200 Subject: [PATCH 08/35] Mesa Fix - Replaced the 3.3 context by a 2.1 context. - Added the extension search for instanced rendering. - Added an alternate rendering with points instead of spheres for the case the extensions cannot be found. --- .../demo/Circular_kernel_3/Viewer.cpp | 214 ++++++++++++++---- .../demo/Circular_kernel_3/Viewer.h | 9 +- 2 files changed, 172 insertions(+), 51 deletions(-) diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp index 858aa0ab7af..b2a3e9ab4e9 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp +++ b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp @@ -4,9 +4,12 @@ #include #include #include + + Viewer::Viewer(QWidget* parent ) : QGLViewer(CGAL::Qt::createOpenGLContext(),parent) { + extension_is_found = false; } void Viewer::compile_shaders() @@ -29,16 +32,16 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" - "in highp vec4 center;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec4 center;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -49,9 +52,9 @@ void Viewer::compile_shaders() //Vertex source code const char fragment_source[] = { - "#version 330 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" + "#version 120 \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "uniform highp vec4 color; \n" "uniform vec4 light_pos; \n" "uniform vec4 light_diff; \n" @@ -101,6 +104,59 @@ void Viewer::compile_shaders() std::cerr<<"linking Program FAILED"<compileSourceCode(vertex_source_no_ext)) + { + std::cerr<<"Compiling vertex source FAILED"<compileSourceCode(fragment_source_no_ext)) + { + std::cerr<<"Compiling fragmentsource FAILED"<(pos_sphere_inter.size()*sizeof(float))); - vertexLocation[2] = rendering_program.attributeLocation("vertex"); - rendering_program.bind(); - rendering_program.enableAttributeArray(vertexLocation[2]); - rendering_program.setAttributeBuffer(vertexLocation[2],GL_FLOAT,0,3); - buffers[6].release(); - //normals of the sphere - buffers[7].bind(); - buffers[7].allocate(normals_inter.data(), - static_cast(normals_inter.size()*sizeof(float))); - normalsLocation[2] = rendering_program.attributeLocation("normal"); - rendering_program.bind(); - rendering_program.enableAttributeArray(normalsLocation[2]); - rendering_program.setAttributeBuffer(normalsLocation[2],GL_FLOAT,0,3); - buffers[7].release(); - //center of the sphere - buffers[8].bind(); - buffers[8].allocate(pos_points.data(), - static_cast(pos_points.size()*sizeof(float))); - centerLocation = rendering_program.attributeLocation("center"); - rendering_program.bind(); - rendering_program.enableAttributeArray(centerLocation); - rendering_program.setAttributeBuffer(centerLocation,GL_FLOAT,0,3); - buffers[8].release(); - glVertexAttribDivisor(centerLocation, 1); - glVertexAttribDivisor(normalsLocation[1], 0); + if(extension_is_found) + { + //points of the sphere + buffers[6].bind(); + buffers[6].allocate(pos_sphere_inter.data(), + static_cast(pos_sphere_inter.size()*sizeof(float))); + vertexLocation[2] = rendering_program.attributeLocation("vertex"); + rendering_program.bind(); + rendering_program.enableAttributeArray(vertexLocation[2]); + rendering_program.setAttributeBuffer(vertexLocation[2],GL_FLOAT,0,3); + buffers[6].release(); + //normals of the sphere + buffers[7].bind(); + buffers[7].allocate(normals_inter.data(), + static_cast(normals_inter.size()*sizeof(float))); + normalsLocation[2] = rendering_program.attributeLocation("normal"); + rendering_program.bind(); + rendering_program.enableAttributeArray(normalsLocation[2]); + rendering_program.setAttributeBuffer(normalsLocation[2],GL_FLOAT,0,3); + buffers[7].release(); + //center of the sphere + buffers[8].bind(); + buffers[8].allocate(pos_points.data(), + static_cast(pos_points.size()*sizeof(float))); + centerLocation = rendering_program.attributeLocation("center"); + rendering_program.bind(); + rendering_program.enableAttributeArray(centerLocation); + rendering_program.setAttributeBuffer(centerLocation,GL_FLOAT,0,3); + buffers[8].release(); + + glVertexAttribDivisor(centerLocation, 1); + glVertexAttribDivisor(normalsLocation[1], 0); + } + else + { + //points of the sphere + buffers[6].bind(); + buffers[6].allocate(pos_points.data(), + static_cast(pos_points.size()*sizeof(float))); + rendering_program_no_ext.bind(); + rendering_program_no_ext.enableAttributeArray("vertex"); + rendering_program_no_ext.setAttributeBuffer("vertex",GL_FLOAT,0,3); + buffers[6].release(); + } vao[2].release(); @@ -693,8 +770,14 @@ void Viewer::attrib_buffers(QGLViewer* viewer) rendering_program.setUniformValue(mvpLocation, mvpMatrix); rendering_program.setUniformValue(mvLocation, mvMatrix); - rendering_program.release(); + if(!extension_is_found) + { + rendering_program_no_ext.bind(); + rendering_program_no_ext.setUniformValue("mvp_matrix", mvpMatrix); + rendering_program_no_ext.release(); + } + } @@ -708,18 +791,34 @@ void Viewer::draw() rendering_program.bind(); color.setRgbF(1.0f, 1.0f, 1.0f); rendering_program.setUniformValue(colorLocation, color); - glDrawArraysInstanced(GL_TRIANGLES, 0, static_cast(pos_sphere.size()/3), 1); + if(extension_is_found) + glDrawArraysInstanced(GL_TRIANGLES, 0, static_cast(pos_sphere.size()/3), 1); + else + glDrawArrays(GL_TRIANGLES, 0, static_cast(pos_sphere.size()/3)); rendering_program.release(); vao[0].release(); //intersection vao[2].bind(); attrib_buffers(this); - rendering_program.bind(); color.setRgbF(0.0f, 1.0f, 0.0f); - rendering_program.setUniformValue(colorLocation, color); - glDrawArraysInstanced(GL_TRIANGLES, 0, static_cast(pos_sphere_inter.size()/3), static_cast(pos_points.size()/3)); - rendering_program.release(); + if(extension_is_found) + { + rendering_program.bind(); + rendering_program.setUniformValue(colorLocation, color); + glDrawArraysInstanced(GL_TRIANGLES, 0, static_cast(pos_points.size()/3), static_cast(pos_points.size()/3)); + rendering_program.release(); + } + else + { + glPointSize(4.0f); + rendering_program_no_ext.bind(); + rendering_program_no_ext.setUniformValue(colorLocation, color); + glDrawArrays(GL_POINTS, 0, static_cast(pos_points.size()/3)); + rendering_program_no_ext.release(); + glPointSize(1.0f); + } + vao[2].release(); //circles @@ -738,6 +837,24 @@ void Viewer::draw() void Viewer::init() { + + glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDARBPROC)this->context()->getProcAddress("glDrawArraysInstancedARB"); + if(!glDrawArraysInstanced) + { + qDebug()<<"glDrawArraysInstancedARB : extension not found. Spheres will be displayed as points."; + extension_is_found = false; + } + else + extension_is_found = true; + + glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORARBPROC)this->context()->getProcAddress("glVertexAttribDivisorARB"); + if(!glDrawArraysInstanced) + { + qDebug()<<"glVertexAttribDivisorARB : extension not found. Spheres will be displayed as points."; + extension_is_found = false; + } + else + extension_is_found = true; compile_shaders(); compute_elements(); initialize_buffers(); @@ -748,6 +865,7 @@ void Viewer::init() glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); + } template diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h index 81b20ba1746..f0ba2f3e78e 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h +++ b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h @@ -1,14 +1,14 @@ #include #include -#include +#include #include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel EPIC; -class Viewer : public QGLViewer, QOpenGLFunctions_3_3_Core +class Viewer : public QGLViewer, QOpenGLFunctions_2_1 { public: Viewer(QWidget* parent = 0); @@ -29,7 +29,7 @@ private: int mvLocation; int colorLocation; int lightLocation[5]; - + bool extension_is_found; std::vector pos_points; std::vector pos_lines; @@ -43,6 +43,9 @@ private: QOpenGLBuffer buffers[9]; QOpenGLVertexArrayObject vao[3]; QOpenGLShaderProgram rendering_program; + QOpenGLShaderProgram rendering_program_no_ext; + PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; + PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; void initialize_buffers(); void compute_elements(); From 3a5d0a79fc798f2b268c442f1ac51b77636646af Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 10:11:29 +0200 Subject: [PATCH 09/35] Mesa Fix - Replaced the 3.3 context by a 2.1 context - Set the shaders version to 120 --- .../demo/Linear_cell_complex/Viewer.cpp | 28 +++++++++---------- .../demo/Linear_cell_complex/Viewer.h | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp index cf92a3804e3..0070d881bd3 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp @@ -232,17 +232,17 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 140 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" - "in highp vec4 color;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec4 color;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" - "out highp vec4 fColor; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" + "varying highp vec4 fColor; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -254,10 +254,10 @@ void Viewer::compile_shaders() //Vertex source code const char fragment_source[] = { - "#version 140 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" - "in highp vec4 fColor; \n" + "#version 120 \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" + "varying highp vec4 fColor; \n" "uniform vec4 light_pos; \n" "uniform vec4 light_diff; \n" "uniform vec4 light_spec; \n" @@ -310,8 +310,8 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source_p_l[] = { - "#version 140 \n" - "in highp vec4 vertex;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "void main(void)\n" "{\n" @@ -321,7 +321,7 @@ void Viewer::compile_shaders() //Vertex source code const char fragment_source_p_l[] = { - "#version 140 \n" + "#version 120 \n" "uniform highp vec4 color; \n" "void main(void) { \n" "gl_FragColor = color; \n" diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.h b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.h index e5dc086f76f..c03977f900a 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.h +++ b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.h @@ -25,11 +25,11 @@ #include #include -#include +#include #include #include #include -class Viewer : public QGLViewer, QOpenGLFunctions_3_3_Core +class Viewer : public QGLViewer, QOpenGLFunctions_2_1 { Q_OBJECT From d39d336461cbc307aa6d60e1b5f406a34c2653fc Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 10:31:26 +0200 Subject: [PATCH 10/35] Mesa Fix - Changed 3.3 context in 2.1 context - set shaders version to 120 --- Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp | 26 +++++++++---------- .../Mesh_3/Scene_implicit_function_item.cpp | 20 +++++++------- Mesh_3/demo/Mesh_3/Scene_polygon_soup.cpp | 16 ++++++------ Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp | 16 ++++++------ .../Mesh_3/Scene_segmented_image_item.cpp | 22 ++++++++-------- .../demo/Mesh_3/Volume_plane_intersection.cpp | 6 ++--- Mesh_3/demo/Mesh_3/include/CGAL_demo/Viewer.h | 4 +-- 7 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp b/Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp index cc894397138..1b82b6b3d63 100644 --- a/Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp +++ b/Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp @@ -51,16 +51,16 @@ void Scene_c3t3_item::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" - "in highp vec3 inColor; \n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec3 inColor; \n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" - "out highp vec4 color; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" + "varying highp vec4 color; \n" "void main(void)\n" "{\n" " color = vec4(inColor, 1.0); \n" @@ -73,9 +73,9 @@ void Scene_c3t3_item::compile_shaders() const char fragment_source[] = { "#version 330 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" - "in vec4 color; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" + "varying vec4 color; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" "uniform highp vec4 light_spec; \n" @@ -130,8 +130,8 @@ void Scene_c3t3_item::compile_shaders() //Vertex source code const char vertex_source_grid[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 f_matrix; \n" @@ -143,7 +143,7 @@ void Scene_c3t3_item::compile_shaders() //Fragment source code const char fragment_source_grid[] = { - "#version 330 \n" + "#version 120 \n" "uniform vec4 color; \n" "void main(void) { \n" "gl_FragColor = color; \n" diff --git a/Mesh_3/demo/Mesh_3/Scene_implicit_function_item.cpp b/Mesh_3/demo/Mesh_3/Scene_implicit_function_item.cpp index e8690bcf679..2b89086350e 100644 --- a/Mesh_3/demo/Mesh_3/Scene_implicit_function_item.cpp +++ b/Mesh_3/demo/Mesh_3/Scene_implicit_function_item.cpp @@ -68,8 +68,8 @@ void Scene_implicit_function_item::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "void main(void)\n" @@ -80,7 +80,7 @@ void Scene_implicit_function_item::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 330 \n" + "#version 120 \n" "uniform vec4 color; \n" "void main(void) { \n" "gl_FragColor = color; \n" @@ -115,24 +115,24 @@ void Scene_implicit_function_item::compile_shaders() //Vertex source code const char tex_vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec2 tex_coord; \n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec2 tex_coord; \n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 f_matrix;\n" - "out highp vec2 texc;\n" + "varying highp vec2 texc;\n" "void main(void)\n" "{\n" " gl_Position = mvp_matrix * f_matrix * vertex;\n" " texc = tex_coord;\n" "}" }; - //Vertex source code + //Fragment source code const char tex_fragment_source[] = { - "#version 330 \n" + "#version 120 \n" "uniform sampler2D texture;\n" - "in highp vec2 texc;\n" + "varying highp vec2 texc;\n" "void main(void) { \n" "gl_FragColor = texture2D(texture, texc.st);\n" "} \n" diff --git a/Mesh_3/demo/Mesh_3/Scene_polygon_soup.cpp b/Mesh_3/demo/Mesh_3/Scene_polygon_soup.cpp index dcaaa23c337..9a2a9a14fdf 100644 --- a/Mesh_3/demo/Mesh_3/Scene_polygon_soup.cpp +++ b/Mesh_3/demo/Mesh_3/Scene_polygon_soup.cpp @@ -125,14 +125,14 @@ void Scene_polygon_soup::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -143,9 +143,9 @@ void Scene_polygon_soup::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 330 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" + "#version 120 \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "uniform vec4 color; \n" "uniform bool is_two_side; \n" "uniform highp vec4 light_pos; \n" diff --git a/Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp b/Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp index 6d410ba491e..c1e552e2311 100644 --- a/Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp +++ b/Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp @@ -54,14 +54,14 @@ void Scene_polyhedron_item::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -72,9 +72,9 @@ void Scene_polyhedron_item::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 330 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" + "#version 120 \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "uniform vec4 color; \n" "uniform bool is_two_side; \n" "uniform highp vec4 light_pos; \n" diff --git a/Mesh_3/demo/Mesh_3/Scene_segmented_image_item.cpp b/Mesh_3/demo/Mesh_3/Scene_segmented_image_item.cpp index 408c2e93ac1..a8d3c81a9d5 100644 --- a/Mesh_3/demo/Mesh_3/Scene_segmented_image_item.cpp +++ b/Mesh_3/demo/Mesh_3/Scene_segmented_image_item.cpp @@ -497,16 +497,16 @@ void Scene_segmented_image_item::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" - "in highp vec4 inColor;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec4 inColor;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" - "out highp vec4 color; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" + "varying highp vec4 color; \n" "void main(void)\n" "{\n" " color=inColor; \n" @@ -518,10 +518,10 @@ void Scene_segmented_image_item::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 330 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" - "in highp vec4 color; \n" + "#version 120 \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" + "varying highp vec4 color; \n" "uniform bool is_two_side; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" diff --git a/Mesh_3/demo/Mesh_3/Volume_plane_intersection.cpp b/Mesh_3/demo/Mesh_3/Volume_plane_intersection.cpp index 379f5585c39..c2b3891aad2 100644 --- a/Mesh_3/demo/Mesh_3/Volume_plane_intersection.cpp +++ b/Mesh_3/demo/Mesh_3/Volume_plane_intersection.cpp @@ -16,8 +16,8 @@ void Volume_plane_intersection::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 f_matrix; \n" "void main(void)\n" @@ -28,7 +28,7 @@ void Volume_plane_intersection::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 330 \n" + "#version 120 \n" "void main(void) { \n" "gl_FragColor = vec4(1.0,0.0,0.0,1.0); \n" "} \n" diff --git a/Mesh_3/demo/Mesh_3/include/CGAL_demo/Viewer.h b/Mesh_3/demo/Mesh_3/include/CGAL_demo/Viewer.h index 3e590acd239..9712cc45787 100644 --- a/Mesh_3/demo/Mesh_3/include/CGAL_demo/Viewer.h +++ b/Mesh_3/demo/Mesh_3/include/CGAL_demo/Viewer.h @@ -4,13 +4,13 @@ #include #include #include -#include +#include // forward declarations class QWidget; class Scene_draw_interface; -class VIEWER_EXPORT Viewer : public QGLViewer, public QOpenGLFunctions_3_3_Core { +class VIEWER_EXPORT Viewer : public QGLViewer, public QOpenGLFunctions_2_1 { Q_OBJECT From 4c37b2d80a3d016afcd780f8497756a21f364b50 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 11:00:31 +0200 Subject: [PATCH 11/35] Mesa Fix : - context set to 2.1 - shaders version set to 120 - instanced rendering managed with ARB extension - if extension cannot be found, the wireframe mode is forced. --- .../demo/Periodic_3_triangulation_3/Scene.cpp | 118 +++++++++++------- .../demo/Periodic_3_triangulation_3/Scene.h | 13 +- 2 files changed, 82 insertions(+), 49 deletions(-) diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp index e922b37f0f3..05486d54280 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp @@ -34,8 +34,8 @@ void Scene::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "void main(void)\n" "{\n" @@ -45,7 +45,7 @@ void Scene::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 330 \n" + "#version 120 \n" "uniform highp vec4 color; \n" "void main(void) { \n" "gl_FragColor = color; \n" @@ -82,15 +82,15 @@ void Scene::compile_shaders() //Vertex source code const char vertex_source_spheres[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" - "in highp vec4 center;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec4 center;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -101,9 +101,9 @@ void Scene::compile_shaders() //Fragment source code const char fragment_source_spheres[] = { - "#version 330 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" + "#version 120 \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" "uniform highp vec4 light_spec; \n" @@ -159,18 +159,18 @@ void Scene::compile_shaders() //Vertex source code const char vertex_source_cylinders[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" - "in highp vec4 transfo1;\n" - "in highp vec4 transfo2;\n" - "in highp vec4 transfo3;\n" - "in highp vec4 transfo4;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec4 transfo1;\n" + "attribute highp vec4 transfo2;\n" + "attribute highp vec4 transfo3;\n" + "attribute highp vec4 transfo4;\n" "mat4 transfo = mat4(transfo1, transfo2, transfo3, transfo4); \n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -488,8 +488,11 @@ void Scene::initialize_buffers() rendering_program_spheres.enableAttributeArray(centerLocation[0]); rendering_program_spheres.setAttributeBuffer(centerLocation[0],GL_FLOAT,0,3); buffers[0].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[3].release(); rendering_program_spheres.release(); @@ -538,13 +541,15 @@ void Scene::initialize_buffers() rendering_program_cylinders.setAttributeBuffer(centerLocation[4],GL_FLOAT,0,4); buffers[13].release(); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[1],1); + glVertexAttribDivisor(centerLocation[2],1); + glVertexAttribDivisor(centerLocation[3],1); + glVertexAttribDivisor(centerLocation[4],1); - glVertexAttribDivisor(centerLocation[1],1); - glVertexAttribDivisor(centerLocation[2],1); - glVertexAttribDivisor(centerLocation[3],1); - glVertexAttribDivisor(centerLocation[4],1); - - glVertexAttribDivisor(normalsLocation[1],0); + glVertexAttribDivisor(normalsLocation[1],0); + } vao[8].release(); vao[9].bind(); @@ -590,13 +595,15 @@ void Scene::initialize_buffers() rendering_program_cylinders.setAttributeBuffer(centerLocation[4],GL_FLOAT,0,4); buffers[18].release(); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[1],1); + glVertexAttribDivisor(centerLocation[2],1); + glVertexAttribDivisor(centerLocation[3],1); + glVertexAttribDivisor(centerLocation[4],1); - glVertexAttribDivisor(centerLocation[1],1); - glVertexAttribDivisor(centerLocation[2],1); - glVertexAttribDivisor(centerLocation[3],1); - glVertexAttribDivisor(centerLocation[4],1); - - glVertexAttribDivisor(normalsLocation[1],0); + glVertexAttribDivisor(normalsLocation[1],0); + } vao[9].release(); @@ -642,14 +649,15 @@ void Scene::initialize_buffers() rendering_program_cylinders.setAttributeBuffer(centerLocation[4],GL_FLOAT,0,4); buffers[22].release(); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[1],1); + glVertexAttribDivisor(centerLocation[2],1); + glVertexAttribDivisor(centerLocation[3],1); + glVertexAttribDivisor(centerLocation[4],1); - glVertexAttribDivisor(centerLocation[1],1); - glVertexAttribDivisor(centerLocation[2],1); - glVertexAttribDivisor(centerLocation[3],1); - glVertexAttribDivisor(centerLocation[4],1); - - glVertexAttribDivisor(normalsLocation[1],0); - + glVertexAttribDivisor(normalsLocation[1],0); + } vao[10].release(); rendering_program_cylinders.release(); @@ -727,6 +735,25 @@ void Scene::init() { // undo from QGLViewer internal initializeGL function // glDisable(GL_COLOR_MATERIAL); initializeOpenGLFunctions(); + glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDARBPROC)ui->viewer->context()->getProcAddress("glDrawArraysInstancedARB"); + if(!glDrawArraysInstanced) + { + qDebug()<<"glDrawArraysInstancedARB : extension not found. Wireframe mode will be forced."; + extension_is_found = false; + } + else + extension_is_found = true; + + glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORARBPROC)ui->viewer->context()->getProcAddress("glVertexAttribDivisorARB"); + if(!glDrawArraysInstanced) + { + qDebug()<<"glVertexAttribDivisorARB : extension not found. Wireframe mode will be forced."; + extension_is_found = false; + } + else + extension_is_found = true; + + wireframe = !extension_is_found; // camera // only 2.7 gets an 'f' as VC++ warns if we don't ui->viewer->camera()->setPosition(Vec(0.5,0.5,2.7f)); @@ -971,8 +998,11 @@ void Scene::update_position() rendering_program_spheres.enableAttributeArray(centerLocation[0]); rendering_program_spheres.setAttributeBuffer(centerLocation[0],GL_FLOAT,0,3); buffers[5].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[1],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[1],0); + } vao[7].release(); ui->viewer->update(); 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 4f0db183696..a689bfad4cb 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 @@ -6,12 +6,12 @@ #include #include #include -#include +#include #include #include #include -class Scene : public QObject, QOpenGLFunctions_3_3_Core +class Scene : public QObject, QOpenGLFunctions_2_1 { Q_OBJECT @@ -144,9 +144,9 @@ public Q_SLOTS: ui->viewer->update(); } void toggle_wireframe(bool on) { - wireframe = on; - ( on ? glDisable(GL_LIGHTING) : glEnable(GL_LIGHTING) ); - changed(); + wireframe = !(!on && extension_is_found); + ( on ? glDisable(GL_LIGHTING) : glEnable(GL_LIGHTING) ); + changed(); } void toggle_in_plane(bool on) { in_plane = on; @@ -287,11 +287,14 @@ private: std::vector transfo4_square; bool are_buffers_initialized; + bool extension_is_found; QOpenGLBuffer buffers[24]; QOpenGLVertexArrayObject vao[12]; QOpenGLShaderProgram rendering_program; QOpenGLShaderProgram rendering_program_spheres; QOpenGLShaderProgram rendering_program_cylinders; + PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; + PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; void initialize_buffers(); void compute_elements(); void attrib_buffers(QGLViewer*); From 88e41a6bf74691696e96367fb6e7ca726ec30667 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 11:17:24 +0200 Subject: [PATCH 12/35] Mesa Fix : - context set to 2.1 - shaders versions set to 120 --- Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp | 6 +++--- Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp index 7d1b9a93d09..2e551b3097b 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp +++ b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp @@ -265,8 +265,8 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "void main(void)\n" "{\n" @@ -276,7 +276,7 @@ void Viewer::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 330 \n" + "#version 120 \n" "uniform highp vec4 color; \n" "void main(void) { \n" "gl_FragColor = color; \n" 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 cce393ebe1d..c03df5c5c65 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.h +++ b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.h @@ -3,14 +3,14 @@ #include "Scene.h" #include -#include +#include #include #include #include #include -class Viewer : public QGLViewer, QOpenGLFunctions_3_3_Core { +class Viewer : public QGLViewer, QOpenGLFunctions_2_1 { typedef qglviewer::Vec Vec; From db28896b1547d64d2d4497cf016e3ee157af775a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 14:48:42 +0200 Subject: [PATCH 13/35] Mesa Fix : - context set to 2.1 - shaders versions set to 120 - fetch and set the ARB extensions for instanced Rendering - displays points instead of spheres if the extensions cannot be found - anti-aliasing problem with polyline fixed : calling lines durind draw instead of draw_edges messes the blending. The blending of the lines must be done with the facets colors and thus the lines must be drawn AFTER the facets. --- .../Polyhedron/CGAL_demo/Viewer_interface.h | 8 +- .../Polyhedron/Scene_edit_polyhedron_item.cpp | 21 +- .../demo/Polyhedron/Scene_polylines_item.cpp | 218 +++++++++++------- Polyhedron/demo/Polyhedron/Viewer.cpp | 19 ++ .../Polyhedron/resources/shader_instanced.v | 2 +- .../Polyhedron/resources/shader_with_light.f | 2 +- .../Polyhedron/resources/shader_with_light.v | 2 +- .../resources/shader_with_texture.f | 2 +- .../resources/shader_with_texture.v | 2 +- .../resources/shader_with_textured_edges.f | 2 +- .../resources/shader_with_textured_edges.v | 2 +- .../resources/shader_without_light.f | 2 +- .../resources/shader_without_light.v | 2 +- 13 files changed, 177 insertions(+), 107 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h b/Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h index 10eb01aa7c8..05955d44373 100644 --- a/Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h +++ b/Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include // forward declarations class QWidget; @@ -14,7 +14,7 @@ class QKeyEvent; #include "../Viewer_config.h" // for VIEWER_EXPORT -class VIEWER_EXPORT Viewer_interface : public QGLViewer, public QOpenGLFunctions_3_3_Core { +class VIEWER_EXPORT Viewer_interface : public QGLViewer, public QOpenGLFunctions_2_1 { Q_OBJECT @@ -30,6 +30,9 @@ public: static QString dumpFrame(const qglviewer::Frame&); virtual bool inFastDrawing() const = 0; + PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; + PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; + bool extension_is_found; GLfloat pickMatrix_[16]; Q_SIGNALS: @@ -47,6 +50,7 @@ public Q_SLOTS: virtual QString dumpCameraCoordinates() = 0; virtual bool moveCameraToCoordinates(QString, float animation_duration = 0.5f) = 0; + }; // end class Viewer_interface #endif // VIEWER_INTERFACE_H diff --git a/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp index e0aaecaf4bb..c1a2ec5a506 100644 --- a/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_edit_polyhedron_item.cpp @@ -73,7 +73,7 @@ Scene_edit_polyhedron_item::Scene_edit_polyhedron_item const char vertex_shader_source_bbox[] = { - + "#version 120 \n" "attribute highp vec3 vertex; \n" "attribute highp vec3 colors; \n" @@ -92,6 +92,7 @@ Scene_edit_polyhedron_item::Scene_edit_polyhedron_item }; const char fragment_shader_source[]= { + "#version 120 \n" "varying vec3 fColors; \n" " \n" "void main(void) \n" @@ -214,8 +215,11 @@ void Scene_edit_polyhedron_item::initialize_buffers(Viewer_interface *viewer =0) program->setAttributeBuffer("center",GL_DOUBLE,0,3); buffers[8].release(); - viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); - viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); + if(viewer->extension_is_found) + { + viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); + viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); + } vaos[3]->release(); } //vao for the BBOX @@ -292,8 +296,11 @@ void Scene_edit_polyhedron_item::initialize_buffers(Viewer_interface *viewer =0) program->setAttributeBuffer("center",GL_DOUBLE,0,3); buffers[16].release(); - viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); - viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); + if(viewer->extension_is_found) + { + viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); + viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); + } vaos[6]->release(); } //vao for the axis @@ -501,7 +508,7 @@ void Scene_edit_polyhedron_item::draw_ROI_and_control_vertices(Viewer_interface* color.set_rgb_color(0, 1.f, 0); if(ui_widget->ShowROICheckBox->isChecked()) { - if(!ui_widget->ShowAsSphereCheckBox->isChecked()) { + if(!ui_widget->ShowAsSphereCheckBox->isChecked() || !viewer->extension_is_found) { vaos[1]->bind(); program = getShaderProgram(PROGRAM_WITHOUT_LIGHT); @@ -524,7 +531,7 @@ void Scene_edit_polyhedron_item::draw_ROI_and_control_vertices(Viewer_interface* } } - if(!ui_widget->ShowAsSphereCheckBox->isChecked()) { + if(!ui_widget->ShowAsSphereCheckBox->isChecked() || !viewer->extension_is_found) { vaos[5]->bind(); program = getShaderProgram(PROGRAM_WITHOUT_LIGHT); attrib_buffers(viewer,PROGRAM_WITHOUT_LIGHT); diff --git a/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp index 9314bdbcdea..739bef298c5 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp @@ -51,40 +51,63 @@ Scene_polylines_item::initialize_buffers(Viewer_interface *viewer = 0) const } //vao for the spheres { - program = getShaderProgram(PROGRAM_INSTANCED, viewer); - program->bind(); + if(viewer->extension_is_found) + { + program = getShaderProgram(PROGRAM_INSTANCED, viewer); + program->bind(); - vaos[1]->bind(); - buffers[1].bind(); - buffers[1].allocate(positions_spheres.data(), - static_cast(positions_spheres.size()*sizeof(float))); - program->enableAttributeArray("vertex"); - program->setAttributeBuffer("vertex",GL_FLOAT,0,3); - buffers[1].release(); + vaos[1]->bind(); + buffers[1].bind(); + buffers[1].allocate(positions_spheres.data(), + static_cast(positions_spheres.size()*sizeof(float))); + program->enableAttributeArray("vertex"); + program->setAttributeBuffer("vertex",GL_FLOAT,0,3); + buffers[1].release(); - buffers[2].bind(); - buffers[2].allocate(normals_spheres.data(), - static_cast(normals_spheres.size()*sizeof(float))); - program->enableAttributeArray("normals"); - program->setAttributeBuffer("normals",GL_FLOAT,0,3); - buffers[2].release(); + buffers[2].bind(); + buffers[2].allocate(normals_spheres.data(), + static_cast(normals_spheres.size()*sizeof(float))); + program->enableAttributeArray("normals"); + program->setAttributeBuffer("normals",GL_FLOAT,0,3); + buffers[2].release(); - buffers[3].bind(); - buffers[3].allocate(color_spheres.data(), - static_cast(color_spheres.size()*sizeof(float))); - program->enableAttributeArray("colors"); - program->setAttributeBuffer("colors",GL_FLOAT,0,3); - buffers[3].release(); + buffers[3].bind(); + buffers[3].allocate(color_spheres.data(), + static_cast(color_spheres.size()*sizeof(float))); + program->enableAttributeArray("colors"); + program->setAttributeBuffer("colors",GL_FLOAT,0,3); + buffers[3].release(); - buffers[4].bind(); - buffers[4].allocate(positions_center.data(), - static_cast(positions_center.size()*sizeof(float))); - program->enableAttributeArray("center"); - program->setAttributeBuffer("center",GL_FLOAT,0,3); - buffers[4].release(); + buffers[4].bind(); + buffers[4].allocate(positions_center.data(), + static_cast(positions_center.size()*sizeof(float))); + program->enableAttributeArray("center"); + program->setAttributeBuffer("center",GL_FLOAT,0,3); + buffers[4].release(); - viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); - viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); + viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); + viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); + } + else + { + program = getShaderProgram(PROGRAM_WITHOUT_LIGHT, viewer); + program->bind(); + + vaos[1]->bind(); + buffers[1].bind(); + buffers[1].allocate(positions_center.data(), + static_cast(positions_center.size()*sizeof(float))); + program->enableAttributeArray("vertex"); + program->setAttributeBuffer("vertex",GL_FLOAT,0,3); + buffers[1].release(); + + buffers[2].bind(); + buffers[2].allocate(color_spheres.data(), + static_cast(color_spheres.size()*sizeof(float))); + program->enableAttributeArray("colors"); + program->setAttributeBuffer("colors",GL_FLOAT,0,3); + buffers[2].release(); + } vaos[1]->release(); program->release(); @@ -92,39 +115,51 @@ Scene_polylines_item::initialize_buffers(Viewer_interface *viewer = 0) const //vao for the wired spheres { - program = getShaderProgram(PROGRAM_INSTANCED_WIRE, viewer); - program->bind(); + if(viewer->extension_is_found) + { + program = getShaderProgram(PROGRAM_INSTANCED_WIRE, viewer); + program->bind(); - vaos[2]->bind(); - buffers[5].bind(); - buffers[5].allocate(positions_wire_spheres.data(), - static_cast(positions_wire_spheres.size()*sizeof(float))); - program->enableAttributeArray("vertex"); - program->setAttributeBuffer("vertex",GL_FLOAT,0,3); - buffers[5].release(); - QColor temp = this->color(); - program->setAttributeValue("colors", temp); + vaos[2]->bind(); + buffers[5].bind(); + buffers[5].allocate(positions_wire_spheres.data(), + static_cast(positions_wire_spheres.size()*sizeof(float))); + program->enableAttributeArray("vertex"); + program->setAttributeBuffer("vertex",GL_FLOAT,0,3); + buffers[5].release(); - program->setAttributeValue("normals",QVector3D(0.0,0.0,0.0)); - buffers[6].bind(); - buffers[6].allocate(color_spheres.data(), - static_cast(color_spheres.size()*sizeof(float))); - program->enableAttributeArray("colors"); - program->setAttributeBuffer("colors",GL_FLOAT,0,3); - buffers[6].release(); + buffers[3].bind(); + program->enableAttributeArray("colors"); + program->setAttributeBuffer("colors",GL_FLOAT,0,3); + buffers[3].release(); - buffers[7].bind(); - buffers[7].allocate(positions_center.data(), - static_cast(positions_center.size()*sizeof(float))); - program->enableAttributeArray("center"); - program->setAttributeBuffer("center",GL_FLOAT,0,3); - buffers[7].release(); + buffers[2].bind(); + program->enableAttributeArray("normals"); + program->setAttributeBuffer("normals",GL_FLOAT,0,3); + buffers[2].release(); - viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); - viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); - vaos[2]->release(); - program->release(); + buffers[6].bind(); + buffers[6].allocate(color_spheres.data(), + static_cast(color_spheres.size()*sizeof(float))); + program->enableAttributeArray("colors"); + program->setAttributeBuffer("colors",GL_FLOAT,0,3); + buffers[6].release(); + + buffers[7].bind(); + buffers[7].allocate(positions_center.data(), + static_cast(positions_center.size()*sizeof(float))); + program->enableAttributeArray("center"); + program->setAttributeBuffer("center",GL_FLOAT,0,3); + buffers[7].release(); + + + viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); + viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); + + vaos[2]->release(); + program->release(); + } } are_buffers_filled = true; @@ -363,8 +398,7 @@ Scene_polylines_item::toolTip() const { bool Scene_polylines_item::supportsRenderingMode(RenderingMode m) const { return (m == Wireframe || - m == Flat || - m == Flat || + m == FlatPlusEdges || m == Points); } @@ -376,26 +410,30 @@ Scene_polylines_item::draw(Viewer_interface* viewer) const { initialize_buffers(viewer); if(d->draw_extremities) { - vaos[1]->bind(); - program = getShaderProgram(PROGRAM_INSTANCED); - attrib_buffers(viewer, PROGRAM_INSTANCED); - program->bind(); - viewer->glDrawArraysInstanced(GL_TRIANGLES, 0, - static_cast(positions_spheres.size()/3), nbSpheres); - program->release(); - vaos[1]->release(); - } - if(renderingMode() == Flat) - { - vaos[0]->bind(); - attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT); - program = getShaderProgram(PROGRAM_WITHOUT_LIGHT); - program->bind(); - QColor temp = this->color(); - program->setAttributeValue("colors", temp); - viewer->glDrawArrays(GL_LINES, 0, static_cast(positions_lines.size()/4)); - program->release(); - vaos[0]->release(); + if(viewer->extension_is_found) + { + vaos[1]->bind(); + program = getShaderProgram(PROGRAM_INSTANCED); + attrib_buffers(viewer, PROGRAM_INSTANCED); + program->bind(); + viewer->glDrawArraysInstanced(GL_TRIANGLES, 0, + static_cast(positions_spheres.size()/3), nbSpheres); + program->release(); + vaos[1]->release(); + } + else + { + vaos[1]->bind(); + program = getShaderProgram(PROGRAM_WITHOUT_LIGHT); + attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT); + glPointSize(8.0f); + glEnable(GL_POINT_SMOOTH); + program->bind(); + viewer->glDrawArrays(GL_POINTS, 0, static_cast(positions_center.size()/3)); + glDisable(GL_POINT_SMOOTH); + program->release(); + vaos[1]->release(); + } } } @@ -409,21 +447,23 @@ Scene_polylines_item::draw_edges(Viewer_interface* viewer) const { attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT); program = getShaderProgram(PROGRAM_WITHOUT_LIGHT); program->bind(); - QColor temp = this->color(); - program->setAttributeValue("colors", temp); + program->setAttributeValue("colors", this->color()); viewer->glDrawArrays(GL_LINES, 0, static_cast(positions_lines.size()/4)); program->release(); vaos[0]->release(); if(d->draw_extremities) { - vaos[2]->bind(); - attrib_buffers(viewer, PROGRAM_INSTANCED_WIRE); - program = getShaderProgram(PROGRAM_INSTANCED_WIRE); - program->bind(); - viewer->glDrawArraysInstanced(GL_LINES, 0, - static_cast(positions_wire_spheres.size()/3), nbSpheres); - program->release(); - vaos[2]->release(); + if(viewer->extension_is_found) + { + vaos[2]->bind(); + attrib_buffers(viewer, PROGRAM_INSTANCED_WIRE); + program = getShaderProgram(PROGRAM_INSTANCED_WIRE); + program->bind(); + viewer->glDrawArraysInstanced(GL_LINES, 0, + static_cast(positions_wire_spheres.size()/3), nbSpheres); + program->release(); + vaos[2]->release(); + } } } diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index 78e08c6dee0..10b11de01be 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -105,6 +105,25 @@ void Viewer::initializeGL() { QGLViewer::initializeGL(); initializeOpenGLFunctions(); + glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDARBPROC)this->context()->getProcAddress("glDrawArraysInstancedARB"); + if(!glDrawArraysInstanced) + { + qDebug()<<"glDrawArraysInstancedARB : extension not found. Spheres will be displayed as points."; + extension_is_found = false; + } + else + extension_is_found = true; + + glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORARBPROC)this->context()->getProcAddress("glVertexAttribDivisorARB"); + if(!glDrawArraysInstanced) + { + qDebug()<<"glVertexAttribDivisorARB : extension not found. Spheres will be displayed as points."; + extension_is_found = false; + } + else + extension_is_found = true; + + setBackgroundColor(::Qt::white); d->scene->initializeGL(); diff --git a/Polyhedron/demo/Polyhedron/resources/shader_instanced.v b/Polyhedron/demo/Polyhedron/resources/shader_instanced.v index 0f7d6ff4740..d353c8d9949 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_instanced.v +++ b/Polyhedron/demo/Polyhedron/resources/shader_instanced.v @@ -1,4 +1,4 @@ -#version 330 +#version 120 attribute highp vec4 vertex; attribute highp vec3 normals; attribute highp vec3 colors; diff --git a/Polyhedron/demo/Polyhedron/resources/shader_with_light.f b/Polyhedron/demo/Polyhedron/resources/shader_with_light.f index 9fa9b65352f..8d958ab4085 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_with_light.f +++ b/Polyhedron/demo/Polyhedron/resources/shader_with_light.f @@ -1,4 +1,4 @@ -#version 330 +#version 120 varying highp vec4 color; varying highp vec4 fP; varying highp vec3 fN; diff --git a/Polyhedron/demo/Polyhedron/resources/shader_with_light.v b/Polyhedron/demo/Polyhedron/resources/shader_with_light.v index cad171b3084..fa04afac9df 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_with_light.v +++ b/Polyhedron/demo/Polyhedron/resources/shader_with_light.v @@ -1,4 +1,4 @@ -#version 330 +#version 120 attribute highp vec4 vertex; attribute highp vec3 normals; attribute highp vec3 colors; diff --git a/Polyhedron/demo/Polyhedron/resources/shader_with_texture.f b/Polyhedron/demo/Polyhedron/resources/shader_with_texture.f index 2c90da7dba8..4d9bc7ca323 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_with_texture.f +++ b/Polyhedron/demo/Polyhedron/resources/shader_with_texture.f @@ -1,4 +1,4 @@ -#version 330 +#version 120 varying highp vec3 fColors; varying highp vec2 f_texCoord; uniform sampler2D s_texture; diff --git a/Polyhedron/demo/Polyhedron/resources/shader_with_texture.v b/Polyhedron/demo/Polyhedron/resources/shader_with_texture.v index 09ced2cacaf..bfecbfc3b74 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_with_texture.v +++ b/Polyhedron/demo/Polyhedron/resources/shader_with_texture.v @@ -1,4 +1,4 @@ -#version 330 +#version 120 attribute highp vec4 vertex; attribute highp vec3 normal; attribute highp vec3 color_facets; diff --git a/Polyhedron/demo/Polyhedron/resources/shader_with_textured_edges.f b/Polyhedron/demo/Polyhedron/resources/shader_with_textured_edges.f index ef0d574d1bc..888152005a4 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_with_textured_edges.f +++ b/Polyhedron/demo/Polyhedron/resources/shader_with_textured_edges.f @@ -1,4 +1,4 @@ -#version 330 +#version 120 varying highp vec3 fColors; varying highp vec2 f_texCoord; uniform highp sampler2D s_texture; diff --git a/Polyhedron/demo/Polyhedron/resources/shader_with_textured_edges.v b/Polyhedron/demo/Polyhedron/resources/shader_with_textured_edges.v index 7d3010a1ca1..7770cc309fe 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_with_textured_edges.v +++ b/Polyhedron/demo/Polyhedron/resources/shader_with_textured_edges.v @@ -1,4 +1,4 @@ -#version 330 +#version 120 attribute highp vec4 vertex; attribute highp vec2 v_texCoord; uniform highp vec3 color_lines; diff --git a/Polyhedron/demo/Polyhedron/resources/shader_without_light.f b/Polyhedron/demo/Polyhedron/resources/shader_without_light.f index 6a14655a5a7..32b3ebd0455 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_without_light.f +++ b/Polyhedron/demo/Polyhedron/resources/shader_without_light.f @@ -1,4 +1,4 @@ -#version 330 +#version 120 varying highp vec4 color; void main(void) { diff --git a/Polyhedron/demo/Polyhedron/resources/shader_without_light.v b/Polyhedron/demo/Polyhedron/resources/shader_without_light.v index 6f9e362709b..892328ae65c 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_without_light.v +++ b/Polyhedron/demo/Polyhedron/resources/shader_without_light.v @@ -1,4 +1,4 @@ - #version 330 + #version 120 attribute highp vec4 vertex; attribute highp vec3 colors; uniform highp mat4 mvp_matrix; From 43e675903ab1c84f0d2c51951f997df083202786 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 15:03:51 +0200 Subject: [PATCH 14/35] Antialiasing fix - The polylines were drawn in draw() instead of draw_edges(), which messed up the blending, as it should be done with the color of the facets but in draw they are not displayed yet. --- .../demo/Polyhedron/Scene_polylines_item.cpp | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp index 9314bdbcdea..bca98e069c3 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polylines_item.cpp @@ -102,10 +102,17 @@ Scene_polylines_item::initialize_buffers(Viewer_interface *viewer = 0) const program->enableAttributeArray("vertex"); program->setAttributeBuffer("vertex",GL_FLOAT,0,3); buffers[5].release(); - QColor temp = this->color(); - program->setAttributeValue("colors", temp); - program->setAttributeValue("normals",QVector3D(0.0,0.0,0.0)); + + buffers[3].bind(); + program->enableAttributeArray("colors"); + program->setAttributeBuffer("colors",GL_FLOAT,0,3); + buffers[3].release(); + + buffers[2].bind(); + program->enableAttributeArray("normals"); + program->setAttributeBuffer("normals",GL_FLOAT,0,3); + buffers[2].release(); buffers[6].bind(); buffers[6].allocate(color_spheres.data(), @@ -121,8 +128,10 @@ Scene_polylines_item::initialize_buffers(Viewer_interface *viewer = 0) const program->setAttributeBuffer("center",GL_FLOAT,0,3); buffers[7].release(); + viewer->glVertexAttribDivisor(program->attributeLocation("center"), 1); viewer->glVertexAttribDivisor(program->attributeLocation("colors"), 1); + vaos[2]->release(); program->release(); } @@ -283,7 +292,7 @@ Scene_polylines_item::Scene_polylines_item() ,d(new Scene_polylines_item_private()) ,nbSpheres(0) { - setRenderingMode(Flat); + setRenderingMode(FlatPlusEdges); changed(); } @@ -364,7 +373,7 @@ bool Scene_polylines_item::supportsRenderingMode(RenderingMode m) const { return (m == Wireframe || m == Flat || - m == Flat || + m == FlatPlusEdges || m == Points); } @@ -385,18 +394,6 @@ Scene_polylines_item::draw(Viewer_interface* viewer) const { program->release(); vaos[1]->release(); } - if(renderingMode() == Flat) - { - vaos[0]->bind(); - attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT); - program = getShaderProgram(PROGRAM_WITHOUT_LIGHT); - program->bind(); - QColor temp = this->color(); - program->setAttributeValue("colors", temp); - viewer->glDrawArrays(GL_LINES, 0, static_cast(positions_lines.size()/4)); - program->release(); - vaos[0]->release(); - } } // Wireframe OpenGL drawing From 03eee8987ef529a17e6a3e4cf4df5495a758af4f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 10 Aug 2015 16:12:47 +0200 Subject: [PATCH 15/35] Mesa Fix : - context set to 2.1 - shaders versions set to 120 - fetch and set the ARB extensions for instanced Rendering - displays points instead of spheres if the extensions cannot be found --- .../demo/Triangulation_3/Viewer.cpp | 191 ++++++++++++------ Triangulation_3/demo/Triangulation_3/Viewer.h | 8 +- 2 files changed, 133 insertions(+), 66 deletions(-) diff --git a/Triangulation_3/demo/Triangulation_3/Viewer.cpp b/Triangulation_3/demo/Triangulation_3/Viewer.cpp index 2262eeab95f..43c22bfb7af 100644 --- a/Triangulation_3/demo/Triangulation_3/Viewer.cpp +++ b/Triangulation_3/demo/Triangulation_3/Viewer.cpp @@ -18,6 +18,25 @@ using namespace std; void Viewer::init() { initializeOpenGLFunctions(); + glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDARBPROC)this->context()->getProcAddress("glDrawArraysInstancedARB"); + if(!glDrawArraysInstanced) + { + qDebug()<<"glDrawArraysInstancedARB : extension not found. Spheres will be displayed as points."; + extension_is_found = false; + } + else + extension_is_found = true; + + glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORARBPROC)this->context()->getProcAddress("glVertexAttribDivisorARB"); + if(!glDrawArraysInstanced) + { + qDebug()<<"glVertexAttribDivisorARB : extension not found. Spheres will be displayed as points."; + extension_is_found = false; + } + else + extension_is_found = true; +// extension_is_found = false; + /* Initial timer for playing incremental construction */ m_pTimer = new QTimer(this); connect(m_pTimer, SIGNAL(timeout()), this, SLOT(incremental_insert())); @@ -162,8 +181,8 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "void main(void)\n" "{\n" @@ -173,7 +192,7 @@ void Viewer::compile_shaders() //Fragment source code const char fragment_source[] = { - "#version 330 \n" + "#version 120 \n" "uniform highp vec4 color; \n" "void main(void) { \n" "gl_FragColor = color; \n" @@ -210,15 +229,15 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source_spheres[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" - "in highp vec4 center;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec4 center;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -229,9 +248,9 @@ void Viewer::compile_shaders() //Fragment source code const char fragment_source_spheres[] = { - "#version 330 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" + "#version 120 \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "uniform vec4 color; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" @@ -288,18 +307,18 @@ void Viewer::compile_shaders() //Vertex source code const char vertex_source_cylinders[] = { - "#version 330 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" - "in highp vec4 transfo1;\n" - "in highp vec4 transfo2;\n" - "in highp vec4 transfo3;\n" - "in highp vec4 transfo4;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec4 transfo1;\n" + "attribute highp vec4 transfo2;\n" + "attribute highp vec4 transfo3;\n" + "attribute highp vec4 transfo4;\n" "mat4 transfo = mat4(transfo1, transfo2, transfo3, transfo4); \n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" - "out highp vec4 fP; \n" - "out highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" @@ -714,19 +733,24 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[13].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[11].release(); //Empty Sphere vao[12].bind(); - buffers[14].bind(); - buffers[14].allocate(pos_emptySphere->data(), pos_emptySphere->size()*sizeof(float)); - centerLocation[0] = rendering_program_spheres.attributeLocation("center"); - rendering_program_spheres.enableAttributeArray(centerLocation[0]); - rendering_program_spheres.setAttributeBuffer(centerLocation[0],GL_FLOAT,0,3); - buffers[14].release(); - + if(extension_is_found) + { + buffers[14].bind(); + buffers[14].allocate(pos_emptySphere->data(), pos_emptySphere->size()*sizeof(float)); + centerLocation[0] = rendering_program_spheres.attributeLocation("center"); + rendering_program_spheres.enableAttributeArray(centerLocation[0]); + rendering_program_spheres.setAttributeBuffer(centerLocation[0],GL_FLOAT,0,3); + buffers[14].release(); + } buffers[32].bind(); buffers[32].allocate(normals_emptySphere->data(), normals_emptySphere->size()*sizeof(float)); normalsLocation[0] = rendering_program_spheres.attributeLocation("normal"); @@ -741,8 +765,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[16].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[12].release(); //Vertex Sphere @@ -767,8 +794,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[17].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[13].release(); //New point Sphere @@ -791,8 +821,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[17].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[14].release(); //Selected point Sphere @@ -815,8 +848,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[17].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[15].release(); //Moving point Sphere @@ -839,8 +875,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[17].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[16].release(); //Querry point Sphere @@ -863,8 +902,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[17].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[17].release(); //Nearest neighbor Sphere @@ -887,8 +929,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[17].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[18].release(); //incremental list @@ -910,8 +955,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[17].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[25].release(); //incremental next point @@ -933,8 +981,11 @@ void Viewer::initialize_buffers() rendering_program_spheres.setAttributeBuffer(poly_vertexLocation[1],GL_FLOAT,0,3); buffers[17].release(); - glVertexAttribDivisor(centerLocation[0],1); - glVertexAttribDivisor(normalsLocation[0],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[0],1); + glVertexAttribDivisor(normalsLocation[0],0); + } vao[26].release(); } @@ -985,12 +1036,14 @@ void Viewer::initialize_buffers() rendering_program_cylinders.setAttributeBuffer(centerLocation[4],GL_FLOAT,0,4); buffers[23].release(); - - glVertexAttribDivisor(centerLocation[1],1); - glVertexAttribDivisor(centerLocation[2],1); - glVertexAttribDivisor(centerLocation[3],1); - glVertexAttribDivisor(centerLocation[4],1); - glVertexAttribDivisor(normalsLocation[1],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[1],1); + glVertexAttribDivisor(centerLocation[2],1); + glVertexAttribDivisor(centerLocation[3],1); + glVertexAttribDivisor(centerLocation[4],1); + glVertexAttribDivisor(normalsLocation[1],0); + } vao[19].release(); @@ -1035,13 +1088,14 @@ void Viewer::initialize_buffers() rendering_program_cylinders.enableAttributeArray(centerLocation[4]); rendering_program_cylinders.setAttributeBuffer(centerLocation[4],GL_FLOAT,0,4); buffers[27].release(); - - - glVertexAttribDivisor(centerLocation[1],1); - glVertexAttribDivisor(centerLocation[2],1); - glVertexAttribDivisor(centerLocation[3],1); - glVertexAttribDivisor(centerLocation[4],1); - glVertexAttribDivisor(normalsLocation[1],0); + if(extension_is_found) + { + glVertexAttribDivisor(centerLocation[1],1); + glVertexAttribDivisor(centerLocation[2],1); + glVertexAttribDivisor(centerLocation[3],1); + glVertexAttribDivisor(centerLocation[4],1); + glVertexAttribDivisor(normalsLocation[1],0); + } vao[20].release(); } @@ -1143,7 +1197,7 @@ void Viewer::draw() initialize_buffers(); QFont fontPrompt("Arial", 8); attrib_buffers(this); - if(m_isFlat) + if(m_isFlat || !extension_is_found) { if(m_showVertex) @@ -1564,7 +1618,10 @@ void Viewer::draw() rendering_program_spheres.bind(); vao[11].bind(); rendering_program_spheres.setUniformValue(colorLocation[1], m_colorTrackball); - glDrawArraysInstanced(GL_TRIANGLES, 0, points_trackBall->size()/3, 1); + if(extension_is_found) + glDrawArraysInstanced(GL_TRIANGLES, 0, points_trackBall->size()/3, 1); + else + glDrawArrays(GL_TRIANGLES, 0, points_trackBall->size()/3); vao[11].release(); rendering_program_spheres.release(); } @@ -1573,7 +1630,13 @@ void Viewer::draw() rendering_program_spheres.bind(); vao[12].bind(); rendering_program_spheres.setUniformValue(colorLocation[1], m_colorEmptySphere); - glDrawArraysInstanced(GL_TRIANGLES, 0, points_emptySphere->size()/3, pos_emptySphere->size()/3); + if(extension_is_found) + glDrawArraysInstanced(GL_TRIANGLES, 0, points_emptySphere->size()/3, pos_emptySphere->size()/3); + else if(pos_emptySphere->size()>0) + { + rendering_program_spheres.setAttributeValue("center", QVector4D(pos_emptySphere->at(0), pos_emptySphere->at(1), pos_emptySphere->at(2), 1.0)); + glDrawArrays(GL_TRIANGLES, 0, points_emptySphere->size()/3); + } vao[12].release(); rendering_program_spheres.release(); } diff --git a/Triangulation_3/demo/Triangulation_3/Viewer.h b/Triangulation_3/demo/Triangulation_3/Viewer.h index ca05da36146..d32de675c84 100644 --- a/Triangulation_3/demo/Triangulation_3/Viewer.h +++ b/Triangulation_3/demo/Triangulation_3/Viewer.h @@ -8,7 +8,7 @@ #include #include "PreferenceDlg.h" -#include +#include #include #include #include @@ -18,7 +18,7 @@ using namespace qglviewer; class MainWindow; -class Viewer : public QGLViewer, QOpenGLFunctions_3_3_Core { +class Viewer : public QGLViewer, QOpenGLFunctions_2_1 { Q_OBJECT @@ -345,6 +345,8 @@ private: int lightLocation[5*2]; bool are_buffers_initialized; + bool extension_is_found; + std::vector *pos_emptyFacet; std::vector *pos_emptySphere; std::vector *points_emptySphere; @@ -385,6 +387,8 @@ private: QOpenGLShaderProgram rendering_program; QOpenGLShaderProgram rendering_program_spheres; QOpenGLShaderProgram rendering_program_cylinders; + PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; + PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; void initialize_buffers(); void compute_elements(); void attrib_buffers(QGLViewer*); From 0f83711bab3857de2ed563caed70882ea1d56797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 11 Aug 2015 07:52:26 +0200 Subject: [PATCH 16/35] each time an item is removed, the skeletonization functor will be deleted it might look rather extreme but indices of items are internally used so it's the safest way --- ...Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp index e8d3625ef3a..98161cd4b11 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp @@ -155,6 +155,9 @@ public: connect(ui->pushButton_segment, SIGNAL(clicked()), this, SLOT(on_actionSegment())); + QObject* scene_object = dynamic_cast(scene); + connect(scene_object, SIGNAL(itemAboutToBeDestroyed(Scene_item*)), + this, SLOT(on_actionItemAboutToBeDestroyed(Scene_item*))); } QList actions() const { @@ -719,10 +722,6 @@ void Polyhedron_demo_mean_curvature_flow_skeleton_plugin::on_actionRun() delete temp; } - QObject* scene_object = dynamic_cast(scene); - connect(scene_object, SIGNAL(itemAboutToBeDestroyed(Scene_item*)), - this, SLOT(on_actionItemAboutToBeDestroyed(Scene_item*))); - //#define DRAW_NON_FIXED_POINTS #ifdef DRAW_NON_FIXED_POINTS // draw non-fixed points From bd1b89cdf4fd43f8c9ba98ff618fbb1eab7d43f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 11 Aug 2015 08:15:46 +0200 Subject: [PATCH 17/35] Fix a loop preventing the selection of several items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MainWindow::selectionChanged() was calling Scene::setSelectedItem that was connected to MainWindow::selectionChanged(). We introduce a new function that does not trigger the call to selectionChanged Bug fix of |-- |commit 63dca733dccc06aa97889ae3496c261c559ecc4a |Author: Sébastien Loriot |Date: Thu Aug 6 16:49:25 2015 +0200 | | Scene::setSelectedItem is now connected to MainWindow::selectSceneItem |-- --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 2 +- Polyhedron/demo/Polyhedron/Scene.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index e56572adff8..8a06dd6344e 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -959,7 +959,7 @@ QList MainWindow::getSelectedSceneItemIndices() const void MainWindow::selectionChanged() { - scene->setSelectedItem(getSelectedSceneItemIndex()); + scene->setSelectedItemIndex(getSelectedSceneItemIndex()); scene->setSelectedItemsList(getSelectedSceneItemIndices()); Scene_item* item = scene->item(getSelectedSceneItemIndex()); if(item != NULL && item->manipulatable()) { diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h index 2777b23715c..a8990104a01 100644 --- a/Polyhedron/demo/Polyhedron/Scene.h +++ b/Polyhedron/demo/Polyhedron/Scene.h @@ -115,6 +115,11 @@ public Q_SLOTS: void itemChanged(int i); void itemChanged(Scene_item*); + void setSelectedItemIndex(int i) + { + selected_item = i; + } + void setSelectedItem(int i ) { selected_item = i; From 52eefe1a55ebe1c175cc57c25404a8a38d652b10 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 11 Aug 2015 08:54:11 +0200 Subject: [PATCH 18/35] ShortestPath not seen fix - Change of DepthFunc to be in mode less or equal, so that if two lines overlap, only the last drawn will be displayed. As the shortest path is always drawn after the item, it is the one displayed and not the edge on wich it is. --- Polyhedron/demo/Polyhedron/Scene.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index d3fc928e732..fd4540f465a 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -288,7 +288,7 @@ Scene::draw_aux(bool with_names, Viewer_interface* viewer) ::glPopName(); } } - +glDepthFunc(GL_LEQUAL); // Wireframe OpenGL drawing for(int index = 0; index < m_entries.size(); ++index) { @@ -353,6 +353,7 @@ Scene::draw_aux(bool with_names, Viewer_interface* viewer) } } + // Points OpenGL drawing for(int index = 0; index < m_entries.size(); ++index) { @@ -381,6 +382,7 @@ Scene::draw_aux(bool with_names, Viewer_interface* viewer) ::glPopName(); } } + glDepthFunc(GL_LESS); } int From b4d7511346b4bd672b52f489ae0be5172b58b1aa Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 11 Aug 2015 11:27:09 +0200 Subject: [PATCH 19/35] get_hole_visualizer() fix - Use a QMap instead of a linear search --- .../Polyhedron_demo_hole_filling_plugin.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp index 8c30ec50cb2..daedacd0fab 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp @@ -35,6 +35,7 @@ #include "Kernel_type.h" #include +#include // Class for visualizing holes in a polyhedron // provides mouse selection functionality @@ -307,13 +308,8 @@ public: void init(QMainWindow* mainWindow, Scene_interface* scene_interface, Messages_interface* m); Scene_hole_visualizer* get_hole_visualizer(Scene_polyhedron_item* poly_item) { - // did not use a map to assoc Scene_polyhedron_item with Scene_hole_visualizer to prevent crowded code - for(Scene_interface::Item_id i = 0, end = scene->numberOfEntries(); i < end; ++i) { - Scene_hole_visualizer* hole_visualizer = qobject_cast(scene->item(i)); - if(hole_visualizer && hole_visualizer->poly_item == poly_item) - { return hole_visualizer; } - } - return NULL; + + return visualizers[poly_item]; } public Q_SLOTS: @@ -353,6 +349,9 @@ private: QDockWidget* dock_widget; Ui::HoleFilling ui_widget; + //Maintains a reference between all the visualizers and their poly_item + // to ease the management of the visualizers + QMap visualizers; // hold created facet for accept reject functionality std::vector new_facets; Scene_polyhedron_item* last_active_item; // always keep it NULL while not active-reject state @@ -427,6 +426,7 @@ void Polyhedron_demo_hole_filling_plugin::item_about_to_be_destroyed(Scene_item* if(poly_item) { // erase assoc polylines item scene->erase( scene->item_id( get_hole_visualizer(poly_item) ) ); + visualizers.remove(poly_item); // close accept-reject dialog if it is open if(last_active_item == poly_item) { on_Accept_button(); @@ -460,6 +460,7 @@ void Polyhedron_demo_hole_filling_plugin::on_Visualize_holes_button() { } Scene_hole_visualizer* hole_visualizer = new Scene_hole_visualizer(poly_item, mw); + visualizers[poly_item] = hole_visualizer; connect(hole_visualizer, SIGNAL(itemChanged()), this, SLOT(hole_visualizer_changed())); if(hole_visualizer->polyline_data_list.empty()) { @@ -589,6 +590,7 @@ void Polyhedron_demo_hole_filling_plugin::on_Reject_button() { void Polyhedron_demo_hole_filling_plugin::hole_visualizer_changed() { Scene_hole_visualizer* hole_visualizer = qobject_cast(this->sender()); if(hole_visualizer && hole_visualizer->polyline_data_list.empty()) { + visualizers.remove(hole_visualizer->poly_item); scene->erase( scene->item_id(hole_visualizer)); } } From 4256bcc2a846cbee5d3becbd8c99b07c5997df75 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 11 Aug 2015 12:01:31 +0200 Subject: [PATCH 20/35] hole_filling fox - The QMap wasn't updated when the visualizer is deleted. --- .../Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp index daedacd0fab..7871f422d1d 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp @@ -426,12 +426,18 @@ void Polyhedron_demo_hole_filling_plugin::item_about_to_be_destroyed(Scene_item* if(poly_item) { // erase assoc polylines item scene->erase( scene->item_id( get_hole_visualizer(poly_item) ) ); - visualizers.remove(poly_item); + visualizers.remove(poly_item); // close accept-reject dialog if it is open if(last_active_item == poly_item) { on_Accept_button(); } } + else { + Scene_hole_visualizer* visu_item = qobject_cast(scene_item); + if(visu_item) { + visualizers.remove(visu_item->poly_item); + } + } } // removes Scene_hole_visualizer items void Polyhedron_demo_hole_filling_plugin::dock_widget_closed() { @@ -590,8 +596,8 @@ void Polyhedron_demo_hole_filling_plugin::on_Reject_button() { void Polyhedron_demo_hole_filling_plugin::hole_visualizer_changed() { Scene_hole_visualizer* hole_visualizer = qobject_cast(this->sender()); if(hole_visualizer && hole_visualizer->polyline_data_list.empty()) { - visualizers.remove(hole_visualizer->poly_item); scene->erase( scene->item_id(hole_visualizer)); + visualizers.remove(hole_visualizer->poly_item); } } // helper function for filling holes From 3291077b16596117751d6c79805bc37d975aef31 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 11 Aug 2015 12:01:31 +0200 Subject: [PATCH 21/35] hole_filling fix - The QMap wasn't updated when the visualizer is deleted. --- .../Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp index daedacd0fab..7871f422d1d 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp @@ -426,12 +426,18 @@ void Polyhedron_demo_hole_filling_plugin::item_about_to_be_destroyed(Scene_item* if(poly_item) { // erase assoc polylines item scene->erase( scene->item_id( get_hole_visualizer(poly_item) ) ); - visualizers.remove(poly_item); + visualizers.remove(poly_item); // close accept-reject dialog if it is open if(last_active_item == poly_item) { on_Accept_button(); } } + else { + Scene_hole_visualizer* visu_item = qobject_cast(scene_item); + if(visu_item) { + visualizers.remove(visu_item->poly_item); + } + } } // removes Scene_hole_visualizer items void Polyhedron_demo_hole_filling_plugin::dock_widget_closed() { @@ -590,8 +596,8 @@ void Polyhedron_demo_hole_filling_plugin::on_Reject_button() { void Polyhedron_demo_hole_filling_plugin::hole_visualizer_changed() { Scene_hole_visualizer* hole_visualizer = qobject_cast(this->sender()); if(hole_visualizer && hole_visualizer->polyline_data_list.empty()) { - visualizers.remove(hole_visualizer->poly_item); scene->erase( scene->item_id(hole_visualizer)); + visualizers.remove(hole_visualizer->poly_item); } } // helper function for filling holes From e3c53da3113b3f9665ef57eee100c07966e33bde Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 11 Aug 2015 12:20:27 +0200 Subject: [PATCH 22/35] No holes fix - If the visualizer was created with an item without a hole, the QMap was not updated when the visualizer was destroyed. --- .../demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp index 7871f422d1d..43a9325e747 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp @@ -308,7 +308,6 @@ public: void init(QMainWindow* mainWindow, Scene_interface* scene_interface, Messages_interface* m); Scene_hole_visualizer* get_hole_visualizer(Scene_polyhedron_item* poly_item) { - return visualizers[poly_item]; } @@ -471,6 +470,7 @@ void Polyhedron_demo_hole_filling_plugin::on_Visualize_holes_button() { if(hole_visualizer->polyline_data_list.empty()) { print_message("There is no hole in selected polyhedron item!"); + visualizers.remove(poly_item); delete hole_visualizer; return; } From 9257bf2c0386a3a7f9c290d2157f40bb7ec70355 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 11 Aug 2015 14:19:01 +0200 Subject: [PATCH 23/35] DrawText fix - Must disable the polygon offset after drawing so that it does not disturb the postdraw function. --- Polyhedron/demo/Polyhedron/Scene.cpp | 1 + Polyhedron/demo/Polyhedron/Viewer.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index fd4540f465a..fc573bc5776 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -383,6 +383,7 @@ glDepthFunc(GL_LEQUAL); } } glDepthFunc(GL_LESS); + } int diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index 78e08c6dee0..6c0644d69ea 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -202,6 +202,8 @@ void Viewer_impl::draw_aux(bool with_names, Viewer* viewer) scene->drawWithNames(viewer); else scene->draw(viewer); + ::glDisable(GL_POLYGON_OFFSET_FILL); + ::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); } void Viewer::drawWithNames() From 9cc40133ec893b4190e30a5867ab428b0ee7aab7 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 11 Aug 2015 15:18:40 +0200 Subject: [PATCH 24/35] Fix shader error (removed spaces before #version) --- .../resources/shader_without_light.v | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/resources/shader_without_light.v b/Polyhedron/demo/Polyhedron/resources/shader_without_light.v index 6f9e362709b..1abc25b9b7d 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_without_light.v +++ b/Polyhedron/demo/Polyhedron/resources/shader_without_light.v @@ -1,12 +1,12 @@ - #version 330 - attribute highp vec4 vertex; - attribute highp vec3 colors; - uniform highp mat4 mvp_matrix; - uniform highp mat4 f_matrix; - varying highp vec4 color; - void main(void) - { - color = vec4(colors, 1.0); - gl_Position = mvp_matrix * f_matrix * vertex; - } +#version 330 +attribute highp vec4 vertex; +attribute highp vec3 colors; +uniform highp mat4 mvp_matrix; +uniform highp mat4 f_matrix; +varying highp vec4 color; +void main(void) +{ + color = vec4(colors, 1.0); + gl_Position = mvp_matrix * f_matrix * vertex; +} From 6b8d5ebce5bb5c41165bbadd784a4c5ba7c05650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 12 Aug 2015 11:03:40 +0200 Subject: [PATCH 25/35] change the bound for the filtering --- .../demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui b/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui index a699faed2b8..917d82a299a 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui @@ -30,7 +30,7 @@ 0.000000000000000 - 30.000000000000000 + 999999999.000000000000000 0.000000000000000 From 52a35d4d8d9b1a4a00fa5601ba95965e405b6cab Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 13 Aug 2015 08:55:10 +0200 Subject: [PATCH 26/35] Random displaying fix - The bounding box was set before being initialized. --- Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp index 0070d881bd3..f23bc783960 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp @@ -657,15 +657,14 @@ void Viewer::attrib_buffers(QGLViewer* viewer) void Viewer::sceneChanged() { - + compute_elements(); this->camera()->setSceneBoundingBox(qglviewer::Vec(bb.xmin(), bb.ymin(), bb.zmin()), qglviewer::Vec(bb.xmax(), bb.ymax(), bb.zmax())); - compute_elements(); - are_buffers_initialized = false; + are_buffers_initialized = false; this->showEntireScene(); } From 721647343678b2a6d81c67f6d8f3e48ab70c9741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 13 Aug 2015 10:00:11 +0200 Subject: [PATCH 27/35] add a warning in case of isolated vertices in an OFF loaded in a polyhedron --- .../Polyhedron/Polyhedron_demo_off_plugin.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp index 01bc86868bb..bc15dfda545 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp @@ -5,6 +5,9 @@ #include "Polyhedron_demo_io_plugin_interface.h" #include +#include +#include + class Polyhedron_demo_off_plugin : public QObject, public Polyhedron_demo_io_plugin_interface @@ -37,7 +40,13 @@ Polyhedron_demo_off_plugin::load(QFileInfo fileinfo) { std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl; return NULL; } - + + // to detect isolated vertices + CGAL::File_scanner_OFF scanner( in, false); + std::size_t total_nb_of_vertices = scanner.size_of_vertices(); + in.close(); + in.open(fileinfo.filePath().toUtf8()); + // Try to read .off in a polyhedron Scene_polyhedron_item* item = new Scene_polyhedron_item(); item->setName(fileinfo.baseName()); @@ -56,6 +65,14 @@ Polyhedron_demo_off_plugin::load(QFileInfo fileinfo) { } return soup_item; } + else + if( total_nb_of_vertices!= item->polyhedron()->size_of_vertices()) + { + QMessageBox::warning((QWidget*)NULL, + tr("Isolated vertices found"), + tr("%1 isolated vertices ignored") + .arg(total_nb_of_vertices-item->polyhedron()->size_of_vertices())); + } return item; } From ee2b0b2011cd232c451a5e71b262ac29b24cec2b Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 13 Aug 2015 11:56:04 +0200 Subject: [PATCH 28/35] Transparent facets fix - set the alpha value to 1 in the shaders to insure opaque color. --- Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp index f23bc783960..f9e325b493a 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp @@ -235,7 +235,7 @@ void Viewer::compile_shaders() "#version 120 \n" "attribute highp vec4 vertex;\n" "attribute highp vec3 normal;\n" - "attribute highp vec4 color;\n" + "attribute highp vec3 color;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" @@ -247,7 +247,7 @@ void Viewer::compile_shaders() "{\n" " fP = mv_matrix * vertex; \n" " fN = mat3(mv_matrix)* normal; \n" - " fColor = color; \n" + " fColor = vec4(color, 1.0); \n" " gl_Position = mvp_matrix * vertex;\n" "}" }; From 95f87a3ac5d8a5b30f84b83cb7b03e6df11e4809 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 13 Aug 2015 14:08:12 +0200 Subject: [PATCH 29/35] Depth test problem fix - Calling glEnable(GL_DEPTH_TEST) in the beginning of every draw should solve this problem. --- Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp | 1 + Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp | 1 + Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp | 1 + Mesh_3/demo/Mesh_3/src/CGAL_demo/Viewer.cpp | 1 + .../demo/Periodic_3_triangulation_3/Scene.cpp | 1 + Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp | 1 + Triangulation_3/demo/Triangulation_3/Viewer.cpp | 1 + 7 files changed, 7 insertions(+) diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp index dd13883e3df..363cd3466a7 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp @@ -325,6 +325,7 @@ void Viewer::compute_elements() void Viewer::draw() { + glEnable(GL_DEPTH_TEST); if(!are_buffers_initialized) initialize_buffers(); QColor color; diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp index b2a3e9ab4e9..50b4d6e6b01 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp +++ b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp @@ -783,6 +783,7 @@ void Viewer::attrib_buffers(QGLViewer* viewer) void Viewer::draw() { + glEnable(GL_DEPTH_TEST); QColor color; //sphere diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp index f9e325b493a..48569ec0990 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp @@ -670,6 +670,7 @@ Viewer::sceneChanged() void Viewer::draw() { + glEnable(GL_DEPTH_TEST); if(!are_buffers_initialized) initialize_buffers(); diff --git a/Mesh_3/demo/Mesh_3/src/CGAL_demo/Viewer.cpp b/Mesh_3/demo/Mesh_3/src/CGAL_demo/Viewer.cpp index 564ec702e70..e9ef91d85d2 100644 --- a/Mesh_3/demo/Mesh_3/src/CGAL_demo/Viewer.cpp +++ b/Mesh_3/demo/Mesh_3/src/CGAL_demo/Viewer.cpp @@ -53,6 +53,7 @@ void Viewer::initializeGL() void Viewer::draw_aux(bool with_names) { QGLViewer::draw(); + glEnable(GL_DEPTH_TEST); if(scene == 0) return; diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp index 05486d54280..b530307cb5a 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp @@ -780,6 +780,7 @@ void Scene::init() { // Draws the triangulation void Scene::draw() { + glEnable(GL_DEPTH_TEST); if(!are_buffers_initialized) initialize_buffers(); gl_draw_location(); diff --git a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp index 2e551b3097b..cd59c5dc42f 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp +++ b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp @@ -27,6 +27,7 @@ Viewer::sceneChanged() void Viewer::draw() { + glEnable(GL_DEPTH_TEST); if(!are_buffers_initialized) initialize_buffers(); QColor color; diff --git a/Triangulation_3/demo/Triangulation_3/Viewer.cpp b/Triangulation_3/demo/Triangulation_3/Viewer.cpp index 43c22bfb7af..495e52b8e4b 100644 --- a/Triangulation_3/demo/Triangulation_3/Viewer.cpp +++ b/Triangulation_3/demo/Triangulation_3/Viewer.cpp @@ -1193,6 +1193,7 @@ void Viewer::attrib_buffers(QGLViewer* viewer) void Viewer::draw() { + glEnable(GL_DEPTH_TEST); if(!are_buffers_initialized) initialize_buffers(); QFont fontPrompt("Arial", 8); From f6e86631a75f851b966f4bc241e48e5e89e60356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 13 Aug 2015 16:21:18 +0200 Subject: [PATCH 30/35] prevent from closing and reopening the stream --- Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp index bc15dfda545..30c6e3d0d76 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp @@ -44,8 +44,7 @@ Polyhedron_demo_off_plugin::load(QFileInfo fileinfo) { // to detect isolated vertices CGAL::File_scanner_OFF scanner( in, false); std::size_t total_nb_of_vertices = scanner.size_of_vertices(); - in.close(); - in.open(fileinfo.filePath().toUtf8()); + in.seekg(0); // Try to read .off in a polyhedron Scene_polyhedron_item* item = new Scene_polyhedron_item(); From a3addbfd9b3e4ee6b4349a2412b0275cb06c962f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 14 Aug 2015 13:56:43 +0200 Subject: [PATCH 31/35] Fix - Polyhedron : spaces in a shader made it invalid - Circular Kernel : green intersection spheres are back : wrong attribute in the draw function - Alpha Shapes : "in" remained in the shaders. --- Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp | 14 ++++++------ .../demo/Circular_kernel_3/Viewer.cpp | 5 +++-- .../resources/shader_without_light.v | 22 +++++++++---------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp index 363cd3466a7..a5a0dd2f222 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp @@ -30,8 +30,8 @@ void Viewer::compile_shaders() const char vertex_source[] = { "#version 120 \n" - "in highp vec4 vertex;\n" - "in highp vec3 normal;\n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" "uniform highp mat4 mvp_matrix;\n" "uniform highp mat4 mv_matrix; \n" @@ -44,12 +44,12 @@ void Viewer::compile_shaders() " gl_Position = mvp_matrix * vertex;\n" "}" }; - //Vertex source code + //Fragment source code const char fragment_source[] = { "#version 120 \n" - "in highp vec4 fP; \n" - "in highp vec3 fN; \n" + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" "uniform highp vec4 color; \n" "uniform vec4 light_pos; \n" "uniform vec4 light_diff; \n" @@ -105,8 +105,8 @@ rendering_program.bind(); //Vertex source code const char vertex_source_points[] = { - "#version 120 \n" - "in highp vec4 vertex;\n" + "#version 120 \n" + "attribute highp vec4 vertex;\n" "uniform highp mat4 mvp_matrix;\n" "void main(void)\n" diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp index 50b4d6e6b01..0036038b6de 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp +++ b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp @@ -193,6 +193,7 @@ void Viewer::initialize_buffers() buffers[2].release(); if(extension_is_found) { + glVertexAttribDivisor(trivialCenterLocation, 1); glVertexAttribDivisor(normalsLocation[0], 0); } @@ -240,7 +241,7 @@ void Viewer::initialize_buffers() vao[2].bind(); if(extension_is_found) { - //points of the sphere + //points of the spheres buffers[6].bind(); buffers[6].allocate(pos_sphere_inter.data(), static_cast(pos_sphere_inter.size()*sizeof(float))); @@ -807,7 +808,7 @@ void Viewer::draw() { rendering_program.bind(); rendering_program.setUniformValue(colorLocation, color); - glDrawArraysInstanced(GL_TRIANGLES, 0, static_cast(pos_points.size()/3), static_cast(pos_points.size()/3)); + glDrawArraysInstanced(GL_TRIANGLES, 0, static_cast(pos_sphere_inter.size()/3), static_cast(pos_points.size()/3)); rendering_program.release(); } else diff --git a/Polyhedron/demo/Polyhedron/resources/shader_without_light.v b/Polyhedron/demo/Polyhedron/resources/shader_without_light.v index 892328ae65c..69e5741f510 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_without_light.v +++ b/Polyhedron/demo/Polyhedron/resources/shader_without_light.v @@ -1,12 +1,12 @@ - #version 120 - attribute highp vec4 vertex; - attribute highp vec3 colors; - uniform highp mat4 mvp_matrix; - uniform highp mat4 f_matrix; - varying highp vec4 color; - void main(void) - { - color = vec4(colors, 1.0); - gl_Position = mvp_matrix * f_matrix * vertex; - } +#version 120 +attribute highp vec4 vertex; +attribute highp vec3 colors; +uniform highp mat4 mvp_matrix; +uniform highp mat4 f_matrix; +varying highp vec4 color; +void main(void) +{ + color = vec4(colors, 1.0); + gl_Position = mvp_matrix * f_matrix * vertex; +} From 9dc8e079ad629872326153eeec3735cfa7c288d5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 18 Aug 2015 18:19:54 +0200 Subject: [PATCH 32/35] QOpenGLShaderProgram::create was introduced in Qt-5.3 With Qt-5.2: error: 'class QOpenGLShaderProgram' has no member named 'create' Anyway, that call is useless. --- Mesh_3/demo/Mesh_3/Volume_plane.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Mesh_3/demo/Mesh_3/Volume_plane.h b/Mesh_3/demo/Mesh_3/Volume_plane.h index 4cc1e3e04f8..0efdaab4fb1 100644 --- a/Mesh_3/demo/Mesh_3/Volume_plane.h +++ b/Mesh_3/demo/Mesh_3/Volume_plane.h @@ -423,9 +423,6 @@ void Volume_plane::init() { template void Volume_plane::initShaders() { - program.create(); - - QOpenGLShader *vertex = new QOpenGLShader(QOpenGLShader::Vertex); vertex->compileSourceCode(vertexShader_source); @@ -436,7 +433,6 @@ void Volume_plane::initShaders() { program.link(); - program_bordures.create(); QOpenGLShader *vertex_bordures = new QOpenGLShader(QOpenGLShader::Vertex); vertex_bordures->compileSourceCode(vertexShader_bordures_source); From c9f16f89841c55048362e288fc43eb6bbc530d11 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 18 Aug 2015 18:46:02 +0200 Subject: [PATCH 33/35] Define the OpenGL functions typedefs - PFNGLDRAWARRAYSINSTANCEDARBPROC - PFNGLVERTEXATTRIBDIVISORARBPROC Definitions found in glext.h from Mesa. --- Circular_kernel_3/demo/Circular_kernel_3/Viewer.h | 2 ++ .../demo/Periodic_3_triangulation_3/Scene.h | 2 ++ Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h | 2 ++ Triangulation_3/demo/Triangulation_3/Viewer.h | 2 ++ 4 files changed, 8 insertions(+) diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h index f0ba2f3e78e..378fc42114d 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h +++ b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.h @@ -44,6 +44,8 @@ private: QOpenGLVertexArrayObject vao[3]; QOpenGLShaderProgram rendering_program; QOpenGLShaderProgram rendering_program_no_ext; + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; 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 a689bfad4cb..4c012aa04dc 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 @@ -293,6 +293,8 @@ private: QOpenGLShaderProgram rendering_program; QOpenGLShaderProgram rendering_program_spheres; QOpenGLShaderProgram rendering_program_cylinders; + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; void initialize_buffers(); diff --git a/Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h b/Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h index 05955d44373..fe99eda60b2 100644 --- a/Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h +++ b/Polyhedron/demo/Polyhedron/CGAL_demo/Viewer_interface.h @@ -30,6 +30,8 @@ public: static QString dumpFrame(const qglviewer::Frame&); virtual bool inFastDrawing() const = 0; + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; bool extension_is_found; diff --git a/Triangulation_3/demo/Triangulation_3/Viewer.h b/Triangulation_3/demo/Triangulation_3/Viewer.h index d32de675c84..c865f018a41 100644 --- a/Triangulation_3/demo/Triangulation_3/Viewer.h +++ b/Triangulation_3/demo/Triangulation_3/Viewer.h @@ -387,6 +387,8 @@ private: QOpenGLShaderProgram rendering_program; QOpenGLShaderProgram rendering_program_spheres; QOpenGLShaderProgram rendering_program_cylinders; + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; void initialize_buffers(); From 8c9b4975bcfcf847cf96406c3640549270e7599f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 18 Aug 2015 18:46:51 +0200 Subject: [PATCH 34/35] Fix a typedef --- .../include/CGAL/Periodic_3_triangulation_3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h index 6a21b1b4ff5..3bebc4df680 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h @@ -2175,6 +2175,7 @@ Periodic_3_triangulation_3::periodic_insert( // This only holds for Delaunay CGAL_triangulation_assertion(lt != VERTEX); + CGAL_USE(lt); // Choose the periodic copy of tester.point() that is inside c. Offset current_off = get_location_offset(tester, c); From 4463e53d0a84ee80cf0feb20ffc86ae249937a44 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 19 Aug 2015 15:57:29 +0200 Subject: [PATCH 35/35] Revert "add a dependency on the Qt5::QSQLiteDriverPlugin" This reverts commit 156b267d85dd2f8a5d92c944716138a501c7cb44. Conflicts: Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt The reason is that our demo does not depend on QtSql or any QtSql plugin. For details, see: https://github.com/CGAL/cgal/issues/254#issuecomment-132605984 --- .../demo/Periodic_3_triangulation_3/CMakeLists.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt index a0d4b6416ad..1da698a23fd 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt @@ -14,7 +14,7 @@ find_package(CGAL COMPONENTS Qt5) include( ${CGAL_USE_FILE} ) # Find Qt5 itself -find_package(Qt5 QUIET COMPONENTS Xml OpenGL Help Core Sql) +find_package(Qt5 QUIET COMPONENTS Xml OpenGL Help Core) # Find OpenGL find_package(OpenGL) @@ -25,7 +25,7 @@ if(Qt5_FOUND) find_package(QGLViewer) endif(Qt5_FOUND) -if (CGAL_FOUND AND CGAL_Qt5_FOUND AND OPENGL_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND TARGET Qt5::qcollectiongenerator AND TARGET Qt5::QSQLiteDriverPlugin) +if (CGAL_FOUND AND CGAL_Qt5_FOUND AND OPENGL_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND TARGET Qt5::qcollectiongenerator) include_directories( ${QGLVIEWER_INCLUDE_DIR} ) @@ -97,10 +97,6 @@ else () set(PERIODIC_TRIANGULATION_MISSING_DEPS "qcollectiongenerator, ${PERIODIC_TRIANGULATION_MISSING_DEPS}") endif() - if (NOT TARGET Qt5::QSQLiteDriverPlugin) - set(PERIODIC_TRIANGULATION_MISSING_DEPS "SQLite driver plugin, ${PERIODIC_TRIANGULATION_MISSING_DEPS}") - endif() - message(STATUS "NOTICE: This demo requires ${PERIODIC_TRIANGULATION_MISSING_DEPS}and will not be compiled.") endif ()