Remove direct use of the OpenGL API

We always use the Qt wrappers.
This commit is contained in:
Laurent Rineau 2017-11-28 16:07:37 +01:00
parent 1296d83552
commit f5b5aead66
5 changed files with 12 additions and 20 deletions

View File

@ -27,15 +27,12 @@ find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Gui Svg)
include( ${CGAL_USE_FILE} )
# Find OpenGL
find_package(OpenGL)
# Find QGLViewer
if(Qt5_FOUND)
find_package(QGLViewer)
endif(Qt5_FOUND)
if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND)
include_directories ( ${QGLVIEWER_INCLUDE_DIR} )
@ -71,7 +68,7 @@ if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FO
include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(AABB_demo)
else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND)
set(AABB_MISSING_DEPS "")
@ -87,14 +84,10 @@ else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER
set(AABB_MISSING_DEPS "Qt5, ${AABB_MISSING_DEPS}")
endif()
if(NOT OPENGL_FOUND)
set(AABB_MISSING_DEPS "OpenGL, ${AABB_MISSING_DEPS}")
endif()
if(NOT QGLVIEWER_FOUND)
set(AABB_MISSING_DEPS "QGLViewer, ${AABB_MISSING_DEPS}")
endif()
message(STATUS "NOTICE: This demo requires ${AABB_MISSING_DEPS}and will not be compiled.")
endif (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
endif (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND)

View File

@ -595,6 +595,7 @@ void Scene::draw(QGLViewer* viewer)
initGL();
if(!are_buffers_initialized)
initialize_buffers();
gl->glEnable(GL_DEPTH_TEST);
QColor color;
QMatrix4x4 fMatrix;
fMatrix.setToIdentity();
@ -663,7 +664,7 @@ void Scene::draw(QGLViewer* viewer)
//cutting_segments
fMatrix.setToIdentity();
::glLineWidth(2.0f);
gl->glLineWidth(2.0f);
vao[3].bind();
attrib_buffers(viewer);
rendering_program.bind();
@ -671,7 +672,7 @@ void Scene::draw(QGLViewer* viewer)
rendering_program.setUniformValue(colorLocation, color);
rendering_program.setUniformValue(fLocation, fMatrix);
gl->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_cut_segments.size()/3));
::glLineWidth(1.0f);
gl->glLineWidth(1.0f);
rendering_program.release();
vao[3].release();
//grid
@ -690,8 +691,8 @@ void Scene::draw(QGLViewer* viewer)
//cutting_plane
// for(int i=0; i< 16 ; i++)
// fMatrix.data()[i] = m_frame->matrix()[i];
::glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
::glEnable(GL_BLEND);
gl->glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
gl->glEnable(GL_BLEND);
vao[4].bind();
attrib_buffers(viewer);
rendering_program.bind();
@ -699,7 +700,7 @@ void Scene::draw(QGLViewer* viewer)
rendering_program.setUniformValue(colorLocation, color);
rendering_program.setUniformValue(fLocation, fMatrix);
gl->glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_plane.size()/3));
::glDisable(GL_BLEND);
gl->glDisable(GL_BLEND);
rendering_program.release();
vao[4].release();

View File

@ -18,7 +18,6 @@ void Viewer::setScene(Scene* pScene)
void Viewer::draw()
{
glEnable(GL_DEPTH_TEST);
QGLViewer::draw();
if(m_pScene != NULL)
{

View File

@ -21,10 +21,9 @@ include(${CGAL_USE_FILE})
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(OpenGL)
find_package(QGLViewer)
if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND )
add_definitions(-DQT_NO_KEYWORDS)
@ -55,6 +54,6 @@ if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_
else()
message(STATUS "NOTICE: This demo requires CGAL, the QGLViewer, OpenGL and Qt5, and will not be compiled.")
message(STATUS "NOTICE: This demo requires CGAL, the QGLViewer, and Qt5, and will not be compiled.")
endif()

View File

@ -335,7 +335,7 @@ Viewer::draw()
rendering_program_points.bind();
color.setRgbF(1.0f, 0.0f, 0.0f);
glPointSize(5);
::glEnable(GL_POINT_SMOOTH);
glEnable(GL_POINT_SMOOTH);
rendering_program_points.setUniformValue(colorLocation_points, color);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
rendering_program_points.release();