Skip to content

Commit

Permalink
Do not use OpenGL directly, but only using Qt5 OpenGL classes
Browse files Browse the repository at this point in the history
  • Loading branch information
lrineau committed Nov 28, 2017
1 parent 670cf2b commit 6ec4c12
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 178 deletions.
5 changes: 2 additions & 3 deletions Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt
Expand Up @@ -11,10 +11,9 @@ include(${CGAL_USE_FILE})

find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL)

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 )


include_directories (${QGLVIEWER_INCLUDE_DIR})
Expand All @@ -36,6 +35,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()
6 changes: 3 additions & 3 deletions Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp
Expand Up @@ -860,10 +860,10 @@ void Viewer::init()
compile_shaders();
compute_elements();
initialize_buffers();
::glEnable(GL_BLEND);
glEnable(GL_BLEND);

::glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);

Expand Down
2 changes: 0 additions & 2 deletions Installation/cmake/modules/CGAL_Macros.cmake
Expand Up @@ -304,7 +304,6 @@ if( NOT CGAL_MACROS_FILE_INCLUDED )
endif()

if (${component} STREQUAL "Qt5")
find_package(OpenGL QUIET)
find_package(Qt5 COMPONENTS OpenGL Gui Core Script ScriptTools QUIET)
endif()

Expand Down Expand Up @@ -341,7 +340,6 @@ if( NOT CGAL_MACROS_FILE_INCLUDED )

if (${component} STREQUAL "Qt5")
set(CGAL_${component}_FOUND TRUE)
find_package(OpenGL QUIET)
find_package(Qt5 COMPONENTS OpenGL Gui Core Script ScriptTools QUIET)
endif()
####message( STATUS "External library ${vlib} after find")
Expand Down
12 changes: 1 addition & 11 deletions Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake
Expand Up @@ -10,7 +10,6 @@
# .. code-block:: cmake
#
# find_package(Qt5 QUIET COMPONENTS OpenGL Svg)
# find_package(OpenGL QUIET)
#
# and defines the variable :variable:`CGAL_Qt5_FOUND` and the function
# :command:`CGAL_setup_CGAL_Qt5_dependencies`.
Expand All @@ -25,9 +24,7 @@ set(CGAL_SetupCGAL_Qt5Dependencies_included TRUE)
# Used Modules
# ^^^^^^^^^^^^
# - :module:`Qt5Config`
# - :module:`FindOpenGL`
find_package(Qt5 QUIET COMPONENTS OpenGL Svg)
find_package(OpenGL QUIET)

set(CGAL_Qt5_MISSING_DEPS "")
if(NOT Qt5OpenGL_FOUND)
Expand All @@ -39,9 +36,6 @@ endif()
if(NOT Qt5_FOUND)
set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} Qt5")
endif()
if(NOT OPENGL_FOUND)
set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} OpenGL")
endif()


#.rst:
Expand Down Expand Up @@ -71,9 +65,6 @@ if(NOT CGAL_Qt5_MISSING_DEPS)
endif()

#get_property(QT_UIC_EXECUTABLE TARGET Qt5::uic PROPERTY LOCATION)
#message( STATUS "OpenGL include: ${OPENGL_INCLUDE_DIR}" )
#message( STATUS "OpenGL libraries: ${OPENGL_LIBRARIES}" )
#message( STATUS "OpenGL definitions: ${OPENGL_DEFINITIONS}" )
#message( STATUS "Qt5Core include: ${Qt5Core_INCLUDE_DIRS}" )
#message( STATUS "Qt5 libraries: ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Svg_LIBRARIES} ${Qt5OpenGL_LIBRARIES}" )
#message( STATUS "Qt5Core definitions: ${Qt5Core_DEFINITIONS}" )
Expand Down Expand Up @@ -105,11 +96,10 @@ function(CGAL_setup_CGAL_Qt5_dependencies target)
if($ENV{CGAL_FAKE_PUBLIC_RELEASE})
target_compile_definitions( ${target} ${keyword} CGAL_FAKE_PUBLIC_RELEASE=1 )
endif()
target_include_directories( ${target} SYSTEM ${keyword} ${OPENGL_INCLUDE_DIR})
target_link_libraries( ${target} ${keyword} CGAL::CGAL)
if(CGAL_HEADER_ONLY)
target_link_libraries( ${target} ${keyword} CGAL::Qt5_moc_and_resources)
endif()
target_link_libraries( ${target} ${keyword} Qt5::OpenGL Qt5::Svg ${OPENGL_LIBRARIES})
target_link_libraries( ${target} ${keyword} Qt5::OpenGL Qt5::Svg)
endfunction()

31 changes: 0 additions & 31 deletions Installation/cmake/modules/FindOpenGL.cmake

This file was deleted.

5 changes: 2 additions & 3 deletions Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt
Expand Up @@ -40,13 +40,12 @@ include(${CGAL_USE_FILE})

find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)

find_package(OpenGL)
find_package(QGLViewer)

if ( NOT (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND
OPENGL_FOUND AND QGLVIEWER_FOUND) )
QGLVIEWER_FOUND) )

MESSAGE(STATUS "NOTICE: This demo requires CGAL, QGLViewer, OpenGL "
MESSAGE(STATUS "NOTICE: This demo requires CGAL, QGLViewer, "
"and Qt5, and will not be compiled.")

else()
Expand Down
38 changes: 19 additions & 19 deletions Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp
Expand Up @@ -709,14 +709,14 @@ void Viewer::draw()
color.setRgbF(0.2f, 0.2f, 0.7f);
rendering_program_p_l.bind();
rendering_program_p_l.setAttributeValue(colorLocation,color);
::glLineWidth(size_edges);
glLineWidth(size_edges);
glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_lines.size()/3));
rendering_program_p_l.release();
vao[2].release();
}
if(vertices)
{
::glPointSize(size_points);
glPointSize(size_points);
vao[3].bind();
attrib_buffers(this);
color.setRgbF(.2f,.2f,.6f);
Expand Down Expand Up @@ -750,23 +750,23 @@ void Viewer::init()
setKeyDescription(Qt::Key_PageUp, "Decrease light (all colors, use shift/alt/ctrl for one rgb component)");

// Light default parameters
::glLineWidth(size_edges);
::glPointSize(size_points);
::glEnable(GL_POLYGON_OFFSET_FILL);
::glPolygonOffset(1.0f,1.0f);
::glClearColor(1.0f,1.0f,1.0f,0.0f);
::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

::glEnable(GL_LIGHTING);

::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

::glShadeModel(GL_FLAT);
::glDisable(GL_BLEND);
::glDisable(GL_LINE_SMOOTH);
::glDisable(GL_POLYGON_SMOOTH_HINT);
::glBlendFunc(GL_ONE, GL_ZERO);
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
glLineWidth(size_edges);
glPointSize(size_points);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f,1.0f);
glClearColor(1.0f,1.0f,1.0f,0.0f);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

glEnable(GL_LIGHTING);

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

glShadeModel(GL_FLAT);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POLYGON_SMOOTH_HINT);
glBlendFunc(GL_ONE, GL_ZERO);
glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
compile_shaders();
}

Expand Down
Expand Up @@ -21,9 +21,6 @@ if(Qt5_FOUND)
add_definitions(-DQT_NO_KEYWORDS)
endif(Qt5_FOUND)

# Find OpenGL
find_package(OpenGL)

# Find CImg
find_path(CIMG_INCLUDE_DIR
NAMES CImg.h
Expand All @@ -37,7 +34,7 @@ else()
"Try setting the environment variable CIMG_INC_DIR to point to the path of the directory containing CImg.h.")
endif()

if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND)
if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND)

set(
SRCS
Expand Down Expand Up @@ -96,7 +93,7 @@ if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND)

include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(Otr2_demo)
else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND )
else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND )

set(OTR2_MISSING_DEPS "")

Expand All @@ -112,10 +109,6 @@ else (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND )
set(OTR2_MISSING_DEPS "Qt5.4, ${OTR2_MISSING_DEPS}")
endif()

if(NOT OPENGL_FOUND)
set(OTR2_MISSING_DEPS "OpenGL, ${OTR2_MISSING_DEPS}")
endif()

message(STATUS "NOTICE: This demo requires ${OTR2_MISSING_DEPS}and will not be compiled.")

endif (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND)
endif (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND)
Expand Up @@ -17,16 +17,13 @@ include( ${CGAL_USE_FILE} )
# Find Qt5 itself
find_package(Qt5 QUIET COMPONENTS Xml OpenGL Help Core)

# Find OpenGL
find_package(OpenGL)

# Find QGLViewer
if(Qt5_FOUND)
add_definitions(-DQT_NO_KEYWORDS)
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 Qt5_FOUND AND QGLVIEWER_FOUND AND TARGET Qt5::qcollectiongenerator)

include_directories( ${QGLVIEWER_INCLUDE_DIR} )

Expand Down Expand Up @@ -86,10 +83,6 @@ else ()
set(PERIODIC_TRIANGULATION_MISSING_DEPS "Qt5, ${PERIODIC_TRIANGULATION_MISSING_DEPS}")
endif()

if(NOT OPENGL_FOUND)
set(PERIODIC_TRIANGULATION_MISSING_DEPS "OpenGL, ${PERIODIC_TRIANGULATION_MISSING_DEPS}")
endif()

if(NOT QGLVIEWER_FOUND)
set(PERIODIC_TRIANGULATION_MISSING_DEPS "QGLViewer, ${PERIODIC_TRIANGULATION_MISSING_DEPS}")
endif()
Expand Down
Expand Up @@ -830,7 +830,7 @@ void Scene::draw() {
rendering_program.bind();

glPointSize(5);
::glEnable(GL_POINT_SMOOTH);
glEnable(GL_POINT_SMOOTH);

rendering_program.setUniformValue(colorLocation[0], color);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
Expand All @@ -844,7 +844,7 @@ void Scene::draw() {
rendering_program.bind();

glPointSize(5);
::glEnable(GL_POINT_SMOOTH);
glEnable(GL_POINT_SMOOTH);
rendering_program.setUniformValue(colorLocation[0], color);
glDrawArrays(GL_POINTS, 0, 1);
rendering_program.release();
Expand Down
10 changes: 2 additions & 8 deletions Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt
Expand Up @@ -23,13 +23,11 @@ include(${CGAL_USE_FILE})

find_package(Qt5 QUIET COMPONENTS Xml Script Help OpenGL Svg)

find_package(OpenGL)

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 AND TARGET Qt5::qcollectiongenerator )
if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND TARGET Qt5::qcollectiongenerator )


include_directories (${QGLVIEWER_INCLUDE_DIR})
Expand Down Expand Up @@ -66,7 +64,7 @@ if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_

include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(Periodic_Lloyd_3)
else( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE )
else( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE )

set(PERIODIC_LLOYD_MISSING_DEPS "")

Expand All @@ -78,10 +76,6 @@ else( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER
set(PERIODIC_LLOYD_MISSING_DEPS "Qt5, ${PERIODIC_LLOYD_MISSING_DEPS}")
endif()

if(NOT OPENGL_FOUND)
set(PERIODIC_LLOYD_MISSING_DEPS "OpenGL, ${PERIODIC_LLOYD_MISSING_DEPS}")
endif()

if(NOT QGLVIEWER_FOUND)
set(PERIODIC_LLOYD_MISSING_DEPS "QGLViewer, ${PERIODIC_LLOYD_MISSING_DEPS}")
endif()
Expand Down
34 changes: 17 additions & 17 deletions Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/Viewer.cpp
Expand Up @@ -32,18 +32,18 @@ Viewer::draw()
initialize_buffers();
QColor color;
//the points
::glEnable(GL_BLEND);
::glEnable(GL_POINT_SMOOTH);
::glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
::glEnable(GL_LINE_SMOOTH);
::glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
::glPointSize(5);
glEnable(GL_BLEND);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPointSize(5);

::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
::glColor3f(0.2f, 0.2f, 1.f);
::glEnable(GL_POLYGON_OFFSET_FILL);
::glPolygonOffset(3.0f,-3.0f);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glColor3f(0.2f, 0.2f, 1.f);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(3.0f,-3.0f);


attrib_buffers(this);
Expand All @@ -56,10 +56,10 @@ Viewer::draw()
vao[0].release();

//The Lines
::glLineWidth(1.);
::glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
::glColor3ub(0,0,0);
::glDisable(GL_POLYGON_OFFSET_FILL);
glLineWidth(1.);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glColor3ub(0,0,0);
glDisable(GL_POLYGON_OFFSET_FILL);

vao[1].bind();
color.setRgbF(0.27f, 0.51f, 0.7f);
Expand Down Expand Up @@ -173,7 +173,7 @@ void Viewer::initialize_buffers()

void Viewer::compute_elements()
{
//::glColor3f(1.0f, 0.72f, 0.06f);
//glColor3f(1.0f, 0.72f, 0.06f);
pos_points.resize(0);
pos_lines.resize(0);
pos_8lines.resize(0);
Expand All @@ -188,7 +188,7 @@ void Viewer::compute_elements()
pos_points.push_back(p.x()); pos_points.push_back(p.y()); pos_points.push_back(p.z());
}

//::glColor3f(0.27f, 0.51f, 0.7f);
//glColor3f(0.27f, 0.51f, 0.7f);
for (Periodic_triangle_iterator ptit
= scene->periodic_triangulation.periodic_triangles_begin(
P3DT3::UNIQUE);
Expand Down

0 comments on commit 6ec4c12

Please sign in to comment.