From 301416c151c859701818ec1d2e07bc9aa64592ec Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 29 Jun 2018 12:01:39 +0200 Subject: [PATCH] Pass to OpenGL_ES_2 --- GraphicsView/include/CGAL/Qt/camera_impl.h | 17 ------------- GraphicsView/include/CGAL/Qt/qglviewer.h | 4 ++-- GraphicsView/include/CGAL/Qt/qglviewer_impl.h | 7 +++--- Polyhedron/demo/Polyhedron/Scene.cpp | 24 ++++++++----------- .../demo/Polyhedron/Scene_group_item.cpp | 2 +- Polyhedron/demo/Polyhedron/Viewer.cpp | 11 +-------- Polyhedron/demo/Polyhedron/opengl_tools.h | 2 +- 7 files changed, 19 insertions(+), 48 deletions(-) diff --git a/GraphicsView/include/CGAL/Qt/camera_impl.h b/GraphicsView/include/CGAL/Qt/camera_impl.h index a0fee4d8d0c..fb9d42a513f 100644 --- a/GraphicsView/include/CGAL/Qt/camera_impl.h +++ b/GraphicsView/include/CGAL/Qt/camera_impl.h @@ -494,14 +494,7 @@ void Camera::computeModelViewMatrix() const { CGAL_INLINE_FUNCTION void Camera::loadProjectionMatrix(bool reset) const { // WARNING: makeCurrent must be called by every calling method - gl()->glMatrixMode(GL_PROJECTION); - - if (reset) - gl()->glLoadIdentity(); - computeProjectionMatrix(); - - gl()->glMultMatrixd(projectionMatrix_); } /*! Loads the OpenGL \c GL_MODELVIEW matrix with the modelView matrix @@ -536,12 +529,7 @@ void Camera::loadProjectionMatrix(bool reset) const { CGAL_INLINE_FUNCTION void Camera::loadModelViewMatrix(bool reset) const { // WARNING: makeCurrent must be called by every calling method - gl()->glMatrixMode(GL_MODELVIEW); computeModelViewMatrix(); - if (reset) - gl()->glLoadMatrixd(modelViewMatrix_); - else - gl()->glMultMatrixd(modelViewMatrix_); } /*! Same as loadProjectionMatrix() but for a stereo setup. @@ -575,9 +563,6 @@ void Camera::loadProjectionMatrixStereo(bool leftBuffer) const { qreal left, right, bottom, top; qreal screenHalfWidth, halfWidth, side, shift, delta; - gl()->glMatrixMode(GL_PROJECTION); - gl()->glLoadIdentity(); - switch (type()) { case Camera::PERSPECTIVE: // compute half width of screen, @@ -629,7 +614,6 @@ void Camera::loadProjectionMatrixStereo(bool leftBuffer) const { CGAL_INLINE_FUNCTION void Camera::loadModelViewMatrixStereo(bool leftBuffer) const { // WARNING: makeCurrent must be called by every calling method - gl()->glMatrixMode(GL_MODELVIEW); qreal halfWidth = focusDistance() * tan(horizontalFieldOfView() / 2.0); qreal shift = @@ -641,7 +625,6 @@ void Camera::loadModelViewMatrixStereo(bool leftBuffer) const { modelViewMatrix_[12] -= shift; else modelViewMatrix_[12] += shift; - gl()->glLoadMatrixd(modelViewMatrix_); } /*! Fills \p m with the Camera projection matrix values. diff --git a/GraphicsView/include/CGAL/Qt/qglviewer.h b/GraphicsView/include/CGAL/Qt/qglviewer.h index 42ef9c7b1eb..73541a58e88 100644 --- a/GraphicsView/include/CGAL/Qt/qglviewer.h +++ b/GraphicsView/include/CGAL/Qt/qglviewer.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -75,7 +75,7 @@ href="../examples/callback.html">callback example for a complete implementation. \nosubgrouping */ -class CGAL_QT_EXPORT QGLViewer : public QOpenGLWidget, public QOpenGLFunctions_2_1 { +class CGAL_QT_EXPORT QGLViewer : public QOpenGLWidget, public QOpenGLFunctions { Q_OBJECT public: diff --git a/GraphicsView/include/CGAL/Qt/qglviewer_impl.h b/GraphicsView/include/CGAL/Qt/qglviewer_impl.h index 169d891a99a..32c0eff8f7c 100644 --- a/GraphicsView/include/CGAL/Qt/qglviewer_impl.h +++ b/GraphicsView/include/CGAL/Qt/qglviewer_impl.h @@ -210,7 +210,7 @@ If a 4.3 context could not be set, a 2.1 context will be used instead. */ CGAL_INLINE_FUNCTION void CGAL::QGLViewer::initializeGL() { - QSurfaceFormat format; + /*QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setVersion(4,3); @@ -229,9 +229,10 @@ void CGAL::QGLViewer::initializeGL() { else { is_ogl_4_3 = true; - } + }*/ + is_ogl_4_3 = false; makeCurrent(); - QOpenGLFunctions_2_1::initializeOpenGLFunctions(); + QOpenGLFunctions::initializeOpenGLFunctions(); // Default colors setForegroundColor(QColor(180, 180, 180)); setBackgroundColor(QColor(51, 51, 51)); diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 7a0e20daf4e..c255e738f80 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -490,13 +490,9 @@ void Scene::renderScene(const QList &items, if( group || item.renderingMode() == Flat || item.renderingMode() == FlatPlusEdges || item.renderingMode() == Gouraud) { if(with_names) { - viewer->glClearDepth(1.0); + viewer->glClearDepthf(1.0); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } - if(item.renderingMode() == Gouraud) - viewer->glShadeModel(GL_SMOOTH); - else - viewer->glShadeModel(GL_FLAT); item.draw(viewer); } @@ -543,14 +539,14 @@ void Scene::renderWireScene(const QList &items, || item.renderingMode() == PointsPlusNormals) { viewer->glDisable(GL_LIGHTING); - viewer->glPointSize(2.f); + //viewer->glPointSize(2.f); viewer->glLineWidth(1.0f); item.drawEdges(viewer); } else{ if( item.renderingMode() == PointsPlusNormals ){ viewer->glDisable(GL_LIGHTING); - viewer->glPointSize(2.f); + //viewer->glPointSize(2.f); viewer->glLineWidth(1.0f); if(index == selected_item || selected_items_list.contains(index)) { @@ -596,7 +592,7 @@ void Scene::renderPointScene(const QList &items, if(group ||item.visible()) { if(item.renderingMode() == Points && with_names) { - viewer->glClearDepth(1.0); + viewer->glClearDepthf(1.0); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } @@ -605,7 +601,7 @@ void Scene::renderPointScene(const QList &items, (item.renderingMode() == ShadedPoints)) { viewer->glDisable(GL_LIGHTING); - viewer->glPointSize(3.0f); + //viewer->glPointSize(3.0f); viewer->glLineWidth(1.0f); item.drawPoints(viewer); } @@ -673,7 +669,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer) 0.0f, 0.0f, 0.0f); - viewer->glClearDepth(1); + viewer->glClearDepthf(1); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //renderScene(children, viewer, picked_item_IDs, false, 0,false, NULL); renderScene(opaque_items, viewer, picked_item_IDs, false, 0,false, NULL); @@ -689,7 +685,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer) 0.0f, 0.0f, 0.0f); - viewer->glClearDepth(1); + viewer->glClearDepthf(1); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // renderScene(children, viewer, picked_item_IDs, false, 0,true, NULL); renderScene(opaque_items, viewer, picked_item_IDs, false, 0,true, NULL); @@ -709,7 +705,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer) 0.0f, 0.0f, 0.0f); - viewer->glClearDepth(1); + viewer->glClearDepthf(1); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderWireScene(children, viewer, picked_item_IDs, false); renderPointScene(children, viewer, picked_item_IDs, false); @@ -728,7 +724,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer) 0.0f, 0.0f, 0.0f); - viewer->glClearDepth(1); + viewer->glClearDepthf(1); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //renderScene(children, viewer, picked_item_IDs, false, i, true, depth_test[i-1]); renderScene(opaque_items , viewer, picked_item_IDs, false, i, true, depth_test[i-1]); @@ -748,7 +744,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer) 0.0f, 0.0f, 0.0f); - viewer->glClearDepth(1); + viewer->glClearDepthf(1); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // renderScene(children, viewer, picked_item_IDs, false, (int)viewer->total_pass()-1, false, depth_test[(int)viewer->total_pass()-2]); renderScene(opaque_items , viewer, picked_item_IDs, false, (int)viewer->total_pass()-1, false, depth_test[(int)viewer->total_pass()-2]); diff --git a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp index 6967c54a691..0a3c31f6653 100644 --- a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp @@ -156,7 +156,7 @@ void Scene_group_item::renderChildren(Viewer_interface *viewer, Q_FOREACH(Scene_interface::Item_id id, children){ if(with_names) { - viewer->glClearDepth(1.0); + viewer->glClearDepthf(1.0f); viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } if(id == scene->mainSelectionIndex()|| scene->selectionIndices().contains(id)) diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index 858654605cf..f75e3b75855 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -461,17 +461,9 @@ void Viewer_impl::draw_aux(bool with_names, Viewer* viewer) return; current_total_pass = viewer->inFastDrawing() ? total_pass/2 : total_pass; viewer->glLineWidth(1.0f); - viewer->glPointSize(2.f); + //viewer->glPointSize(2.f); viewer->glEnable(GL_POLYGON_OFFSET_FILL); viewer->glPolygonOffset(1.0f,1.0f); - viewer->glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - - viewer->glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); - - if(twosides) - viewer->glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); - else - viewer->glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); if(!with_names && antialiasing) { @@ -493,7 +485,6 @@ void Viewer_impl::draw_aux(bool with_names, Viewer* viewer) else scene->draw(viewer); viewer->glDisable(GL_POLYGON_OFFSET_FILL); - viewer->glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); } bool Viewer::inDrawWithNames() const { diff --git a/Polyhedron/demo/Polyhedron/opengl_tools.h b/Polyhedron/demo/Polyhedron/opengl_tools.h index b7884a68518..6b62220e35d 100644 --- a/Polyhedron/demo/Polyhedron/opengl_tools.h +++ b/Polyhedron/demo/Polyhedron/opengl_tools.h @@ -42,7 +42,7 @@ public: set_point_size(ps); } void set_point_size(GLfloat v) { - viewer->glPointSize(v); + //viewer->glPointSize(v); } }; // end class Point_size