diff --git a/Mesh_3/demo/Mesh_3/CMakeLists.txt b/Mesh_3/demo/Mesh_3/CMakeLists.txt index 9c46df44a78..f5556d23830 100644 --- a/Mesh_3/demo/Mesh_3/CMakeLists.txt +++ b/Mesh_3/demo/Mesh_3/CMakeLists.txt @@ -167,7 +167,6 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND AND Boost_F add_library(${SCENE_ITEM_LIB} SHARED ${DEMO_SRC_DIR}/Scene_item.cpp Scene_item_moc.cpp - ${DEMO_SRC_DIR}/Scene_item_with_display_list.cpp ${DEMO_SRC_DIR}/Plugin_helper.cpp) qt5_use_modules(${SCENE_ITEM_LIB} Xml Script OpenGL Svg) set_target_properties(${SCENE_ITEM_LIB} PROPERTIES DEFINE_SYMBOL scene_item_EXPORTS) diff --git a/Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp b/Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp index cdc7a2e3ece..cc894397138 100644 --- a/Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp +++ b/Mesh_3/demo/Mesh_3/Scene_c3t3_item.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp b/Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp index eb4d95a8a2b..6d410ba491e 100644 --- a/Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp +++ b/Mesh_3/demo/Mesh_3/Scene_polyhedron_item.cpp @@ -31,12 +31,6 @@ Scene_polyhedron_item::Scene_polyhedron_item(const Polyhedron& p) compile_shaders(); } -// Scene_polyhedron_item::Scene_polyhedron_item(const Scene_polyhedron_item& item) -// : Scene_item_with_display_list(item), -// poly(new Polyhedron(*item.poly)) -// { -// } - Scene_polyhedron_item::~Scene_polyhedron_item() { for(int i=0; i #include #include -#include -#include */ +#include */ -#endif //STDAFX_H \ No newline at end of file +#endif //STDAFX_H diff --git a/Mesh_3/demo/Mesh_3/include/CGAL_demo/Scene_item_with_display_list.h b/Mesh_3/demo/Mesh_3/include/CGAL_demo/Scene_item_with_display_list.h deleted file mode 100644 index a332d5c34fe..00000000000 --- a/Mesh_3/demo/Mesh_3/include/CGAL_demo/Scene_item_with_display_list.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SCENE_ITEM_WITH_DISPLAY_LIST_H -#define SCENE_ITEM_WITH_DISPLAY_LIST_H - -#include -#include -#include - -// This class represents an object in the scene with an OpenGL rendering using display lists -class SCENE_ITEM_EXPORT Scene_item_with_display_list - : public Scene_item -{ -public: - Scene_item_with_display_list(); -// Scene_item_with_display_list(const Scene_item_with_display_list&); - ~Scene_item_with_display_list(); - - // Points/Wireframe/Flat/Gouraud OpenGL drawing in a display list - virtual void direct_draw(QGLViewer*) = 0; - virtual void direct_draw_edges(Viewer* viewer) { draw(viewer); } - // OpenGL drawing using a display list - virtual void draw(Viewer* viewer) ; - virtual void draw_edges(Viewer* viewer) ; -public Q_SLOTS: - - // Call that once you have finished changing something in the item - // (either the properties or internal data). - virtual void changed(); - -protected: - enum { DRAW = 0, DRAW_EDGES = 1, NB_OF_DISPLAY_LISTS = 2}; - void draw(Viewer* viewer,int) ; - // display lists - mutable GLuint display_list[NB_OF_DISPLAY_LISTS]; - mutable bool display_list_built[NB_OF_DISPLAY_LISTS]; - -}; // end class Scene_item_with_display_list - -#endif // SCENE_ITEM_WITH_DISPLAY_LIST_H diff --git a/Mesh_3/demo/Mesh_3/src/CGAL_demo/Scene_item_with_display_list.cpp b/Mesh_3/demo/Mesh_3/src/CGAL_demo/Scene_item_with_display_list.cpp deleted file mode 100644 index bad42209321..00000000000 --- a/Mesh_3/demo/Mesh_3/src/CGAL_demo/Scene_item_with_display_list.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include - -Scene_item_with_display_list::Scene_item_with_display_list() -{ - for(int i = 0; i < NB_OF_DISPLAY_LISTS; ++i) { - display_list[i] = 0; - display_list_built[i] = false; - } -} - -// Scene_item_with_display_list:: -// Scene_item_with_display_list(const Scene_item_with_display_list& item) -// : Scene_item(item), -// display_list(0), -// display_list_built(false) -// {} - -Scene_item_with_display_list::~Scene_item_with_display_list() -{ - for(int i = 0; i < NB_OF_DISPLAY_LISTS; ++i) { - if(display_list_built[i] && display_list[i] != 0) { - ::glDeleteLists(display_list[i],1); - } - } -} - -// Points/Wireframe/Flat/Gouraud OpenGL drawing in a display list - -void Scene_item_with_display_list::draw(Viewer* viewer) { - draw(viewer, DRAW); -} - -void Scene_item_with_display_list::draw_edges(Viewer* viewer) { - draw(viewer, DRAW_EDGES); -} - -void Scene_item_with_display_list::draw(Viewer* viewer, int i) -{ - if(!display_list_built[i]) - { - if(display_list[i] == 0) { - display_list[i] = ::glGenLists(1); - if(display_list[i] == 0) - { - std::cerr << "Unable to create display list" << std::endl; - return; - } - } - // draw the item in a display list - ::glNewList(display_list[i],GL_COMPILE_AND_EXECUTE); - if(i == 0) { - direct_draw(viewer); - } - else { - direct_draw_edges(viewer); - } - ::glEndList(); - display_list_built[i] = true; - } - else { - // draw using the display list - ::glCallList(display_list[i]); - } -} - -void Scene_item_with_display_list::changed() -{ - for(int i = 0; i < NB_OF_DISPLAY_LISTS; ++i) { - display_list_built[i] = false; - } - - -} diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index 0652a58785b..bcf1e0e88a6 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -182,9 +182,8 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) add_item(scene_polygon_soup_item Scene_polygon_soup_item.cpp)# Scene_polygon_soup_item.moc) target_link_libraries(scene_polygon_soup_item scene_polyhedron_item) - add_item(scene_nef_polyhedron_item Scene_nef_polyhedron_item.cpp# Scene_nef_polyhedron_item.moc - - Scene_nef_rendering.cpp) + add_item(scene_nef_polyhedron_item Scene_nef_polyhedron_item.cpp)# Scene_nef_polyhedron_item.moc + target_link_libraries(scene_nef_polyhedron_item scene_polyhedron_item) add_item(scene_points_with_normal_item Scene_points_with_normal_item.cpp)# Scene_points_with_normal_item.moc) diff --git a/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.cpp b/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.cpp index 00dfe5857f0..475c4670193 100644 --- a/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.cpp @@ -7,103 +7,11 @@ #include #include #include +#include #include #include -void Scene_combinatorial_map_item::initialize_buffers(Viewer_interface *viewer) -{ - viewer->glBindVertexArray(vao); - buffer[0] = QOpenGLBuffer(QOpenGLBuffer::VertexBuffer); - if(!(buffer[0].create())) - std::cout<<"ERROR lors de la creation"<(positions.size()*sizeof(float))); - /* - viewer->glVertexAttribPointer(0, //number of the buffer - 4, //number of floats to be taken - GL_FLOAT, // type of data - GL_FALSE, //not normalized - 0, //compact data (not in a struct) - NULL //no offset (seperated in several buffers) - ); - viewer->glEnableVertexAttribArray(0);*/ - // Clean-up - viewer->glBindVertexArray(0); - -} - -void Scene_combinatorial_map_item::compile_shaders(void) -{ - - //fill the vertex shader - static const char* vertex_shader_source = - { - "#version 300 es \n" - " \n" - "layout (location = 0) in vec3 positions; \n" - - "out highp vec3 fColors; \n" - " \n" - - "void main(void) \n" - "{ \n" - " fColors = vec3(1.0,0.0,0.0); \n" - " gl_Position = mvp_matrix * vec4(positions, 1.0); \n" - "} \n" - }; - //fill the fragment shader - static const char* fragment_shader_source = - { - "#version 300 es \n" - " \n" - "in highp vec3 fColors; \n" - - "out highp vec4 color; \n" - " \n" - "void main(void) \n" - "{ \n" - " color = vec4(fColors, 1.0); \n" - "} \n" - }; - - QOpenGLShader *vertex_shader = new QOpenGLShader(QOpenGLShader::Vertex); - if(!vertex_shader->compileSourceCode(vertex_shader_source)) - std::cout<log().toStdString()<compileSourceCode(fragment_shader_source)) - std::cout<log().toStdString()<addShader(vertex_shader)) - std::cout<log().toStdString()<addShader(fragment_shader)) - std::cout<log().toStdString()<link(); - -} - -void Scene_combinatorial_map_item::compute_normals_and_vertices(void) -{ - positions.push_back(-1.0); - positions.push_back(-1.0); - positions.push_back(0.0); - - positions.push_back(0.0); - positions.push_back(1.0); - positions.push_back(0.0); - - positions.push_back(1.0); - positions.push_back(-1.0); - positions.push_back(0.0); - -} - - -Scene_combinatorial_map_item::Scene_combinatorial_map_item(Scene_interface* scene,void* address):last_known_scene(scene),volume_to_display(0),exportSelectedVolume(NULL),address_of_A(address){m_combinatorial_map=NULL;} +Scene_combinatorial_map_item::Scene_combinatorial_map_item(Scene_interface* scene,void* address):last_known_scene(scene),volume_to_display(0),exportSelectedVolume(NULL),address_of_A(address){m_combinatorial_map=NULL; are_buffers_filled = false;;} Scene_combinatorial_map_item::~Scene_combinatorial_map_item(){if (m_combinatorial_map!=NULL) delete m_combinatorial_map;} Scene_combinatorial_map_item* Scene_combinatorial_map_item::clone() const{return NULL;} @@ -140,8 +48,10 @@ Kernel::Vector_3 Scene_combinatorial_map_item::compute_face_normal(Combinatorial } void Scene_combinatorial_map_item::set_next_volume(){ + //Update des vectors faits ici ++volume_to_display; volume_to_display=volume_to_display%(combinatorial_map().attributes<3>().size()+1); + are_buffers_filled = false; Q_EMIT itemChanged(); if (exportSelectedVolume!=NULL && ( volume_to_display==1 || volume_to_display==0 ) ) @@ -315,34 +225,15 @@ bool Scene_combinatorial_map_item::keyPressEvent(QKeyEvent* e){ return false; } -void Scene_combinatorial_map_item::direct_draw() const { -#if 0 - typedef Combinatorial_map_3::One_dart_per_cell_const_range<3> Volume_dart_range; - typedef Combinatorial_map_3::One_dart_per_incident_cell_const_range<2,3> Facet_in_volume_drange; - typedef Combinatorial_map_3::Dart_of_orbit_const_range<1> Dart_in_facet_range; - Volume_dart_range dart_per_volume_range = combinatorial_map().one_dart_per_cell<3>(); - std::cout<<"COUCOU"<(vit); - - for(Facet_in_volume_drange::const_iterator fit=facet_range.begin();fit!=facet_range.end();++fit){ - Dart_in_facet_range vertices=combinatorial_map().darts_of_orbit<1>(fit); - Kernel::Vector_3 normal = compute_face_normal(fit); - - ::glBegin(GL_POLYGON); - ::glNormal3d(normal.x(),normal.y(),normal.z()); - - for (Dart_in_facet_range::const_iterator pit=vertices.begin();pit!=vertices.end();++pit ){ - const Kernel::Point_3& p= pit->attribute<0>()->point(); - ::glVertex3d(p.x(),p.y(),p.z()); - } - ::glEnd(); - } - } -#else std::size_t index = 0; int voltreated = combinatorial_map().get_new_mark(); int facetreated = combinatorial_map().get_new_mark(); @@ -373,8 +264,12 @@ void Scene_combinatorial_map_item::direct_draw() const { if ( !combinatorial_map().is_marked(vol_it,facetreated) ) { Kernel::Vector_3 normal = compute_face_normal(vol_it); - ::glBegin(GL_POLYGON); - ::glNormal3d(normal.x(),normal.y(),normal.z()); + for(int i=0; i<3; i++) + { + normals.push_back(normal.x()); + normals.push_back(normal.y()); + normals.push_back(normal.z()); + } //iterate over all darts of facets for ( Combinatorial_map_3::Dart_of_orbit_const_range<1>::const_iterator @@ -383,11 +278,12 @@ void Scene_combinatorial_map_item::direct_draw() const { face_it!=face_end; ++face_it) { const Kernel::Point_3& p= face_it->attribute<0>()->point(); - ::glVertex3d(p.x(),p.y(),p.z()); + positions_facets.push_back(p.x()); + positions_facets.push_back(p.y()); + positions_facets.push_back(p.z()); combinatorial_map().mark(face_it,facetreated); combinatorial_map().mark(face_it, voltreated); } - ::glEnd(); } } } @@ -403,32 +299,102 @@ void Scene_combinatorial_map_item::direct_draw() const { combinatorial_map().free_mark(facetreated); combinatorial_map().free_mark(voltreated); -#endif + } + + //edges + { + + typedef Combinatorial_map_3::One_dart_per_cell_const_range<1> Edge_darts; + Edge_darts darts=combinatorial_map().one_dart_per_cell<1>(); + for (Edge_darts::const_iterator dit=darts.begin();dit!=darts.end();++dit){ + CGAL_assertion(!dit->is_free(1)); + const Kernel::Point_3& a = dit->attribute<0>()->point(); + const Kernel::Point_3& b = dit->beta(1)->attribute<0>()->point(); + positions_lines.push_back(a.x()); + positions_lines.push_back(a.y()); + positions_lines.push_back(a.z()); + + positions_lines.push_back(b.x()); + positions_lines.push_back(b.y()); + positions_lines.push_back(b.z()); + + } + } + + //points + { + typedef Combinatorial_map_3::Attribute_const_range<0>::type Point_range; + const Point_range& points=combinatorial_map().attributes<0>(); + for(Point_range::const_iterator pit=boost::next(points.begin());pit!=points.end();++pit){ + const Kernel::Point_3& p=pit->point(); + positions_points.push_back(p.x()); + positions_points.push_back(p.y()); + positions_points.push_back(p.z()); + } + + } + } -void Scene_combinatorial_map_item::direct_draw_edges() const { - typedef Combinatorial_map_3::One_dart_per_cell_const_range<1> Edge_darts; - Edge_darts darts=combinatorial_map().one_dart_per_cell<1>(); - ::glBegin(GL_LINES); - for (Edge_darts::const_iterator dit=darts.begin();dit!=darts.end();++dit){ - CGAL_assertion(!dit->is_free(1)); - const Kernel::Point_3& a = dit->attribute<0>()->point(); - const Kernel::Point_3& b = dit->beta(1)->attribute<0>()->point(); - ::glVertex3d(a.x(),a.y(),a.z()); - ::glVertex3d(b.x(),b.y(),b.z()); - } - ::glEnd(); -} +void Scene_combinatorial_map_item::initialize_buffers(Viewer_interface *viewer) const +{ + //vao for the edges + { + program = getShaderProgram(PROGRAM_WITHOUT_LIGHT, viewer); + program->bind(); -void Scene_combinatorial_map_item::draw_points() const{ - typedef Combinatorial_map_3::Attribute_const_range<0>::type Point_range; - const Point_range& points=combinatorial_map().attributes<0>(); - ::glBegin(GL_POINTS); - for(Point_range::const_iterator pit=boost::next(points.begin());pit!=points.end();++pit){ - const Kernel::Point_3& p=pit->point(); - ::glVertex3d(p.x(),p.y(),p.z()); + vaos[0]->bind(); + buffers[0].bind(); + buffers[0].allocate(positions_lines.data(), + static_cast(positions_lines.size()*sizeof(double))); + program->enableAttributeArray("vertex"); + program->setAttributeBuffer("vertex",GL_DOUBLE,0,3); + buffers[0].release(); + + vaos[0]->release(); + program->release(); } - ::glEnd(); + //vao for the points + { + program = getShaderProgram(PROGRAM_WITHOUT_LIGHT, viewer); + program->bind(); + + vaos[1]->bind(); + buffers[1].bind(); + buffers[1].allocate(positions_points.data(), + static_cast(positions_points.size()*sizeof(double))); + program->enableAttributeArray("vertex"); + program->setAttributeBuffer("vertex",GL_DOUBLE,0,3); + buffers[1].release(); + vaos[1]->release(); + program->release(); + } + //vao for the facets + { + program = getShaderProgram(PROGRAM_WITH_LIGHT, viewer); + program->bind(); + + vaos[2]->bind(); + buffers[2].bind(); + buffers[2].allocate(positions_facets.data(), + static_cast(positions_facets.size()*sizeof(double))); + program->enableAttributeArray("vertex"); + program->setAttributeBuffer("vertex",GL_DOUBLE,0,3); + buffers[2].release(); + + buffers[3].bind(); + buffers[3].allocate(normals.data(), + static_cast(positions_facets.size()*sizeof(double))); + program->enableAttributeArray("normals"); + program->setAttributeBuffer("normals",GL_DOUBLE,0,3); + buffers[3].release(); + + vaos[2]->release(); + program->release(); + } + are_buffers_filled = true; + + } bool Scene_combinatorial_map_item::isEmpty() const {return combinatorial_map().number_of_darts()==0;} @@ -491,3 +457,54 @@ QString Scene_combinatorial_map_item::toolTip() const{ } +void Scene_combinatorial_map_item::draw(Viewer_interface* viewer) const +{ + if(!are_buffers_filled) + { + compute_elements(); + initialize_buffers(viewer); + } + vaos[2]->bind(); + program=getShaderProgram(PROGRAM_WITH_LIGHT); + attrib_buffers(viewer,PROGRAM_WITH_LIGHT); + program->bind(); + program->setAttributeValue("colors", this->color()); + viewer->glDrawArrays(GL_TRIANGLES, 0, static_cast(positions_facets.size()/3)); + vaos[2]->release(); + program->release(); + +} + void Scene_combinatorial_map_item::draw_edges(Viewer_interface* viewer) const +{ + if(!are_buffers_filled) + { + compute_elements(); + initialize_buffers(viewer); + } + vaos[0]->bind(); + program=getShaderProgram(PROGRAM_WITHOUT_LIGHT); + attrib_buffers(viewer,PROGRAM_WITHOUT_LIGHT); + program->bind(); + program->setAttributeValue("colors", this->color()); + viewer->glDrawArrays(GL_LINES, 0, static_cast(positions_lines.size()/3)); + vaos[0]->release(); + program->release(); + +} + void Scene_combinatorial_map_item::draw_points(Viewer_interface* viewer) const +{ + if(!are_buffers_filled) + { + compute_elements(); + initialize_buffers(viewer); + } + vaos[1]->bind(); + program=getShaderProgram(PROGRAM_WITHOUT_LIGHT); + attrib_buffers(viewer,PROGRAM_WITHOUT_LIGHT); + program->bind(); + program->setAttributeValue("colors", this->color()); + viewer->glDrawArrays(GL_POINTS, 0, static_cast(positions_points.size()/3)); + vaos[1]->release(); + program->release(); + +} diff --git a/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.h b/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.h index f23761103c0..fef1a201cb5 100644 --- a/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.h @@ -42,10 +42,10 @@ public: virtual bool supportsRenderingMode(RenderingMode m) const { return (m != Gouraud && m!=PointsPlusNormals); } // CHECK THIS! //Event handling virtual bool keyPressEvent(QKeyEvent*); - // OpenGL drawing in a display list - void direct_draw() const; - void direct_draw_edges() const; - void draw_points() const; + //drawing of the scene + virtual void draw_edges(Viewer_interface* viewer) const; + virtual void draw_points(Viewer_interface*) const; + virtual void draw(Viewer_interface*) const; bool isFinite() const { return true; } bool is_from_corefinement() const {return address_of_A!=NULL;} @@ -72,19 +72,18 @@ private: void* address_of_A; template void export_as_polyhedron(Predicate,const QString&) const; - std::vector positions; - std::vector normals; - std::vector color_lines; - std::vector color_facets; - QOpenGLShaderProgram *rendering_program; - GLint location[9]; + mutable std::vector positions_lines; + mutable std::vector positions_points; + mutable std::vector positions_facets; + mutable std::vector normals; - GLuint vao; - QOpenGLBuffer buffer[5]; - void initialize_buffers(Viewer_interface*); - void compile_shaders(void); - void compute_normals_and_vertices(void); + mutable QOpenGLShaderProgram *program; + + using Scene_item::initialize_buffers; + void initialize_buffers(Viewer_interface *viewer) const; + + void compute_elements(void) const; public Q_SLOTS: void set_next_volume(); diff --git a/Polyhedron/demo/Polyhedron/Scene_item.h b/Polyhedron/demo/Polyhedron/Scene_item.h index 799dad543b9..3f63da6a189 100644 --- a/Polyhedron/demo/Polyhedron/Scene_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_item.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp index 9a4ed13f2d4..a029dbde921 100644 --- a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp @@ -9,7 +9,6 @@ #include #include -#include "Scene_nef_rendering.h" #include #include @@ -453,25 +452,6 @@ Scene_nef_polyhedron_item::toolTip() const .arg(nef_poly->number_of_volumes()); } -void -Scene_nef_polyhedron_item::direct_draw(Viewer_interface* viewer) const { - gl_render_nef_facets(nef_poly); - - GLboolean lighting; - viewer->glGetBooleanv(GL_LIGHTING, &lighting); - viewer->glDisable(GL_LIGHTING); - - GLfloat point_size; - viewer->glGetFloatv(GL_POINT_SIZE, &point_size); - viewer->glPointSize(10.f); - - gl_render_nef_vertices(nef_poly); - - if(lighting) { - viewer->glEnable(GL_LIGHTING); - } - viewer->glPointSize(point_size); -} void Scene_nef_polyhedron_item::draw(Viewer_interface* viewer) const { if(!are_buffers_filled) diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h index 12497f05cf5..ef18fd8bb3e 100644 --- a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h @@ -30,8 +30,6 @@ public: virtual void selection_changed(bool); // Indicate if rendering mode is supported virtual bool supportsRenderingMode(RenderingMode m) const { return m != Gouraud; } // CHECK THIS! - // OpenGL drawing in a display list - void direct_draw(Viewer_interface*) const; virtual void draw(Viewer_interface*) const; virtual void draw_edges() const {} diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_rendering.cpp b/Polyhedron/demo/Polyhedron/Scene_nef_rendering.cpp deleted file mode 100644 index fb0eef97656..00000000000 --- a/Polyhedron/demo/Polyhedron/Scene_nef_rendering.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include "config.h" -#ifdef CGAL_POLYHEDRON_DEMO_USE_NEF -#include "Nef_type.h" -#include -#include -#include - -#include - -#define GL_MACRO(type) case type: std::cerr << #type; break; - -inline void CGAL_GLU_TESS_CALLBACK beginCallback(GLenum which) -{ -// std::cerr << "glBegin("; -// switch(which) -// { -// GL_MACRO(GL_POINTS); -// GL_MACRO(GL_LINES); -// GL_MACRO(GL_LINE_STRIP); -// GL_MACRO(GL_LINE_LOOP); -// GL_MACRO(GL_TRIANGLES); -// GL_MACRO(GL_TRIANGLE_STRIP); -// GL_MACRO(GL_TRIANGLE_FAN); -// GL_MACRO(GL_QUADS); -// GL_MACRO(GL_QUAD_STRIP); -// GL_MACRO(GL_POLYGON); -// } -// std::cerr << ")\n"; - glBegin(which); -} - -inline void CGAL_GLU_TESS_CALLBACK endCallback(void) -{ -// std::cerr << "glEnd()\n"; - glEnd(); -} - -inline void CGAL_GLU_TESS_CALLBACK errorCallback(GLenum errorCode) -{ const GLubyte *estring; - estring = gluErrorString(errorCode); - fprintf(stderr, "Tessellation Error: %s\n", estring); - std::exit (0); -} - -inline void CGAL_GLU_TESS_CALLBACK vertexCallback(GLvoid* vertex, - GLvoid* user) -{ GLdouble* pc(static_cast(vertex)); - GLdouble* pu(static_cast(user)); - // CGAL_NEF_TRACEN("vertexCallback coord "<sncp()) - - - GLboolean old_light_model; - ::glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE, &old_light_model); - - ::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); - GLUtesselator* tess_ = ::gluNewTess(); - ::gluTessCallback(tess_, GLenum(GLU_TESS_VERTEX_DATA), - (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &vertexCallback); - ::gluTessCallback(tess_, GLenum(GLU_TESS_BEGIN), - (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &beginCallback); - ::gluTessCallback(tess_, GLenum(GLU_TESS_END), - (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &endCallback); - ::gluTessCallback(tess_, GLenum(GLU_TESS_ERROR), - (GLvoid (CGAL_GLU_TESS_CALLBACK *)(CGAL_GLU_TESS_DOTS)) &errorCallback); - ::gluTessProperty(tess_, GLenum(GLU_TESS_WINDING_RULE), - GLU_TESS_WINDING_POSITIVE); - - for(Nef_polyhedron::Halffacet_const_iterator - f = p->halffacets_begin (), - end = p->halffacets_end(); - f != end; ++f) - { - if(f->is_twin()) continue; - - Nef_polyhedron::Vector_3 v = f->plane().orthogonal_vector(); - GLdouble normal[3]; - normal[0] = CGAL::to_double(v.x()); - normal[1] = CGAL::to_double(v.y()); - normal[2] = CGAL::to_double(v.z()); - GLdouble norm = normal[0]*normal[0] - + normal[1]*normal[1] - + normal[2]*normal[2]; - norm = CGAL::sqrt(norm); - - normal[0] /= norm; - normal[1] /= norm; - normal[2] /= norm; - - ::gluTessBeginPolygon(tess_, normal); - ::gluTessNormal(tess_,normal[0],normal[1],normal[2]); - - QList points; - for(Nef_polyhedron::Halffacet_cycle_const_iterator - fc = f->facet_cycles_begin(), - end = f->facet_cycles_end(); - fc != end; ++fc) - { - if ( fc.is_shalfedge() ) - { - ::gluTessBeginContour(tess_); - - Nef_polyhedron::SHalfedge_const_handle h = fc; - Nef_polyhedron::SHalfedge_around_facet_const_circulator hc(h), he(hc); - CGAL_For_all(hc,he){ // all vertex coordinates in facet cycle - Nef_polyhedron::SVertex_const_handle v = hc->source(); - const Nef_polyhedron::Point_3& point = v->source()->point(); - int i = points.size(); - DPoint dp(CGAL::to_double(point.x()), - CGAL::to_double(point.y()), - CGAL::to_double(point.z())); - points.push_back(dp); - - ::gluTessVertex(tess_, - static_cast(static_cast(&(points[i].coords))), - &(points[i].coords)); - } // end facet cycles verticeses - - ::gluTessEndContour(tess_); - } - } // end facet cycles - ::gluTessEndPolygon(tess_); - } // end facets - ::gluDeleteTess(tess_); - - ::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, old_light_model); - - GLenum gl_error = ::glGetError(); - if(gl_error != GL_NO_ERROR) - { - std::cerr << "OPENGL ERROR in gl_render_nef_facets!\n " - << ::gluErrorString(gl_error) << "\n"; - } -} // end gl_render_nef_facets - -void gl_render_nef_edges(Nef_polyhedron *p) -{ - ::glBegin(GL_LINES); - - for(Nef_polyhedron::Halfedge_const_iterator - e = p->halfedges_begin(), - end = p->halfedges_end(); - e != end; ++e) - { - if (e->is_twin()) continue; - const Nef_polyhedron::Vertex_const_handle& s = e->source(); - const Nef_polyhedron::Vertex_const_handle& t = e->twin()->source(); - const Nef_polyhedron::Point_3& a = s->point(); - const Nef_polyhedron::Point_3& b = t->point(); - ::glVertex3d(CGAL::to_double(a.x()), - CGAL::to_double(a.y()), - CGAL::to_double(a.z())); - ::glVertex3d(CGAL::to_double(b.x()), - CGAL::to_double(b.y()), - CGAL::to_double(b.z())); - } - - ::glEnd(); - GLenum gl_error = ::glGetError(); - if(gl_error != GL_NO_ERROR) - { - std::cerr << "OPENGL ERROR in gl_render_nef_edges!\n " - << ::gluErrorString(gl_error) << "\n"; - } -} - -void gl_render_nef_vertices(Nef_polyhedron* p) -{ - ::glBegin(GL_POINTS); - - for(Nef_polyhedron::Vertex_const_iterator - v = p->vertices_begin(), - end = p->vertices_end(); - v != end; ++v) - { - const Nef_polyhedron::Point_3& p = v->point(); - ::glVertex3d(CGAL::to_double(p.x()), - CGAL::to_double(p.y()), - CGAL::to_double(p.z())); - } - - ::glEnd(); - GLenum gl_error = ::glGetError(); - if(gl_error != GL_NO_ERROR) - { - std::cerr << "OPENGL ERROR in gl_render_nef_vertices!\n " - << ::gluErrorString(gl_error) << "\n"; - } -} -#endif // CGAL_POLYHEDRON_DEMO_USE_NEF diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_rendering.h b/Polyhedron/demo/Polyhedron/Scene_nef_rendering.h deleted file mode 100644 index 2b030416401..00000000000 --- a/Polyhedron/demo/Polyhedron/Scene_nef_rendering.h +++ /dev/null @@ -1,5 +0,0 @@ -#include "Nef_type_fwd.h" - -void gl_render_nef_facets(Nef_polyhedron* poly); -void gl_render_nef_edges(Nef_polyhedron* poly); -void gl_render_nef_vertices(Nef_polyhedron* poly);