forked from sofa-framework/sofa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SofaFramework] Isolate OpenGL code into a single module (Sofa.GL) (s…
…ofa-framework#1649) * new module, move files, setup cmake * make the module compile * make SofaFramework compiling * split Transformation (w/ and wo ogl) * move DrawToolGL in gl, move DrawTool in helper, make sofacore independent of Sofa.GL * add compat mechanism * move Trackball to helper::visual (as it has no opengl code), and add compat from helper::gl * Make SofaOpenGLVisual (and others) compiling * Make SofaGuiQt (and others) compiling * add Sofa.GL test * clean compat * add Color compat * Add Sofa.GL dep to SofaEulerianFluid * add last compat header (seems unused, but in case of) * change ref to InvertibleFVM * Fix cmake config with no opengl and win include dir * Make Sofa.GL a real package (i.e able to do find_package() and stuff) * use only drawtool for Visual3DText, remove gl dependency * remove macro SOFA_NO_OPENGL and use Sofa.GL package mechanism * add Sofa.GL dependency to OpenCL * remove SOFA_NO_OPENGL use in Sofa codebase (i.e no in the plugins) * Change message to ref the PR number for more info * Add dep to sofa.gl for OptiTrackNatNet * IDE: add Sofa.GL in the SofaFramework folder * replace _API keyword (with SOFA_GL_API) * Revert "Merge remote-tracking branch 'origin/fix_cmake_win_noopengl_png' into isolate_gl" This reverts commit 8828228, reversing changes made to 81885a0. * [CImgPlugin] CLEAN dependencies in CMakeLists * [CImgPlugin] FIX Zlib dependency * [CImgPlugin] CLEAN link to release deps only * Fix image with GL * fix merge... * Update CMakeLists.txt * Update VisualParams.h Co-authored-by: Guillaume Paran <guillaume.paran@sofa-framework.org>
- Loading branch information
Showing
113 changed files
with
1,947 additions
and
1,058 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
project(Sofa.GL LANGUAGES CXX) | ||
|
||
set(SOFAGLSRC_ROOT "src/sofa/gl") | ||
|
||
sofa_find_package(OpenGL REQUIRED BOTH_SCOPES) | ||
sofa_find_package(GLEW BOTH_SCOPES) | ||
|
||
set(HEADER_FILES | ||
${SOFAGLSRC_ROOT}/config.h.in | ||
${SOFAGLSRC_ROOT}/initSofa.GL.h | ||
${SOFAGLSRC_ROOT}/gl.h | ||
${SOFAGLSRC_ROOT}/glu.h | ||
${SOFAGLSRC_ROOT}/Capture.h | ||
${SOFAGLSRC_ROOT}/Color.h | ||
${SOFAGLSRC_ROOT}/RAII.h | ||
${SOFAGLSRC_ROOT}/template.h | ||
${SOFAGLSRC_ROOT}/Axis.h | ||
${SOFAGLSRC_ROOT}/BasicShapes.h | ||
${SOFAGLSRC_ROOT}/BasicShapesGL.h | ||
${SOFAGLSRC_ROOT}/BasicShapesGL.inl | ||
${SOFAGLSRC_ROOT}/Cylinder.h | ||
${SOFAGLSRC_ROOT}/Texture.h | ||
${SOFAGLSRC_ROOT}/VideoRecorderFFMPEG.h | ||
${SOFAGLSRC_ROOT}/glText.h | ||
${SOFAGLSRC_ROOT}/glText.inl | ||
${SOFAGLSRC_ROOT}/TransformationGL.h | ||
${SOFAGLSRC_ROOT}/DrawToolGL.h | ||
) | ||
|
||
set(SOURCE_FILES | ||
${SOFAGLSRC_ROOT}/initSofa.GL.cpp | ||
${SOFAGLSRC_ROOT}/Axis.cpp | ||
${SOFAGLSRC_ROOT}/BasicShapesGL.cpp | ||
${SOFAGLSRC_ROOT}/Cylinder.cpp | ||
${SOFAGLSRC_ROOT}/glText.cpp | ||
${SOFAGLSRC_ROOT}/Capture.cpp | ||
${SOFAGLSRC_ROOT}/Texture.cpp | ||
${SOFAGLSRC_ROOT}/VideoRecorderFFMPEG.cpp | ||
${SOFAGLSRC_ROOT}/Color.cpp | ||
${SOFAGLSRC_ROOT}/gl.cpp | ||
${SOFAGLSRC_ROOT}/TransformationGL.cpp | ||
${SOFAGLSRC_ROOT}/DrawToolGL.cpp | ||
) | ||
|
||
if(GLEW_FOUND) | ||
list(APPEND HEADER_FILES | ||
${SOFAGLSRC_ROOT}/FrameBufferObject.h | ||
${SOFAGLSRC_ROOT}/GLSLShader.h | ||
) | ||
list(APPEND SOURCE_FILES | ||
${SOFAGLSRC_ROOT}/FrameBufferObject.cpp | ||
${SOFAGLSRC_ROOT}/GLSLShader.cpp | ||
) | ||
list(APPEND SHADER_FILES | ||
${SOFAGLSRC_ROOT}/shaders/generateSphere.cppglsl | ||
) | ||
endif() | ||
|
||
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC SofaHelper SofaDefaultType) | ||
|
||
target_compile_definitions(${PROJECT_NAME} PRIVATE SOFA_BUILD_SOFA_GL) # To remove once sofa_add_targets_to_package remove the dot in the generated definition | ||
|
||
if(TARGET OpenGL::GL AND TARGET OpenGL::GLU) # Imported targets defined since CMake 3.8 | ||
target_link_libraries(${PROJECT_NAME} PUBLIC OpenGL::GL OpenGL::GLU) | ||
else() | ||
target_link_libraries(${PROJECT_NAME} PUBLIC ${OPENGL_LIBRARIES}) | ||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${OPENGL_INCLUDE_DIR}) | ||
endif() | ||
if(CMAKE_SYSTEM_NAME STREQUAL Linux AND SOFA_BUILD_RELEASE_PACKAGE AND OPENGL_GLU_FOUND) | ||
# Add GLU to Linux binaries | ||
sofa_install_libraries(PATHS ${OPENGL_glu_LIBRARY}) | ||
endif() | ||
|
||
if(GLEW_FOUND) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC GLEW::GLEW) | ||
if (SOFA_BUILD_RELEASE_PACKAGE OR CMAKE_SYSTEM_NAME STREQUAL Windows) | ||
sofa_install_libraries(TARGETS GLEW::GLEW) | ||
endif() | ||
else() | ||
message("OpenGL advanced functions (e.g shaders, FBO) are disabled.") | ||
endif() | ||
|
||
# own include dir, the macro does not handle "independent" package for SofaFramework-style include | ||
# i.e NOT the name of package first (sofa/gl is wanted, instead of Sofa.GL/) | ||
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}/${PROJECT_NAME}>") | ||
|
||
sofa_create_package_with_targets( | ||
PACKAGE_NAME ${PROJECT_NAME} | ||
PACKAGE_VERSION ${Sofa_VERSION} | ||
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES | ||
INCLUDE_SOURCE_DIR "src" | ||
INCLUDE_INSTALL_DIR "${PROJECT_NAME}" | ||
RELOCATABLE "SofaFramework" | ||
) | ||
|
||
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER SofaFramework) | ||
|
||
# Tests | ||
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled | ||
cmake_dependent_option(SOFAGL_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF) | ||
if(SOFAGL_BUILD_TESTS) | ||
enable_testing() | ||
add_subdirectory(${PROJECT_NAME}_test) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Sofa.GL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# CMake package configuration file for the @PROJECT_NAME@ module | ||
|
||
@PACKAGE_GUARD@ | ||
@PACKAGE_INIT@ | ||
|
||
set(SOFA.GL_HAVE_GLEW @SOFA.GL_HAVE_GLEW@) | ||
|
||
find_package(SofaFramework QUIET REQUIRED) # SofaHelper SofaDefaulttype | ||
find_package(OpenGL QUIET REQUIRED) | ||
|
||
if(SOFA.GL_HAVE_GLEW) | ||
find_package(GLEW QUIET REQUIRED) | ||
endif() | ||
|
||
if(NOT TARGET @PROJECT_NAME@) | ||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") | ||
endif() | ||
|
||
check_required_components(@PROJECT_NAME@) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
project(Sofa.GL_test) | ||
|
||
set(SOURCE_FILES | ||
src/GLSLShader_test.cpp | ||
) | ||
|
||
add_executable(${PROJECT_NAME} ${SOURCE_FILES}) | ||
target_link_libraries(${PROJECT_NAME} SofaGTestMain Sofa.GL) | ||
|
||
add_test(NAME Sofa.GL_test COMMAND Sofa.GL_test) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.