diff --git a/Apps/CMakeLists.txt b/Apps/CMakeLists.txt index c55e44804b953b35e68b9b0a3e339bbf445de961..a1ab246480c08e36b731c126c4af0e69433554ca 100644 --- a/Apps/CMakeLists.txt +++ b/Apps/CMakeLists.txt @@ -1,32 +1,16 @@ SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin) -# define libs -SET (COMMON_LIBS ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} ${Boost_REGEX_LIBRARY} ${Boost_THREAD_LIBRARY} gzstream assimp) - -# define includes of external libs -SET(CGoGN_EXT_INCLUDES - ${LIBXML2_INCLUDE_DIR} - ${CGoGN_ROOT_DIR}/ThirdParty/Numerical - ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig - ${CGoGN_ROOT_DIR}/ThirdParty/gzstream - ${CGoGN_ROOT_DIR}/ThirdParty/Zinri - ${CGoGN_ROOT_DIR}/ThirdParty/glm - ${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include ) - - - # FOR Qt4 SET(QT_USE_QTOPENGL TRUE) INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS}) - - SET(CGoGN_LIBS_R topology algo container utils) IF(WIN32) SET(CGoGN_LIBS_D topology algo container utils) # libs have same name but in different place in Visual add_subdirectory(Examples/Release) + add_subdirectory(Examples/Tests) add_subdirectory(Tuto) ELSE(WIN32) SET(CGoGN_LIBS_D topologyD algoD containerD utilsD) diff --git a/Apps/Examples/Debug/CMakeLists.txt b/Apps/Examples/Debug/CMakeLists.txt index 973b7097a142f514e6aa6e51ec1cbeb600ed5ee2..e6278f82004bc163b2556849c0f7814dabc942d7 100644 --- a/Apps/Examples/Debug/CMakeLists.txt +++ b/Apps/Examples/Debug/CMakeLists.txt @@ -19,7 +19,6 @@ link_directories( IF(WIN32) link_directories( ${CGoGN_ROOT_DIR}/lib/$(ConfigurationName) ${Boost_LIBRARY_DIRS}) ELSE(WIN32) - link_directories( ${CGoGN_ROOT_DIR}/lib/Debug ${CGoGN_ROOT_DIR}/lib/Release ) ENDIF(WIN32) @@ -28,47 +27,47 @@ ENDIF(WIN32) QT4_WRAP_CPP(polyhedronsView_moc ../polyhedronsView.h) add_executable( polyhedronsViewD ../polyhedronsView.cpp ${polyhedronsView_moc}) target_link_libraries( polyhedronsViewD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(frame_manip_moc ../frame_manip.h) add_executable( frame_manipD ../frame_manip.cpp ${frame_manip_moc}) target_link_libraries( frame_manipD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(texturesExample_moc ../texturesExample.h) add_executable( texturesExampleD ../texturesExample.cpp ${texturesExample_moc} ) target_link_libraries( texturesExampleD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleMap3_moc ../simpleMap3.h) add_executable( simpleMap3D ../simpleMap3.cpp ${simpleMap3_moc} ) target_link_libraries( simpleMap3D - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleGMap2_moc ../simpleGMap2.h) add_executable( simpleGMap2D ../simpleGMap2.cpp ${simpleGMap2_moc} ) target_link_libraries( simpleGMap2D - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleGMap3_moc ../simpleGMap3.h) add_executable( simpleGMap3D ../simpleGMap3.cpp ${simpleGMap3_moc} ) target_link_libraries( simpleGMap3D - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(extrusionView_moc ../extrusionView.h) add_executable( extrusionViewD ../extrusionView.cpp ${extrusionView_moc}) target_link_libraries( extrusionViewD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( viewer_ui ../viewer.ui ) QT4_WRAP_CPP( viewer_moc ../viewer.h ) add_executable( viewerD ../viewer.cpp ${viewer_moc} ${viewer_ui}) target_link_libraries( viewerD - ${CGoGN_LIBS_D} ${NUMERICAL_LIBS} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${NUMERICAL_LIBS} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( clipping_ui ../clipping.ui ) QT4_WRAP_CPP( clipping_moc ../clipping.h ) add_executable( clippingD ../clipping.cpp ${clipping_ui} ${clipping_moc}) target_link_libraries( clippingD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) diff --git a/Apps/Examples/Release/CMakeLists.txt b/Apps/Examples/Release/CMakeLists.txt index 24a68afa629a9f473f2dc70eb61892adb8f1299e..978c2f696b42e38e73f0b102194ab00ab710bc70 100644 --- a/Apps/Examples/Release/CMakeLists.txt +++ b/Apps/Examples/Release/CMakeLists.txt @@ -26,42 +26,42 @@ ENDIF(WIN32) QT4_WRAP_CPP(polyhedronsView_moc ../polyhedronsView.h) add_executable( polyhedronsView ../polyhedronsView.cpp ${polyhedronsView_moc}) target_link_libraries( polyhedronsView - ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(frame_manip_moc ../frame_manip.h) add_executable( frame_manip ../frame_manip.cpp ${frame_manip_moc}) target_link_libraries( frame_manip - ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(texturesExample_moc ../texturesExample.h) add_executable( texturesExample ../texturesExample.cpp ${texturesExample_moc} ) target_link_libraries( texturesExample - ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleGMap2_moc ../simpleGMap2.h) add_executable( simpleGMap2 ../simpleGMap2.cpp ${simpleGMap2_moc} ) target_link_libraries( simpleGMap2 - ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(simpleGMap3_moc ../simpleGMap3.h) add_executable( simpleGMap3 ../simpleGMap3.cpp ${simpleGMap3_moc} ) target_link_libraries( simpleGMap3 - ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(extrusionView_moc ../extrusionView.h) add_executable( extrusionView ../extrusionView.cpp ${extrusionView_moc}) target_link_libraries( extrusionView - ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( viewer_ui ../viewer.ui ) QT4_WRAP_CPP( viewer_moc ../viewer.h ) add_executable( viewer ../viewer.cpp ${viewer_moc} ${viewer_ui}) target_link_libraries( viewer - ${CGoGN_LIBS_R} ${NUMERICAL_LIBS} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_R} ${NUMERICAL_LIBS} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( clipping_ui ../clipping.ui ) QT4_WRAP_CPP( clipping_moc ../clipping.h ) add_executable( clipping ../clipping.cpp ${clipping_ui} ${clipping_moc}) target_link_libraries( clipping - ${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) diff --git a/Apps/Examples/Tests/CMakeLists.txt b/Apps/Examples/Tests/CMakeLists.txt index 15652236fc41b6aa8f903b2bed11014bd1599eed..1b30bdc3bad15fbf69025b3224261a69d4535e5f 100644 --- a/Apps/Examples/Tests/CMakeLists.txt +++ b/Apps/Examples/Tests/CMakeLists.txt @@ -4,28 +4,21 @@ project(geometryAssertD) SET(CMAKE_BUILD_TYPE Debug) -#SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream AntTweakBar openctm) # FOR Qt4 -FIND_PACKAGE(Qt4 REQUIRED) + SET(QT_USE_QTOPENGL TRUE) INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS}) -# define includes path include_directories( + ${CMAKE_CURRENT_BINARY_DIR} ${CGoGN_ROOT_DIR}/include - /usr/include/libxml2/ - ${CGoGN_ROOT_DIR}/include - ${CGoGN_ROOT_DIR}/ThirdParty/Numerical - ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig - ${CGoGN_ROOT_DIR}/ThirdParty/gzstream - ${CGoGN_ROOT_DIR}/ThirdParty/Zinri - ${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include - ${CGoGN_ROOT_DIR}/ThirdParty/glm + ${CGoGN_EXT_INCLUDES} ) + # define libs path link_directories( ${CGoGN_ROOT_DIR}/lib/Debug @@ -36,18 +29,18 @@ link_directories( add_executable( Geom_orientationD ./Geom_orientation.cpp) target_link_libraries( Geom_orientationD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) add_executable( Geom_inclusionD ./Geom_inclusion.cpp) target_link_libraries( Geom_inclusionD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) add_executable( Geom_intersectionD ./Geom_intersection.cpp) target_link_libraries( Geom_intersectionD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) QT4_WRAP_CPP(concave_rendering_moc concave_rendering.h) add_executable( concave_renderingD concave_rendering.cpp ${concave_rendering_moc}) target_link_libraries( concave_renderingD - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) diff --git a/Apps/Examples/texturesExample.cpp b/Apps/Examples/texturesExample.cpp index b6eb9eb97229dd30cd0995d3324dd6c172361ad1..5de82bd056d21d3238bba6e5954c78fb75a498ae 100644 --- a/Apps/Examples/texturesExample.cpp +++ b/Apps/Examples/texturesExample.cpp @@ -210,8 +210,6 @@ void TexView::computeImage() int main(int argc, char**argv) { - ilInit(); - // interface: QApplication app(argc, argv); TexView tv; diff --git a/Apps/Tuto/CMakeLists.txt b/Apps/Tuto/CMakeLists.txt index 161c5d4766fba67414308e97e87571c78e82651d..e581177b951b7831d2c5d4b0c4b9a880d2f1a9c7 100644 --- a/Apps/Tuto/CMakeLists.txt +++ b/Apps/Tuto/CMakeLists.txt @@ -6,22 +6,12 @@ project(Tutos) SET (CMAKE_BUILD_TYPE Debug) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING") -# FOR Qt4 -FIND_PACKAGE(Qt4 REQUIRED) -SET(QT_USE_QTOPENGL TRUE) -INCLUDE(${QT_USE_FILE}) -ADD_DEFINITIONS(${QT_DEFINITIONS}) include_directories( ${CMAKE_CURRENT_BINARY_DIR} - /usr/include/libxml2/ - ${CGoGN_ROOT_DIR}/ThirdParty/gzstream - ${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM - ${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include - ${CGoGN_ROOT_DIR}/ThirdParty/glm ${CGoGN_ROOT_DIR}/include - ${Boost_INCLUDE_DIRS} + ${CGoGN_EXT_INCLUDES} ) # define libs path @@ -32,48 +22,45 @@ ELSE(WIN32) ENDIF(WIN32) -# define boost component usage (here only thread) -find_package(Boost COMPONENTS thread REQUIRED) - #define exec to compile QT4_WRAP_CPP(tuto1_moc tuto1.h) add_executable( tuto1 tuto1.cpp ${tuto1_moc}) target_link_libraries( tuto1 - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( tuto2_ui tuto2.ui ) QT4_WRAP_CPP(tuto2_moc tuto2.h) add_executable( tuto2 tuto2.cpp tuto2.h ${tuto2_ui} ${tuto2_moc}) target_link_libraries( tuto2 - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(tuto3_moc tuto3.h) add_executable( tuto3 tuto3.cpp ${tuto3_moc}) target_link_libraries( tuto3 - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES}) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( tuto4_ui tuto4.ui ) QT4_WRAP_CPP(tuto4_moc tuto4.h) add_executable( tuto4 tuto4.cpp ${tuto4_ui} ${tuto4_moc}) target_link_libraries( tuto4 - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_UI( tuto5_ui tuto5.ui ) QT4_WRAP_CPP(tuto5_moc tuto5.h) add_executable( tuto5 tuto5.cpp ${tuto5_ui} ${tuto5_moc}) target_link_libraries( tuto5 - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) #add_executable( tuto_subdivision tuto_subdivision.cpp) #target_link_libraries( tuto_subdivision -# ${CGoGN_LIBS_D} ${COMMON_LIBS} ) +# ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) QT4_WRAP_CPP(tp_master_moc tp_master.h) add_executable( tp_master tp_master.cpp ${tp_master_moc}) target_link_libraries( tp_master - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) #BOOST_LIBS macro: allow using compiled boost in windows (see readme) # -first argument variable that will contain the libs @@ -85,16 +72,16 @@ target_link_libraries( tp_master QT4_WRAP_CPP(tuto_mt_moc tuto_mt.h) add_executable( tuto_mt tuto_mt.cpp ${tuto_mt_moc}) target_link_libraries( tuto_mt - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ${Boost_THREAD_LIBRARY}) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ${Boost_THREAD_LIBRARY}) QT4_WRAP_CPP(tuto_ogl3_moc tuto_ogl3.h) add_executable( tuto_ogl3 tuto_ogl3.cpp ${tuto_ogl3_moc}) target_link_libraries( tuto_ogl3 - ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES}) + ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) #add_executable( tuto_ogl2 tuto_ogl2.cpp) #target_link_libraries( tuto_ogl2 -# ${CGoGN_LIBS_D} ${COMMON_LIBS} ) +# ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 085f1ba1850999b460d1f495443b627520474cde..7296182e41459ba7d72dcf81e10c20d388da8d48 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -6,13 +6,12 @@ project(CGoGN_ThirdParty) SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/..) SET(CMAKE_BUILD_TYPE Release) -SET ( BUILD_SHARED_LIBRARIES OFF CACHE BOOL - "if used all library are build as shared type (.so /dylib/dll)." -) +# for shared or not shared +SET (BUILD_SHARED_LIBS OFF CACHE BOOL + "if used all library are build as shared type (.so /dylib/dll).") -IF ( BUILD_SHARED_LIBRARIES ) - SET (SHARED_OR_STATIC SHARED) -ENDIF ( BUILD_SHARED_LIBRARIES ) +SET (WITH_ASSIMP ON CACHE BOOL "build CGoGN with Assimp") +SET (WITH_NUMERICAL ON CACHE BOOL "build CGoGN with numerical libs") IF (APPLE) @@ -28,9 +27,13 @@ ENDIF(WIN32) add_subdirectory(Zinri Zinri/build) add_subdirectory(gzstream gzstream/build) -add_subdirectory(Numerical Numerical/build) add_subdirectory(Tools Tools/build) -add_subdirectory(Assimp Assimp/build) +IF (WITH_ASSIMP) + add_subdirectory(Numerical Numerical/build) +ENDIF (WITH_ASSIMP) +IF (WITH_NUMERICAL) + add_subdirectory(Assimp Assimp/build) +ENDIF (WITH_NUMERICAL) diff --git a/ThirdParty/Numerical/CMakeLists.txt b/ThirdParty/Numerical/CMakeLists.txt index 6e4eef844fdf8cf9b649750a3d4044170b56f2ae..5faf0497c521224e724d15f67e4e172d539640a7 100644 --- a/ThirdParty/Numerical/CMakeLists.txt +++ b/ThirdParty/Numerical/CMakeLists.txt @@ -11,7 +11,7 @@ include_directories(METIS UFconfig AMD CAMD COLAMD CCOLAMD CHOLMOD UMFPACK) IF(APPLE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_MACOSX -ObjC++ -D__PLACEMENT_NEW_INLINE") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_MACOSX -O3 -fno-strict-aliasing") - SET(PATHSDK "/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks") + SET(PATHSDK "/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks" CACHE STRING) ELSE(APPLE) IF(UNIX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fno-strict-aliasing -D_UNIX -D__PLACEMENT_NEW_INLINE ") @@ -31,5 +31,5 @@ AUX_SOURCE_DIRECTORY(UMFPACK SUB_SOURCES) SET(SOURCES ${SOURCES} ${SUB_SOURCES}) -ADD_LIBRARY(numerical ${SHARED_OR_STATIC} ${SOURCES}) +ADD_LIBRARY(numerical ${SOURCES}) diff --git a/ThirdParty/Numerical/C_BLAS_LAPACK/BLAS/SRC/CMakeLists.txt b/ThirdParty/Numerical/C_BLAS_LAPACK/BLAS/SRC/CMakeLists.txt index 77469347a952eabb251a19c416170c3c88f1d7c8..51516cae4ab103de0fdba84f226a6d2619c3572c 100644 --- a/ThirdParty/Numerical/C_BLAS_LAPACK/BLAS/SRC/CMakeLists.txt +++ b/ThirdParty/Numerical/C_BLAS_LAPACK/BLAS/SRC/CMakeLists.txt @@ -136,7 +136,7 @@ if(BLAS_COMPLEX16) endif() -add_library(blas ${SHARED_OR_STATIC} ${ALLOBJ}) +add_library(blas ${ALLOBJ}) if(UNIX) target_link_libraries(blas m) endif() diff --git a/ThirdParty/Numerical/C_BLAS_LAPACK/F2CLIBS/libf2c/CMakeLists.txt b/ThirdParty/Numerical/C_BLAS_LAPACK/F2CLIBS/libf2c/CMakeLists.txt index af2711b9396d5a9a83424a85dab4ebd2871060ab..66fa36a80b65c05b30448a6ca1c582904a643fa1 100644 --- a/ThirdParty/Numerical/C_BLAS_LAPACK/F2CLIBS/libf2c/CMakeLists.txt +++ b/ThirdParty/Numerical/C_BLAS_LAPACK/F2CLIBS/libf2c/CMakeLists.txt @@ -59,6 +59,6 @@ endif() include_directories(${CLAPACK_SOURCE_DIR}/F2CLIBS/libf2c) include_directories(${CLAPACK_BINARY_DIR}/F2CLIBS/libf2c) -add_library(f2c ${SHARED_OR_STATIC} ${OFILES} ${CMAKE_CURRENT_BINARY_DIR}/arith.h) +add_library(f2c ${OFILES} ${CMAKE_CURRENT_BINARY_DIR}/arith.h) #set_property(TARGET f2c PROPERTY PREFIX lib) #pb sous windows avec le prefix lib diff --git a/ThirdParty/Numerical/C_BLAS_LAPACK/SRC/CMakeLists.txt b/ThirdParty/Numerical/C_BLAS_LAPACK/SRC/CMakeLists.txt index 16fc624ffb50bd36d57ef212ad306c7c3b061df7..ad73c2d01edc99457e7a434c98accd9fd9923afd 100644 --- a/ThirdParty/Numerical/C_BLAS_LAPACK/SRC/CMakeLists.txt +++ b/ThirdParty/Numerical/C_BLAS_LAPACK/SRC/CMakeLists.txt @@ -376,6 +376,6 @@ if(BUILD_COMPLEX16) set(ALLOBJ ${ZLASRC} ${ALLAUX} ${DZLAUX}) endif() -add_library(lapack ${SHARED_OR_STATIC} ${ALLOBJ} ${ALLXOBJ}) +add_library(lapack ${ALLOBJ} ${ALLXOBJ}) target_link_libraries(lapack blas) diff --git a/ThirdParty/Zinri/CMakeLists.txt b/ThirdParty/Zinri/CMakeLists.txt index 7eb0b78c327befa1d6389f249222137e746cf729..fb0b6683c012d1c199c13484eefc1bac8872c257 100644 --- a/ThirdParty/Zinri/CMakeLists.txt +++ b/ThirdParty/Zinri/CMakeLists.txt @@ -10,4 +10,4 @@ file( ${CMAKE_CURRENT_SOURCE_DIR}/*.c ) -add_library( Zinri ${SHARED_OR_STATIC} ${source_files} ) +add_library( Zinri ${source_files} ) diff --git a/ThirdParty/gzstream/CMakeLists.txt b/ThirdParty/gzstream/CMakeLists.txt index de600bff1cfbde8a9f9695b65aac7773846b932f..e94a1a5a190d0c8df51ccc57a4b36b26dd0a525f 100644 --- a/ThirdParty/gzstream/CMakeLists.txt +++ b/ThirdParty/gzstream/CMakeLists.txt @@ -10,4 +10,4 @@ file( ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) -add_library( gzstream ${SHARED_OR_STATIC} ${source_files} ) +add_library( gzstream ${source_files} ) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 49cefa9bc332a35927f64c8a9fd0e0d3d7f7dc57..4b20146f4fca2c25ef5c2129c83e05b96fdca04c 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -2,26 +2,22 @@ cmake_minimum_required(VERSION 2.8) project(CGoGN) -# a decommenter si on veut voir ce qui se passe a la compilation -#set( CMAKE_VERBOSE_MAKEFILE 1 ) - SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/..) -SET(CMAKE_MODULE_PATH " ${CMAKE_MODULE_PATH} ${CGoGN_ROOT_DIR}/cmake_modules/") - - -SET ( BUILD_SHARED_LIBRARIES OFF CACHE BOOL - "if used all library are build as shared type (.so /dylib/dll)." -) +# for GLEW +SET(CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/) -IF ( BUILD_SHARED_LIBRARIES ) - SET (SHARED_OR_STATIC SHARED) -ENDIF ( BUILD_SHARED_LIBRARIES ) +# for shared or not shared +SET (BUILD_SHARED_LIBS OFF CACHE BOOL + "if used all library are build as shared type (.so /dylib/dll).") find_package(OpenGL REQUIRED) find_package(Qt4 REQUIRED) find_package(Boost COMPONENTS regex thread REQUIRED) +find_package(ZLIB REQUIRED) +find_package(LibXml2 REQUIRED) +find_package(GLEW REQUIRED) IF (DEFINED ASSERTON) @@ -30,8 +26,54 @@ ELSE (DEFINED ASSERTON) add_definitions(-DCGOGN_ASSERT_BOOL=false) ENDIF (DEFINED ASSERTON) +SET ( WITH_ASSIMP ON CACHE BOOL "build CGoGN with Assimp ") +IF (WITH_ASSIMP) + add_definitions(-DWITH_ASSIMP) +ENDIF (WITH_ASSIMP) + +# FOR Qt4 +SET(QT_USE_QTOPENGL TRUE) +INCLUDE(${QT_USE_FILE}) +ADD_DEFINITIONS(${QT_DEFINITIONS}) + + add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/") +# define includes of external libs +SET(CGoGN_EXT_INCLUDES + ${CGoGN_ROOT_DIR}/ThirdParty/Numerical + ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig + ${CGoGN_ROOT_DIR}/ThirdParty/gzstream + ${CGoGN_ROOT_DIR}/ThirdParty/Zinri + ${CGoGN_ROOT_DIR}/ThirdParty/glm + ${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include + ${OPENGL_INCLUDE_DIR} + ${GLEW_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIRS} + ${LIBXML2_INCLUDE_DIR} + ${Boost_INCLUDE_DIRS} + ${QT_INCLUDE_DIR} ) + +IF (WITH_ASSIMP) + SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ThirdParty/Assimp/include) +ENDIF (WITH_ASSIMP) + +# define libs for external libs +SET (CGoGN_EXT_LIBS + ${OPENGL_LIBRARY} + ${GLEW_LIBRARIES} + ${ZLIB_LIBRARIES} + ${LIBXML2_LIBRARIES} + ${Boost_REGEX_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${QT_LIBRARIES} + gzstream) + +IF (WITH_ASSIMP) + SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} assimp) +ENDIF (WITH_ASSIMP) + + # qq definition specifiques pour mac IF(APPLE) # attention a changer pour chercher la bonne version automatiquement @@ -42,52 +84,16 @@ IF(APPLE) ENDIF(APPLE) IF(WIN32) - SET(GLEW_LIBRARY glew32) - SET(DEVIL_LIBRARIES DevIL ILU ILUT) - SET(ZLIB_LIBRARIES zlib) - SET(LIBXML2_LIBRARIES xml2) - -# MACRO(BOOST_LIBS lib_lists names) -# SET (${lib_lists} "") -# FOREACH(name ${names}) -# STRING(REGEX REPLACE "-mt" ${boost_extension} newname ${name}) -# SET (${lib_lists} ${${lib_lists}} ${newname} ) -# ENDFOREACH(name) -# ENDMACRO(BOOST_LIBS) -# set (BOOST_INCLUDE_PATH ${boost_path}) - INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/include/) LINK_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/lib/ ${boost_path}/lib) add_subdirectory(Release) add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps) - if (EXISTS "${CGoGN_ROOT_DIR}/Perso") - add_subdirectory(${CGoGN_ROOT_DIR}/Perso Perso) - endif (EXISTS "${CGoGN_ROOT_DIR}/Perso") - if(CMAKE_CONFIGURATION_TYPES) set(CMAKE_CONFIGURATION_TYPES Release Debug) set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE) endif() - ELSE(WIN32) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") - find_package(DevIL) - find_package(ZLIB) - find_package(LibXml2) - SET(GLEW_LIBRARY GLEW) - IF (IL_LIBRARIES) - SET(DEVIL_LIBRARIES ${IL_LIBRARIES} ${ILU_LIBRARIES} ${ILUT_LIBRARIES}) - ELSE(IL_LIBRARIES) - SET(DEVIL_LIBRARIES ${IL_LIBRARY} ${ILU_LIBRARY} ${ILUT_LIBRARY}) - ENDIF(IL_LIBRARIES) - -# MACRO(BOOST_LIBS lib_lists names) -# SET (${lib_lists}) -# FOREACH(name ${names}) -# SET (${lib_lists} ${${lib_lists}} ${name} ) -# ENDFOREACH(name) -# ENDMACRO(BOOST_LIBS) - add_subdirectory(Release) add_subdirectory(Debug) add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps) diff --git a/build/Debug/CMakeLists.txt b/build/Debug/CMakeLists.txt index 623d32506743d8e69097d2a01f8442ceafc012b9..39919d6f970f1b9cc36f9a44ed0eedc89016df50 100644 --- a/build/Debug/CMakeLists.txt +++ b/build/Debug/CMakeLists.txt @@ -10,7 +10,6 @@ ELSE(WIN32) SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/Debug) ENDIF(WIN32) -#SET(BUILD_SHARED_LIBS,FALSE) # FOR Qt4 SET(QT_USE_QTOPENGL TRUE) @@ -20,17 +19,11 @@ ADD_DEFINITIONS(${QT_DEFINITIONS}) include_directories( ${CMAKE_CURRENT_BINARY_DIR} - /usr/include/libxml2 ${CGoGN_ROOT_DIR}/include - ${CGoGN_ROOT_DIR}/ThirdParty/Numerical - ${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include - ${CGoGN_ROOT_DIR}/ThirdParty/gzstream - ${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include - ${CGoGN_ROOT_DIR}/ThirdParty/glm - ${Boost_INCLUDE_DIRS} - + ${CGoGN_EXT_INCLUDES} ) + file( GLOB_RECURSE files_topology @@ -39,7 +32,7 @@ file( ${CGoGN_ROOT_DIR}/include/Topology/*.h ) add_library( - topologyD ${SHARED_OR_STATIC} + topologyD ${files_topology} ) @@ -51,7 +44,7 @@ file( ${CGoGN_ROOT_DIR}/include/Container/*.h ) add_library( - containerD ${SHARED_OR_STATIC} + containerD ${files_container} ) @@ -64,7 +57,7 @@ file( ${CGoGN_ROOT_DIR}/include/Algo/*.h ) add_library( - algoD ${SHARED_OR_STATIC} + algoD ${files_algo} ) @@ -80,21 +73,16 @@ file( ${CGoGN_ROOT_DIR}/include/Utils/Shaders*.geom ) -IF(WIN32) -add_custom_target(shader_targetD ${CGoGN_ROOT_DIR}/bin/shader_to_h ${shaders_srcD} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - SOURCES ${shaders_srcD} -) -ELSE(WIN32) +#IF(WIN32) add_custom_target(shader_targetD ${CGoGN_ROOT_DIR}/bin/shader_to_h ${shaders_srcD} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - SOURCES ${shaders_srcD} -) -ENDIF(WIN32) - - - - + SOURCES ${shaders_srcD} ) +#ELSE(WIN32) +#add_custom_target(shader_targetD ${CGoGN_ROOT_DIR}/bin/shader_to_h ${shaders_srcD} +# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +# SOURCES ${shaders_srcD} +#) +#ENDIF(WIN32) file( @@ -116,7 +104,7 @@ QT4_WRAP_CPP(UTILS_QT_HEADERS_MOC ${utils_qt_headers}) SET (files_utils_withQt ${files_utils} ${UTILS_QT_HEADERS_MOC}) add_library( - utilsD ${SHARED_OR_STATIC} + utilsD ${files_utils_withQt} ) diff --git a/build/Release/CMakeLists.txt b/build/Release/CMakeLists.txt index 62ddcc0b10ff51932b075a2dbc44ab63e6edaff5..3932ae694e4680aedc1e5a09a450f98aa1ceb2fd 100644 --- a/build/Release/CMakeLists.txt +++ b/build/Release/CMakeLists.txt @@ -10,9 +10,6 @@ ELSE(WIN32) SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/Release) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING") ENDIF(WIN32) -#SET(BUILD_SHARED_LIBS,FALSE) - - # FOR Qt4 SET(QT_USE_QTOPENGL TRUE) @@ -22,15 +19,8 @@ ADD_DEFINITIONS(${QT_DEFINITIONS}) include_directories( ${CMAKE_CURRENT_BINARY_DIR} - /usr/include/libxml2 ${CGoGN_ROOT_DIR}/include - ${CGoGN_ROOT_DIR}/ThirdParty/Numerical - ${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include - ${CGoGN_ROOT_DIR}/ThirdParty/gzstream - ${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include - ${CGoGN_ROOT_DIR}/ThirdParty/glm - ${Boost_INCLUDE_DIRS} - + ${CGoGN_EXT_INCLUDES} ) file( @@ -41,7 +31,7 @@ file( ${CGoGN_ROOT_DIR}/include/Topology/*.h ) add_library( - topology ${SHARED_OR_STATIC} + topology ${files_topology} ) @@ -53,7 +43,7 @@ file( ${CGoGN_ROOT_DIR}/include/Container/*.h ) add_library( - container ${SHARED_OR_STATIC} + container ${files_container} ) @@ -66,7 +56,7 @@ file( ${CGoGN_ROOT_DIR}/include/Algo/*.h ) add_library( - algo ${SHARED_OR_STATIC} + algo ${files_algo} ) @@ -129,7 +119,7 @@ QT4_WRAP_CPP(UTILS_QT_HEADERS_MOC ${utils_qt_headers}) SET (files_utils_withQt ${files_utils} ${UTILS_QT_HEADERS_MOC}) add_library( - utils ${SHARED_OR_STATIC} + utils ${files_utils_withQt} ) diff --git a/cmake_modules/FindGLEW.cmake b/cmake_modules/FindGLEW.cmake new file mode 100644 index 0000000000000000000000000000000000000000..033ca963d2bbb79c78d5e4391a3a49e19db0a846 --- /dev/null +++ b/cmake_modules/FindGLEW.cmake @@ -0,0 +1,25 @@ +# - Find GLEW +# Find the GLEW includes and library +# +# GLEW_INCLUDE_DIRS - where to find glew.h, etc. +# GLEW_LIBRARIES - List of libraries when using GLEW. +# GLEW_FOUND - True if GLEW found. + + +FIND_PATH(GLEW_INCLUDE_DIR NAMES GL/glew.h) + +SET(GLEW_NAMES GLEW glew32) + +FIND_LIBRARY(GLEW_LIBRARY NAMES ${GLEW_NAMES} ) + +MARK_AS_ADVANCED(GLEW_LIBRARY GLEW_INCLUDE_DIR) + +# handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW DEFAULT_MSG GLEW_INCLUDE_DIR GLEW_LIBRARY) + +IF (GLEW_FOUND) + SET(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR}) + SET(GLEW_LIBRARIES ${GLEW_LIBRARY}) +ENDIF() diff --git a/include/Algo/Import/import2tables.h b/include/Algo/Import/import2tables.h index 51519f01b41ea000a80230fbc1fa41e5ef2f554d..bd168fc5606384067fd1c7fb450cf3d5cf6dcde7 100644 --- a/include/Algo/Import/import2tables.h +++ b/include/Algo/Import/import2tables.h @@ -34,9 +34,11 @@ #include "Geometry/vector_gen.h" #include "Geometry/matrix.h" +#ifdef WITH_ASSIMP #include "gzstream.h" #include "assimp.h" #include "aiScene.h" +#endif namespace CGoGN { @@ -82,7 +84,9 @@ protected: static ImportSurfacique::ImportType getFileType(const std::string& filename); +#ifdef WITH_ASSIMP void extractMeshRec(AttributeContainer& container, AttributeHandler& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo); +#endif public: typedef typename PFP::VEC3 VEC3 ; @@ -110,9 +114,9 @@ public: bool importPlyPTM(const std::string& filename, std::vector& attrNames); bool importPlyPTMgeneric(const std::string& filename, std::vector& attrNames); - +#ifdef WITH_ASSIMP bool importASSIMP(const std::string& filename, std::vector& attrNames); - +#endif bool mergeCloseVertices(); bool importAHEM(const std::string& filename, std::vector& attrNames); diff --git a/include/Algo/Import/import2tablesSurface.hpp b/include/Algo/Import/import2tablesSurface.hpp index 8119884c8c4844acafa9f0b003b666f79e9c2a4f..f1ae7f27953b8e2faf62f84adec81afedea02c25 100644 --- a/include/Algo/Import/import2tablesSurface.hpp +++ b/include/Algo/Import/import2tablesSurface.hpp @@ -28,10 +28,11 @@ #include "Algo/Import/AHEM.h" +#ifdef WITH_ASSIMP #include "assimp.h" #include "aiPostProcess.h" #include "aiScene.h" - +#endif namespace CGoGN { @@ -112,8 +113,12 @@ bool MeshTablesSurface::importMesh(const std::string& filename, std::vector return importAHEM(filename, attrNames); break; default: + #ifdef WITH_ASSIMP CGoGNout << "TYPE: ASSIMP" << CGoGNendl; return importASSIMP(filename, attrNames); + #else + CGoGNout << "unsupported file type"<< CGoGNendl; + #endif break; } return false; @@ -984,7 +989,7 @@ bool MeshTablesSurface::importAHEM(const std::string& filename, std::vector } - +#ifdef WITH_ASSIMP template void MeshTablesSurface::extractMeshRec(AttributeContainer& container, AttributeHandler& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo) { @@ -1038,6 +1043,7 @@ void MeshTablesSurface::extractMeshRec(AttributeContainer& container, Attri *trafo = prev; } + template bool MeshTablesSurface::importASSIMP(const std::string& filename, std::vector& attrNames) { @@ -1060,6 +1066,7 @@ bool MeshTablesSurface::importASSIMP(const std::string& filename, std::vect return true; } +#endif template bool MeshTablesSurface::mergeCloseVertices() diff --git a/include/Utils/img3D_IO.h b/include/Utils/img3D_IO.h index 23f50c26339d58adeca4494ead09dde21f74d734..a68bbac81b9d7f1e03dce5f03f2b94664f26802a 100644 --- a/include/Utils/img3D_IO.h +++ b/include/Utils/img3D_IO.h @@ -41,6 +41,8 @@ namespace Img3D_IO */ enum TYPEIMG {BOOL8=1, VAL8, RGB8, VAL16, VALFLOAT}; +#ifdef PORTED_TO_QIMAGE + /** * Initialization of IO * Necessary before any other call @@ -60,7 +62,7 @@ namespace Img3D_IO * @param tag image tag (reference out) * @return a pointer on the image data (that have been allocated by function) */ -// unsigned char* loadBool(char* filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag); + unsigned char* loadBool(char* filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag); /** * Save bool image (0/255) @@ -77,7 +79,7 @@ namespace Img3D_IO * @param vz voxel size z * @param tag image tag */ - void saveBool(ILstring filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag); + void saveBool(const std::string& filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag); /** * Load 8 bits image, if image is boolean compressed, it uncompress it ! @@ -92,7 +94,7 @@ namespace Img3D_IO * @param tag image tag (reference out) * @return a pointer on the image data (that have been allocated by function) */ - unsigned char* loadVal_8(ILstring filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag); + unsigned char* loadVal_8(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag); /** * Save 8bits val image @@ -108,7 +110,7 @@ namespace Img3D_IO * @param vz voxel size z * @param tag image tag */ - void saveVal(ILstring filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag); + void saveVal(const std::string& filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag); /** @@ -124,7 +126,7 @@ namespace Img3D_IO * @param tag image tag (reference out) * @return a pointer on the image data (that have been allocated by function) */ - unsigned short* loadVal_16(ILstring filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag); +// unsigned short* loadVal_16(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag); /** * Save 16bits val image @@ -140,7 +142,7 @@ namespace Img3D_IO * @param vz voxel size z * @param tag image tag */ - void saveVal_16(ILstring filename, unsigned short* data, int w, int h, int d, float vx, float vy, float vz, int tag); +// void saveVal_16(const std::string& filename, unsigned short* data, int w, int h, int d, float vx, float vy, float vz, int tag); /** * Load float value image @@ -155,7 +157,7 @@ namespace Img3D_IO * @param tag image tag (reference out) * @return a pointer on the image data (that have been allocated by function) */ - float* loadVal_float(ILstring filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& id); +// float* loadVal_float(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& id); /** * Save float val image @@ -171,7 +173,7 @@ namespace Img3D_IO * @param vz voxel size z * @param tag image tag */ - void saveVal_float(ILstring filename, float* data, int w, int h, int d, float vx, float vy, float vz, int tag); +// void saveVal_float(const std::string& filename, float* data, int w, int h, int d, float vx, float vy, float vz, int tag); /** @@ -187,7 +189,7 @@ namespace Img3D_IO * @param tag image tag (reference out) * @return a pointer on the image data (that have been allocated by function) */ - unsigned char* loadRGB(ILstring filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& id); + unsigned char* loadRGB(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& id); /** * Save RGB 8 bits image @@ -203,7 +205,8 @@ namespace Img3D_IO * @param vz voxel size z * @param tag image tag */ - void saveRGB(ILstring filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag); + void saveRGB(const std::string& filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag); +#endif } //namespace } //namespace diff --git a/include/Utils/text3d.h b/include/Utils/text3d.h index a0c6cadd7c821a799a4fc1587ab6d7a07cd903ed..68267f097a390e8a53a0c52cb1f18ef1f8bdf47f 100644 --- a/include/Utils/text3d.h +++ b/include/Utils/text3d.h @@ -56,8 +56,6 @@ protected: static std::string fragmentShaderText1; static std::string fragmentShaderText2; - static ILuint m_imgName; - static GLuint m_idTexture; std::vector m_strings; diff --git a/include/Utils/textures.h b/include/Utils/textures.h index ad121bb2358a0af7a8b10bb8f19245363977f98e..d3f74a85b9fd39a67749c9d357adb5e117645784 100644 --- a/include/Utils/textures.h +++ b/include/Utils/textures.h @@ -28,8 +28,8 @@ #include "Geometry/vector_gen.h" #include -#include #include +#include namespace CGoGN @@ -192,7 +192,7 @@ public: protected: /// id of image for DevIL - ILuint m_ilName; + QImage* m_qimg; template TYPE applyFilterOneTexel(const Filter& filter, const COORD& t) const; @@ -234,8 +234,6 @@ public: /// load from file void save(const std::string& filename); - /// delete image and IL associated data - void cleanIL(); /** * crop image diff --git a/include/Utils/textures.hpp b/include/Utils/textures.hpp index 379910c4e4bee43f4ccecc014f18d7145cb1dc9d..2a2d2aa091d507fbfe7a187f19a85a81beed96f5 100644 --- a/include/Utils/textures.hpp +++ b/include/Utils/textures.hpp @@ -20,37 +20,44 @@ * Web site: https://iggservis.u-strasbg.fr/CGoGN/ * * Contact information: cgogn@unistra.fr * * * -*******************************************************************************/ +*******************************************************************************/ #include "Utils/cgognStream.h" - -namespace CGoGN -{ -namespace Utils -{ - -// implementation class ImageData - -template < unsigned int DIM, typename TYPE > -ImageData::ImageData(): + +namespace CGoGN +{ +namespace Utils +{ + +// implementation class ImageData + +template < unsigned int DIM, typename TYPE > +ImageData::ImageData(): m_data_ptr(NULL), m_size(0), -m_sizeSub(0), -m_localAlloc(false) +m_sizeSub(0), +m_localAlloc(false) { -} - -template < unsigned int DIM, typename TYPE > +} + +template < unsigned int DIM, typename TYPE > ImageData::ImageData(const ImageData& img): m_size(img.m_size), m_sizeSub(img.m_sizeSub), -m_localAlloc(true) +m_localAlloc(true) { - m_data_ptr = new TYPE[m_sizeSub[DIM-1]]; - memcpy(m_data_ptr, img.m_data_ptr, sizeof(TYPE)*m_sizeSub[DIM-1]); -} - + if (img.m_qimg == NULL) + { + if (img.m_data_ptr != NULL) + { + m_data_ptr = new TYPE[m_sizeSub[DIM-1]]; + memcpy(m_data_ptr, img.m_data_ptr, sizeof(TYPE)*m_sizeSub[DIM-1]); + this->m_qimg = NULL; + } + } +} + template < unsigned int DIM, typename TYPE > ImageData::ImageData(const COORD& size): @@ -59,17 +66,18 @@ m_localAlloc(true) { computeSub(); m_data_ptr = new TYPE[m_sizeSub[DIM-1]]; +} + + +template < unsigned int DIM, typename TYPE > +ImageData::~ImageData() +{ + if (m_data_ptr!=NULL) + { + delete[] m_data_ptr; + } } - - - -template < unsigned int DIM, typename TYPE > -ImageData::~ImageData() -{ - if ((m_localAlloc)&&(m_data_ptr!=NULL)) - delete[] m_data_ptr; -} template < unsigned int DIM, typename TYPE > @@ -86,87 +94,89 @@ void ImageData::swap(ImageData& img) TYPE* prt_temp= m_data_ptr; m_data_ptr = img.m_data_ptr; img.m_data_ptr = prt_temp; +} + - bool tmpAlloc = m_localAlloc; - m_localAlloc = img.m_localAlloc; - img.m_localAlloc = tmpAlloc; +template < unsigned int DIM, typename TYPE > +void ImageData::computeSub() +{ + unsigned int sub=1; + for (unsigned int i=0; i -void ImageData::computeSub() -{ - unsigned int sub=1; - for (unsigned int i=0; i -void ImageData::create(TYPE* data, const COORD& size) -{ + +template < unsigned int DIM, typename TYPE > +void ImageData::create(TYPE* data, const COORD& size) +{ // first free old image if exist - if ((m_localAlloc)&&(m_data_ptr!=NULL)) - delete[] m_data_ptr; - - m_size = size; - computeSub(); - m_data_ptr = data; - m_localAlloc = false; -} - -template < unsigned int DIM, typename TYPE > -void ImageData::create(const COORD& size) + if (this->m_qimg != NULL) + { + delete this->m_qmg; + } + else if (m_data_ptr!=NULL) + { + delete[] m_data_ptr; + } + + m_size = size; + computeSub(); + m_data_ptr = data; + this->m_qimg = NULL; +} + +template < unsigned int DIM, typename TYPE > +void ImageData::create(const COORD& size) { // first free old image if exist - if ((m_localAlloc)&&(m_data_ptr!=NULL)) - delete[] m_data_ptr; - - m_size = size; - computeSub(); - m_data_ptr = new TYPE[m_sizeSub[DIM-1]]; - m_localAlloc = true; -} - - -template < unsigned int DIM, typename TYPE > -TYPE* ImageData::getPtrData() -{ - return m_data_ptr; -} - -template < unsigned int DIM, typename TYPE > -TYPE& ImageData::operator()(unsigned int i) -{ - CGoGN_STATIC_ASSERT(DIM==1, incompatible_image_dimension) ; - assert(i -TYPE& ImageData::operator()(unsigned int i, unsigned int j) -{ - CGoGN_STATIC_ASSERT(DIM==2, incompatible_image_dimension) ; - assert(i -TYPE& ImageData::operator()(unsigned int i, unsigned int j, unsigned int k) -{ - CGoGN_STATIC_ASSERT(DIM==3, incompatible_image_dimension) ; - assert(i +TYPE* ImageData::getPtrData() +{ + return m_data_ptr; +} + +template < unsigned int DIM, typename TYPE > +TYPE& ImageData::operator()(unsigned int i) +{ + CGoGN_STATIC_ASSERT(DIM==1, incompatible_image_dimension) ; + assert(i +TYPE& ImageData::operator()(unsigned int i, unsigned int j) +{ + CGoGN_STATIC_ASSERT(DIM==2, incompatible_image_dimension) ; + assert(i +TYPE& ImageData::operator()(unsigned int i, unsigned int j, unsigned int k) +{ + CGoGN_STATIC_ASSERT(DIM==3, incompatible_image_dimension) ; + assert(i @@ -217,16 +227,16 @@ TYPE& ImageData::texel(const COORD& coord) ptr += coord[i]*m_sizeSub[i]; return *ptr; } - - -template < unsigned int DIM, typename TYPE > -const TYPE& ImageData::texel(const COORD& coord) const -{ - TYPE* ptr = m_data_ptr; - for (unsigned int i=0; i +const TYPE& ImageData::texel(const COORD& coord) const +{ + TYPE* ptr = m_data_ptr; + for (unsigned int i=0; i template < typename TYPE2 > @@ -243,36 +253,18 @@ void ImageData::convert(ImageData& output, TYPE2 (*convertF } -//template < unsigned int DIM, typename TYPE > -//template < typename TYPE2 > -//ImageData::ImageData(const ImageData& img, TYPE (*convertFunc)(const TYPE2&)) -//{ -// m_size = img.m_size; -// m_sizeSub = img.m_sizeSub; -// m_data_ptr = new TYPE[m_sizeSub[DIM-1]]; -// m_localAlloc = true; -// -// TYPE* ptrDst = m_data_ptr; -// TYPE2* ptrSrc = img.m_data_ptr; -// -// for (unsigned int i = 0; i +// implementation class Image + +template < unsigned int DIM, typename TYPE > Image::Image(): -m_ilName(0) -{ +m_qimg(NULL) +{ } template < unsigned int DIM, typename TYPE > Image::Image(const COORD& size): ImageData(size), -m_ilName(0) +m_qimg(NULL) { } @@ -280,67 +272,81 @@ m_ilName(0) template < unsigned int DIM, typename TYPE > Image::~Image() { - if (ilIsImage(m_ilName)) - ilDeleteImage(m_ilName); -} + if (this->m_qimg != NULL) + delete this->m_qimg; + m_qimg = NULL; + this->m_data_ptr = NULL; +} template < unsigned int DIM, typename TYPE > void Image::swap(Image& img) { + if ((this->m_qimg != NULL) && (img.m_qimg != NULL)) + { + QImage* ptr = this->m_qimg; + this->m_qimg = img.m_qimg; + img.m_qimg = ptr; + } + ImageData::swap(img); - ILuint tempo = m_ilName; - m_ilName = img.m_ilName; - img.m_ilName = tempo; } - -template < unsigned int DIM, typename TYPE > -bool Image::load(const std::string& filename) -{ - CGoGN_STATIC_ASSERT(DIM==2, incompatible_Vector_constructor_dimension); - ILuint ilName; - ilGenImages(1,&ilName); - ilBindImage(ilName); - // ??? - ilOriginFunc(IL_ORIGIN_LOWER_LEFT); - ilEnable(IL_ORIGIN_SET); +template < unsigned int DIM, typename TYPE > +bool Image::load(const std::string& filename) +{ + CGoGN_STATIC_ASSERT(DIM==2, incompatible_Vector_constructor_dimension); - bool ok = ilLoadImage(filename.c_str()); + QImage* ptr = new QImage(filename.c_str()); - if (!ok) + if (ptr == NULL) { - ilDeleteImage(ilName); + delete ptr; return false; } - - if ((this->m_localAlloc)&&(this->m_data_ptr!=NULL)) - delete[] this->m_data_ptr; - if (ilIsImage(m_ilName)) - ilDeleteImage(m_ilName); - m_ilName = ilName; - - -// get the info of images - ILuint bpp = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL); + + // get the info of images + unsigned int bpp = ptr->depth() / 8; // compatible TYPE - if (bpp != sizeof(TYPE)) + if (bpp < sizeof(TYPE)) { CGoGNout << "Image::load incompatible type: bbp="< namespace CGoGN { @@ -34,30 +35,6 @@ namespace Utils #include "text3d.vert" #include "text3d.frag" -//std::string Strings3D::vertexShaderText = -//"ATTRIBUTE vec4 VertexPosition;\n" -//"uniform mat4 ModelViewMatrix;\n" -//"uniform mat4 ProjectionMatrix;\n" -//"uniform vec3 strPos;\n" -//"uniform float scale;\n" -//"VARYING_VERT vec2 tex_coord;\n" -//"INVARIANT_POS;\n" -//"void main ()\n" -//"{\n" -//" vec4 pos = ModelViewMatrix * vec4(strPos,1.0) + vec4(VertexPosition[0]*scale,VertexPosition[1]*scale,0.0,0.0);\n" -//" tex_coord = vec2(VertexPosition[2],VertexPosition[3]);\n" -//" gl_Position = ProjectionMatrix * pos;\n" -//"}"; -// -// -//std::string Strings3D::fragmentShaderText1 = -//"VARYING_FRAG vec2 tex_coord;\n" -//"uniform sampler2D FontTexture;\n" -//"uniform vec3 color;\n" -//"FRAG_OUT_DEF;\n" -//"void main (void)\n" -//"{\n" -//" float lum = texture2D(FontTexture, tex_coord).s;\n"; std::string Strings3D::fragmentShaderText2 = " gl_FragColor = vec4(color,0.0)*lum;\n" @@ -65,25 +42,19 @@ std::string Strings3D::fragmentShaderText2 = GLuint Strings3D::m_idTexture = 0xffffffff; -ILuint Strings3D::m_imgName; Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc) : m_nbChars(0) { if (m_idTexture == 0xffffffff) { - std::string font_finename = Utils::GLSLShader::findFile("font_cgogn.png"); - ilInit(); - ilOriginFunc(IL_ORIGIN_UPPER_LEFT); - ilEnable(IL_ORIGIN_SET); - - ilGenImages(1,&m_imgName); - ilBindImage(m_imgName); - ilLoadImage(font_finename.c_str()); - + std::string font_filename = Utils::GLSLShader::findFile("font_cgogn.png"); + + QImage img(font_filename.c_str()); + glGenTextures(1, &m_idTexture); glBindTexture(GL_TEXTURE_2D, m_idTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, WIDTHTEXTURE, HEIGHTTEXTURE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, (GLvoid*)(ilGetData())); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, WIDTHTEXTURE, HEIGHTTEXTURE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, (GLvoid*)(img.bits())); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } @@ -132,8 +103,6 @@ void Strings3D::setScale(float scale) Strings3D::~Strings3D() { - ilDeleteImages(1 ,&m_imgName); - delete m_vbo1; } unsigned int Strings3D::addString(const std::string& str) diff --git a/src/Utils/xglutwin_gl3.cppx b/src/Utils/xglutwin_gl3.cppx deleted file mode 100644 index 05ed004bc196985cd8be21d6be413b248a7791aa..0000000000000000000000000000000000000000 --- a/src/Utils/xglutwin_gl3.cppx +++ /dev/null @@ -1,526 +0,0 @@ -/******************************************************************************* -* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * -* version 0.1 * -* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg * -* * -* This library is free software; you can redistribute it and/or modify it * -* under the terms of the GNU Lesser General Public License as published by the * -* Free Software Foundation; either version 2.1 of the License, or (at your * -* option) any later version. * -* * -* This library is distributed in the hope that it will be useful, but WITHOUT * -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * -* for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with this library; if not, write to the Free Software Foundation, * -* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * -* * -* Web site: http://cgogn.u-strasbg.fr/ * -* Contact information: cgogn@unistra.fr * -* * -*******************************************************************************/ - -//#ifndef MAC_OSX - -#include - -#include "Utils/glutwingl3.h" -#include -#include -#include - -#include - -#include "gzstream.h" -#include "glm/glm.hpp" -#include "glm/gtc/matrix_projection.hpp" -#include "glm/gtc/matrix_transform.hpp" -#include "glm/gtc/type_ptr.hpp" -#include "glm/gtx/inverse_transpose.hpp" - -namespace CGoGN -{ - -namespace Utils -{ - -SimpleGlutWinGL3* SimpleGlutWinGL3::instance=NULL; -float SimpleGlutWinGL3::scalefactor = 1.0f; -float SimpleGlutWinGL3::trans_x=0.; -float SimpleGlutWinGL3::trans_y=0.; -float SimpleGlutWinGL3::trans_z=0.; - -float SimpleGlutWinGL3::foc=2.0f; - -float SimpleGlutWinGL3::curquat[4]={0.0f,0.0f,0.0f,0.0f}; -float SimpleGlutWinGL3::lastquat[4]={0.0f,0.0f,0.0f,0.0f}; -int SimpleGlutWinGL3::spinning = 0; -int SimpleGlutWinGL3::moving = 0; -int SimpleGlutWinGL3::newModel = 1; -int SimpleGlutWinGL3::translating=0; -int SimpleGlutWinGL3::scaling=0; -int SimpleGlutWinGL3::beginx=0; -int SimpleGlutWinGL3::beginy=0; -int SimpleGlutWinGL3::W=0; -int SimpleGlutWinGL3::H=0; -bool SimpleGlutWinGL3::m_noMouse=false; - -float SimpleGlutWinGL3::m_obj_sc; -glm::vec3 SimpleGlutWinGL3::m_obj_pos; - -Utils::GLSLShader* SimpleGlutWinGL3::m_current_shaders=NULL; - -glm::mat4 SimpleGlutWinGL3::m_projection_matrix; - -glm::mat4 SimpleGlutWinGL3::m_modelView_matrix; - -std::stack SimpleGlutWinGL3::m_stack_mv; - -// light -//glm::vec4 SimpleGlutWinGL3::m_materialAmbient; -//glm::vec4 SimpleGlutWinGL3::m_materialDiffuse; -//glm::vec4 SimpleGlutWinGL3::m_materialSpecular; -//float SimpleGlutWinGL3::m_materialShininess; -// -//glm::vec4 SimpleGlutWinGL3::m_lightPosition; -//glm::vec4 SimpleGlutWinGL3::m_lightDiffuse; -//glm::vec4 SimpleGlutWinGL3::m_lightSpecular; -//glm::vec4 SimpleGlutWinGL3::m_lightAmbient; - - -SimpleGlutWinGL3::SimpleGlutWinGL3(int* argc, char **argv, int winX, int winY) -{ - instance = this; - spinning = 0; - moving = 0; - newModel = 1; - scalefactor = 1.0f; - trans_x=0.; - trans_y=0.; - trans_z=-50.0f; - - glutInit(argc, argv); - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); - glutCreateWindow(argv[0]); -// glutInitContextVersion (3, 2); -// glutInitContextFlags (GLUT_FORWARD_COMPATIBLE | GLUT_DEBUG); - - glutReshapeWindow(winX,winY); - W=winX; H=winY; - trackball(curquat, 0.0f, 0.0f, 0.0f, 0.0f); - glutDisplayFunc(redraw); - glutReshapeFunc(reshape); - glutVisibilityFunc(vis); - glutMouseFunc(mouse); - glutMotionFunc(motion); - glutKeyboardFunc(keyboard); - - GLint MajorVersionContext = 0; - GLint MinorVersionContext = 0; - glGetIntegerv(GL_MAJOR_VERSION, &MajorVersionContext); - glGetIntegerv(GL_MINOR_VERSION, &MinorVersionContext); - - std::cout << "OpenGL v"<init(); -} - - - -void SimpleGlutWinGL3::oglRotate(float angle, float x, float y, float z) -{ - m_modelView_matrix = glm::rotate(m_modelView_matrix, angle, glm::vec3(x,y,z)); -} - -void SimpleGlutWinGL3::oglTranslate(float tx, float ty, float tz) -{ - m_modelView_matrix = glm::translate(m_modelView_matrix, glm::vec3(tx,ty,tz)); -} - -void SimpleGlutWinGL3::oglScale(float sx, float sy, float sz) -{ - m_modelView_matrix = glm::scale(m_modelView_matrix, glm::vec3(sx,sy,sz)); -} - -void SimpleGlutWinGL3::oglPushModelViewMatrix() -{ - m_stack_mv.push(m_modelView_matrix); -} - - -bool SimpleGlutWinGL3::oglPopModelViewMatrix() -{ - if (m_stack_mv.empty()) - return false; - m_modelView_matrix = m_stack_mv.top(); - m_stack_mv.pop(); - return true; -} - - -//void SimpleGlutWinGL3::setParameters(int spec, float* val) -//{ -// switch(spec) -// { -// case DIFFUSE_MATERIAL: -// m_materialDiffuse = glm::vec4(val[0],val[1],val[2],val[3]); -// break; -// case SPECULAR_MATERIAL: -// m_materialSpecular = glm::vec4(val[0],val[1],val[2],val[3]); -// break; -// case AMBIENT_MATERIAL: -// m_materialAmbient = glm::vec4(val[0],val[1],val[2],val[3]); -// break; -// case SHININESS: -// m_materialShininess = *val; -// break; -// case DIFFUSE_LIGHT: -// m_lightDiffuse = glm::vec4(val[0],val[1],val[2],val[3]); -// break; -// case SPECULAR_LIGHT: -// m_lightSpecular = glm::vec4(val[0],val[1],val[2],val[3]); -// break; -// case AMBIENT_LIGHT: -// m_lightAmbient = glm::vec4(val[0],val[1],val[2],val[3]); -// break; -// case LIGHT_POSITION: -// m_lightPosition = glm::vec4(val[0],val[1],val[2],val[3]); -// break; -// default: -// std::cerr << "setParameters: wrong parameter"<< std::endl; -// break; -// } -//} - -void SimpleGlutWinGL3::setParamObject(float width, float* pos) -{ - m_obj_sc = 50.0f / width; - m_obj_pos = glm::vec3(-pos[0],-pos[1],-pos[2]); -} - - -void SimpleGlutWinGL3::setCurrentShader(Utils::GLSLShader* sh) -{ - m_current_shaders = sh; - m_current_shaders->bind(); - setModelViewProjectionMatrix(m_current_shaders); - glutPostRedisplay(); -} - - -void SimpleGlutWinGL3::releaseContext() -{ -#ifdef WIN32 - wglMakeCurrent(NULL,NULL); -#else - #ifdef MAC_OSX - CGLSetCurrentContext(NULL); - #else - glXMakeCurrent(m_dpy,None,NULL); - #endif -#endif -} - -void SimpleGlutWinGL3::useContext() -{ -#ifdef WIN32 - wglMakeCurrent(m_drawable, m_context); -#else - #ifdef MAC_OSX - CGLSetCurrentContext(m_context); - #else - glXMakeCurrent(m_dpy, m_drawable, m_context); - #endif -#endif - -} - - - - - -void SimpleGlutWinGL3::recalcModelView(void) -{ - glm::mat4 m; - - oglPopModelViewMatrix(); - oglPushModelViewMatrix(); - - oglTranslate(trans_x,trans_y,trans_z+foc); - - build_rotmatrixgl3(m, curquat); - - m_modelView_matrix *= m; - - float sc = getScale(); - oglScale(sc,sc,sc); - - - oglScale(m_obj_sc,m_obj_sc,m_obj_sc); - oglTranslate(m_obj_pos[0], m_obj_pos[1], m_obj_pos[2]); - - - newModel = 0; - - setModelViewProjectionMatrix(m_current_shaders); -} - -void SimpleGlutWinGL3::redraw(void) -{ - if (newModel) - { - recalcModelView(); - } - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - instance->myRedraw(); - - glutSwapBuffers(); -} - -void SimpleGlutWinGL3::reshape(int w, int h) -{ - if (w>0) W = w; - if (h>0) H = h; - - glViewport(0,0,W,H); - m_projection_matrix = glm::frustum(-1.0f,1.0f,-1.0f*H/W,1.0f*H/W,foc,500.0f); - recalcModelView(); -} - -void SimpleGlutWinGL3::animate(void) -{ - add_quats(lastquat, curquat, curquat); - newModel = 1; - glutPostRedisplay(); -} - -void SimpleGlutWinGL3::motion(int x, int y) -{ - if (!m_noMouse) - { - if (scaling || translating) - { - if (scaling) - { - scalefactor = scalefactor * (1.0f + (((float) (beginy - y)) / H)); - } - else if (translating) - { - trans_x += 0.01f*(x - beginx); - trans_y += 0.01f*(beginy - y); - } - beginx = x; - beginy = y; - newModel = 1; - glutPostRedisplay(); - return; - } - - if (moving) - { - trackball(lastquat, (2.0f * beginx - W) / W,(H - 2.0f * beginy) / H, - (2.0f * x - W) / W,(H - 2.0f * y) / H ); - beginx = x; - beginy = y; - spinning = 1; - // glutIdleFunc(animate); - animate(); - } - } - - instance->myMouseMotion(x, y); -} - -void SimpleGlutWinGL3::vis(int visible) -{ - if (spinning) - { - glutIdleFunc(NULL); - } - -} - -void SimpleGlutWinGL3::mouse(int button, int state, int x, int y) -{ - if (!m_noMouse) - { - if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) - { - spinning = 0; - glutIdleFunc(NULL); - moving = 1; - beginx = x; - beginy = y; - scaling = (glutGetModifiers() & GLUT_ACTIVE_SHIFT) != 0; - translating = (glutGetModifiers() & GLUT_ACTIVE_CTRL) != 0; - } - else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) - { - moving = 0; - } - } - instance->myMouseClick(button, state, x, y); -} - -void SimpleGlutWinGL3::keyboard(unsigned char keycode, int x, int y) -{ - if (keycode == 27) - { - instance->exitCallback(); - exit(0); - } - instance->myKeyboard(keycode, x, y); -} - -int SimpleGlutWinGL3::mainLoop() -{ - glutMainLoop(); - return 0; -} - - - - - -void SimpleGlutWinGL3::setModelViewProjectionMatrix(Utils::GLSLShader* current) -{ - glm::mat4 PMV = m_projection_matrix*m_modelView_matrix; - current->setuniformf<16>("ModelViewProjectionMatrix", &PMV[0][0]); - - current->setuniformf<16>("ModelViewMatrix", &m_modelView_matrix[0][0]); - - glm::mat4 normalMatrix = glm::gtx::inverse_transpose::inverseTranspose(m_modelView_matrix); - current->setuniformf<16>("NormalMatrix", &normalMatrix[0][0]); -} - - - - - -void SimpleGlutWinGL3::capturePNG(const char* filename) -{ - ILuint imgName; - ilGenImages(1,&imgName); - ilBindImage(imgName); - ilutGLScreen(); - - // save image - ilEnable(IL_FILE_OVERWRITE); - ilSaveImage((ILstring) filename); - ilDeleteImages(1,&imgName); -} - -GLfloat SimpleGlutWinGL3::getOrthoScreenRay(int x, int y, Geom::Vec3f& rayA, Geom::Vec3f& rayB) -{ -// GLdouble model[16]; -// GLdouble proj[16]; -// GLint view[4]; -// -// // get Z from depth buffer -// GLfloat prof; -// glReadPixels(x,H-y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&prof); -// -// // get matrices -//// glGetDoublev(GL_MODELVIEW_MATRIX,model); -//// glGetDoublev(GL_PROJECTION_MATRIX,proj); -//// glGetIntegerv(GL_VIEWPORT,view); -// -// // unproject x,y,0 -// GLdouble xx, yy, zz; -// gluUnProject(x, H-y, 0.0f, model, proj, view, &xx, &yy, &zz); -// rayA[0] = float(xx); -// rayA[1] = float(yy); -// rayA[2] = float(zz); -// -// // unprojet x,y,z -// gluUnProject(x, H-y, prof, model, proj, view, &xx, &yy, &zz); -// rayB[0] = float(xx); -// rayB[1] = float(yy); -// rayB[2] = float(zz); -// return prof; - return 0.0; -} - -//void SimpleGlutWinGL3::printString2D(int x, int y, const std::string& str) -//{ -// // PASSAGE EN 2D -// glMatrixMode(GL_PROJECTION); -// glPushMatrix(); -// glLoadIdentity(); -// glOrtho(0, W, H,0, -1, 1); -// glMatrixMode(GL_MODELVIEW); -// glPushMatrix(); -// glLoadIdentity(); -// glDisable(GL_DEPTH_TEST); -// glDisable(GL_LIGHTING); -// -// // AFFICHAGE EN 2D -// int x1 = x; -// for (unsigned i=0; i