diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer.h b/GraphicsView/include/CGAL/Qt/Basic_viewer.h index 9a5a550bafb..5edb37268f0 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer.h @@ -67,37 +67,6 @@ const char vertex_source_color[] = "}" }; -//Vertex source code -/* const char fragment_source_mono[] = - { - "#version 120 \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" - "uniform highp vec4 color; \n" - "uniform vec4 light_pos; \n" - "uniform vec4 light_diff; \n" - "uniform vec4 light_spec; \n" - "uniform vec4 light_amb; \n" - "uniform float spec_power ; \n" - - "void main(void) { \n" - - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" - - " vec3 N = normalize(fN); \n" - " L = normalize(L); \n" - " V = normalize(V); \n" - - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" - - "gl_FragColor = light_amb*color + diffuse ; \n" - "} \n" - "\n" - }; */ - const char fragment_source_color[] = { "#version 120 \n" @@ -141,7 +110,7 @@ const char vertex_source_p_l[] = " gl_Position = mvp_matrix * vertex;\n" "}" }; -//Vertex source code + const char fragment_source_p_l[] = { "#version 120 \n" @@ -227,7 +196,6 @@ public: m_are_buffers_initialized(false), m_face_started(false) { - arrays.resize(LAST_INDEX); if (title[0]==0) setWindowTitle("CGAL Basic Viewer"); else @@ -600,25 +568,22 @@ protected: void initialize_buffers() { - int bufn = 0; - rendering_program_p_l.bind(); // 1) POINT SHADER // 1.1) Mono points vao[VAO_MONO_POINTS].bind(); - + + int bufn = 0; assert(bufn(arrays[POS_MONO_POINTS].size()*sizeof(float))); - vertexLocation[VAO_MONO_POINTS] = rendering_program_p_l.attributeLocation("vertex"); - rendering_program_p_l.enableAttributeArray(vertexLocation[VAO_MONO_POINTS]); - rendering_program_p_l.setAttributeBuffer(vertexLocation[VAO_MONO_POINTS],GL_FLOAT,0,3); + rendering_program_p_l.enableAttributeArray("vertex"); + rendering_program_p_l.setAttributeBuffer("vertex",GL_FLOAT,0,3); buffers[bufn].release(); - ++bufn; rendering_program_p_l.disableAttributeArray("color"); @@ -627,17 +592,16 @@ protected: // 1.2) Color points vao[VAO_COLORED_POINTS].bind(); + ++bufn; assert(bufn(arrays[POS_COLORED_POINTS].size()*sizeof(float))); - vertexLocation[VAO_COLORED_POINTS] = rendering_program_p_l.attributeLocation("vertex"); - rendering_program_p_l.enableAttributeArray(vertexLocation[VAO_COLORED_POINTS]); - rendering_program_p_l.setAttributeBuffer(vertexLocation[VAO_COLORED_POINTS],GL_FLOAT,0,3); - + rendering_program_p_l.enableAttributeArray("vertex"); + rendering_program_p_l.setAttributeBuffer("vertex",GL_FLOAT,0,3); buffers[bufn].release(); - ++bufn; + ++bufn; assert(bufn(arrays[POS_MONO_SEGMENTS].size()*sizeof(float))); - vertexLocation[VAO_MONO_SEGMENTS] = rendering_program_p_l.attributeLocation("vertex"); - rendering_program_p_l.enableAttributeArray(vertexLocation[VAO_MONO_SEGMENTS]); - rendering_program_p_l.setAttributeBuffer(vertexLocation[VAO_MONO_SEGMENTS],GL_FLOAT,0,3); + rendering_program_p_l.enableAttributeArray("vertex"); + rendering_program_p_l.setAttributeBuffer("vertex",GL_FLOAT,0,3); buffers[bufn].release(); - ++bufn; rendering_program_p_l.disableAttributeArray("color"); @@ -670,18 +633,18 @@ protected: // 1.2) Color segments vao[VAO_COLORED_SEGMENTS].bind(); - + + ++bufn; assert(bufn(arrays[POS_COLORED_SEGMENTS].size()*sizeof(float))); - vertexLocation[VAO_COLORED_SEGMENTS] = rendering_program_p_l.attributeLocation("vertex"); - rendering_program_p_l.enableAttributeArray(vertexLocation[VAO_COLORED_SEGMENTS]); - rendering_program_p_l.setAttributeBuffer(vertexLocation[VAO_COLORED_SEGMENTS],GL_FLOAT,0,3); + rendering_program_p_l.enableAttributeArray("vertex"); + rendering_program_p_l.setAttributeBuffer("vertex",GL_FLOAT,0,3); buffers[bufn].release(); - ++bufn; + ++bufn; assert(bufn(arrays[POS_MONO_FACES].size()*sizeof(float))); - vertexLocation[VAO_MONO_FACES] = rendering_program_face.attributeLocation("vertex"); - rendering_program_face.enableAttributeArray(vertexLocation[VAO_MONO_FACES]); - rendering_program_face.setAttributeBuffer(vertexLocation[VAO_MONO_FACES],GL_FLOAT,0,3); + rendering_program_face.enableAttributeArray("vertex"); + rendering_program_face.setAttributeBuffer("vertex",GL_FLOAT,0,3); buffers[bufn].release(); - ++bufn; // 3.1.2) normals of the mono faces + ++bufn; assert(bufn(arrays[SMOOTH_NORMAL_MONO_FACES].size()* sizeof(float))); } - normalsLocation = rendering_program_face.attributeLocation("normal"); - rendering_program_face.enableAttributeArray(normalsLocation); - rendering_program_face.setAttributeBuffer(normalsLocation,GL_FLOAT,0,3); + rendering_program_face.enableAttributeArray("normal"); + rendering_program_face.setAttributeBuffer("normal",GL_FLOAT,0,3); buffers[bufn].release(); - ++bufn; // 3.1.3) color of the mono faces rendering_program_face.disableAttributeArray("color"); - vao[VAO_MONO_FACES].release(); // 3.2) Color faces vao[VAO_COLORED_FACES].bind(); // 3.2.1) points of the color faces + ++bufn; assert(bufn(arrays[POS_COLORED_FACES].size()*sizeof(float))); - vertexLocation[VAO_COLORED_FACES] = rendering_program_face.attributeLocation("vertex"); - rendering_program_face.enableAttributeArray(vertexLocation[VAO_COLORED_FACES]); - rendering_program_face.setAttributeBuffer(vertexLocation[VAO_COLORED_FACES],GL_FLOAT,0,3); + rendering_program_face.enableAttributeArray("vertex"); + rendering_program_face.setAttributeBuffer("vertex",GL_FLOAT,0,3); buffers[bufn].release(); - ++bufn; // 3.2.2) normals of the color faces + ++bufn; assert(bufn(arrays[SMOOTH_NORMAL_COLORED_FACES].size()* sizeof(float))); } - normalsLocation = rendering_program_face.attributeLocation("normal"); - rendering_program_face.enableAttributeArray(normalsLocation); - rendering_program_face.setAttributeBuffer(normalsLocation,GL_FLOAT,0,3); + rendering_program_face.enableAttributeArray("normal"); + rendering_program_face.setAttributeBuffer("normal",GL_FLOAT,0,3); buffers[bufn].release(); - ++bufn; // 3.2.3) colors of the faces + ++bufn; assert(bufn(arrays[POS_MONO_POINTS].size()/3)); vao[VAO_MONO_POINTS].release(); - + vao[VAO_COLORED_POINTS].bind(); if (m_use_mono_color) { @@ -911,7 +856,6 @@ protected: color.setRgbF((double)m_edges_mono_color.red()/(double)255, (double)m_edges_mono_color.green()/(double)255, (double)m_edges_mono_color.blue()/(double)255); - // rendering_program_p_l.disableAttributeArray("color"); rendering_program_p_l.setAttributeValue("color",color); ::glLineWidth(m_size_edges); glDrawArrays(GL_LINES, 0, static_cast(arrays[POS_MONO_SEGMENTS].size()/3)); @@ -936,7 +880,7 @@ protected: rendering_program_p_l.release(); } - + if (m_draw_faces) { rendering_program_face.bind(); @@ -945,7 +889,6 @@ protected: color.setRgbF((double)m_faces_mono_color.red()/(double)255, (double)m_faces_mono_color.green()/(double)255, (double)m_faces_mono_color.blue()/(double)255); - //rendering_program_face.disableAttributeArray("color"); rendering_program_face.setAttributeValue("color",color); glDrawArrays(GL_TRIANGLES, 0, static_cast(arrays[POS_MONO_FACES].size()/3)); vao[VAO_MONO_FACES].release(); @@ -967,7 +910,7 @@ protected: vao[VAO_COLORED_FACES].release(); rendering_program_face.release(); - } + } } virtual void init() @@ -1252,10 +1195,10 @@ private: END_NORMAL, LAST_INDEX=END_NORMAL }; - std::vector > arrays; //[LAST_INDEX]; + std::vector arrays[LAST_INDEX]; static const unsigned int NB_VBO_BUFFERS=(END_POS-BEGIN_POS)+ - (END_COLOR-BEGIN_COLOR); + (END_COLOR-BEGIN_COLOR)+2; // +2 for 2 vectors of normals QGLBuffer buffers[NB_VBO_BUFFERS]; @@ -1271,13 +1214,6 @@ private: }; QOpenGLVertexArrayObject vao[NB_VAO_BUFFERS]; - //Shaders elements - int vertexLocation[NB_VAO_BUFFERS]; - int normalsLocation; - int mvpLocation[2]; - int mvLocation; - int lightLocation[5]; - QOpenGLShaderProgram rendering_program_face; QOpenGLShaderProgram rendering_program_p_l; diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_viewer_qt.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_viewer_qt.h index 8c9b2d778dd..c9d21cc4e71 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_viewer_qt.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_viewer_qt.h @@ -178,7 +178,6 @@ protected: add_mono_segment(p1, p2); else { - // c=CGAL::Color(100,100,100); add_colored_segment(p1, p2, c); // TODO REMOVE LATER } } @@ -193,7 +192,7 @@ protected: if (c.red()<60 || c.green()<60 || c.blue()<60) add_mono_point(p); else - { // c=CGAL::Color(255,100,100); + { add_colored_point(p, c); // TODO REMOVE LATER } } @@ -201,7 +200,7 @@ protected: void compute_elements() { clear(); - + unsigned int markfaces = lcc.get_new_mark(); unsigned int markedges = lcc.get_new_mark(); unsigned int markvertices = lcc.get_new_mark();