Skip to content

Commit 0e2fd22

Browse files
committed
refactor(examples): reduce dependencies on glu
Signed-off-by: Benn Snyder <[email protected]>
1 parent 00b4308 commit 0e2fd22

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ include (SetupDirectories)
4747

4848
set (PROJECT_VER_MAJOR 0)
4949
set (PROJECT_VER_MINOR 7)
50-
set (PROJECT_VER_PATCH 2)
50+
set (PROJECT_VER_PATCH 3)
5151
set (PROJECT_VER
5252
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
5353
set (PROJECT_APIVER

examples/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ if (BUILD_C_SYNC)
5151
install(TARGETS freenect-regtest freenect-tiltdemo
5252
DESTINATION bin)
5353

54-
if (OpenGL_OpenGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
54+
if (OpenGL_OpenGL_FOUND AND GLUT_FOUND)
5555
include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})
5656
add_executable(freenect-glpclview glpclview.c)
5757
include(ChooseOpenGLTarget)
58-
target_link_libraries(freenect-glpclview freenect_sync "${OPENGL_TARGET}" OpenGL::GLU GLUT::GLUT ${MATH_LIB})
58+
target_link_libraries(freenect-glpclview freenect_sync "${OPENGL_TARGET}" GLUT::GLUT ${MATH_LIB})
5959
install(TARGETS freenect-glpclview
6060
DESTINATION bin)
6161
endif ()

examples/glpclview.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ int rotangles[2] = {0}; // Panning angles
4545
float zoom = 1; // zoom factor
4646
int color = 1; // Use the RGB texture or just draw it as color
4747

48+
// implemented here to avoid dependency on libGLU
49+
void gluPerspective(GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar)
50+
{
51+
const double pi = acos(-1);
52+
const GLdouble fH = tan(fovY / 360 * pi) * zNear;
53+
const GLdouble fW = fH * aspect;
54+
glFrustum(-fW, fW, -fH, fH, zNear, zFar);
55+
}
56+
4857
// Do the projection from u,v,depth to X,Y,Z directly in an opengl matrix
4958
// These numbers come from a combination of the ros kinect_node wiki, and
5059
// nicolas burrus' posts.

wrappers/cpp/CMakeLists.txt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@ if (BUILD_EXAMPLES)
99
find_package(OpenGL COMPONENTS OpenGL)
1010
find_package(GLUT)
1111

12-
if (Threads_FOUND AND OpenGL_OpenGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
12+
if (Threads_FOUND AND OpenGL_OpenGL_FOUND AND GLUT_FOUND)
13+
include(ChooseOpenGLTarget)
1314
include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})
1415

1516
add_executable(freenect-cppview cppview.cpp)
16-
add_executable(freenect-cpp_pcview cpp_pc_view.cpp)
17-
1817
target_compile_features(freenect-cppview PUBLIC cxx_std_11)
19-
target_compile_features(freenect-cpp_pcview PUBLIC cxx_std_11)
20-
21-
include(ChooseOpenGLTarget)
22-
target_link_libraries(freenect-cppview freenect "${OPENGL_TARGET}" OpenGL::GLU GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
23-
target_link_libraries(freenect-cpp_pcview freenect "${OPENGL_TARGET}" OpenGL::GLU GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
24-
25-
install(TARGETS freenect-cppview freenect-cpp_pcview
18+
target_link_libraries(freenect-cppview freenect "${OPENGL_TARGET}" GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
19+
install(TARGETS freenect-cppview
2620
DESTINATION bin)
21+
22+
if (OPENGL_GLU_FOUND)
23+
add_executable(freenect-cpp_pcview cpp_pc_view.cpp)
24+
target_compile_features(freenect-cpp_pcview PUBLIC cxx_std_11)
25+
target_link_libraries(freenect-cpp_pcview freenect "${OPENGL_TARGET}" OpenGL::GLU GLUT::GLUT ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
26+
install(TARGETS freenect-cpp_pcview
27+
DESTINATION bin)
28+
endif()
2729
endif()
2830
endif()

wrappers/cpp/cppview.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
#if defined(__APPLE__)
3535
#include <GLUT/glut.h>
3636
#include <OpenGL/gl.h>
37-
#include <OpenGL/glu.h>
3837
#else
3938
#include <GL/glut.h>
4039
#include <GL/gl.h>
41-
#include <GL/glu.h>
4240
#endif
4341

4442

0 commit comments

Comments
 (0)