Skip to content

Commit

Permalink
Add osgEarthImGui nodekit and remove the imgui submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Jul 11, 2024
1 parent a2786fc commit 2267aaf
Show file tree
Hide file tree
Showing 58 changed files with 65,228 additions and 457 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "src/third_party/imgui"]
path = src/third_party/imgui
url = https://github.com/ocornut/imgui.git
branch = docking
[submodule "src/third_party/lerc"]
path = src/third_party/lerc
url = https://github.com/Esri/lerc.git
Expand Down
13 changes: 5 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ include(oe_win32)

option(OSGEARTH_BUILD_TOOLS "Build the osgEarth command-line tools" ON)
option(OSGEARTH_BUILD_EXAMPLES "Build the osgEarth example applications" ON)
option(OSGEARTH_BUILD_IMGUI_NODEKIT "Build the osgEarth ImGui nodekit and ImGui-based apps" ON)
option(OSGEARTH_BUILD_CESIUM_NODEKIT "Build the Cesium nodekit (osgEarthCesium)" OFF)
option(OSGEARTH_BUILD_TRITON_NODEKIT "Build support for SunDog Triton SDK" OFF)
option(OSGEARTH_BUILD_SILVERLINING_NODEKIT "Build support for SunDog SilverLining SDK" OFF)
Expand Down Expand Up @@ -124,14 +125,6 @@ endif()
find_package(OpenGL REQUIRED)
find_package(OpenSceneGraph REQUIRED COMPONENTS osg osgDB osgGA osgManipulator osgShadow osgSim osgText osgUtil osgViewer OpenThreads)

# optional - GLEW supports ImGui
find_package(GLEW)

if(GLEW_FOUND AND EXISTS "${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui.cpp")
set(OSGEARTH_HAVE_IMGUI 1)
endif()


# integrated profiling with tracy?
if(OSGEARTH_ENABLE_PROFILING)
find_package(Tracy)
Expand All @@ -150,6 +143,10 @@ if(OSGEARTH_ASSUME_SINGLE_THREADED_OSG)
add_definitions(-DOSGEARTH_SINGLE_THREADED_OSG)
endif()

# imgui?
if(OSGEARTH_BUILD_IMGUI_NODEKIT)
set(OSGEARTH_HAVE_IMGUI_NODEKIT ON) # for BuildConfig
endif()


# Bring in our utility macros that sub-projects will use to configure themselves.
Expand Down
132 changes: 65 additions & 67 deletions cmake/osgearth-macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,45 +193,45 @@ macro(add_osgearth_app)

set(OK_TO_BUILD TRUE)

if (MY_USE_IMGUI)
if(OSGEARTH_HAVE_IMGUI)
list(APPEND MY_INCLUDE_DIRECTORIES
${GLEW_INCLUDE_DIR}
${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui
${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/examples )
# if (MY_USE_IMGUI)
# if(OSGEARTH_HAVE_IMGUI)
# list(APPEND MY_INCLUDE_DIRECTORIES
# ${GLEW_INCLUDE_DIR}
# ${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui
# ${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/examples )

list(APPEND MY_SOURCES
${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui.cpp
${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui_demo.cpp
${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui_draw.cpp
${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui_widgets.cpp
${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui_tables.cpp
${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/backends/imgui_impl_opengl3.cpp
${OSGEARTH_SOURCE_DIR}/src/osgEarth/ImGui/ImGui.cpp )

list(APPEND MY_LIBRARIES
${MY_LIBRARIES} ${GLEW_LIBRARIES} ${CMAKE_DL_LIBS} OpenGL::GL)

# define for conditional compilation (esp for imgui headers)
if(OSGEARTHPROCEDURAL_LIBRARY)
add_definitions(-DHAVE_OSGEARTHPROCEDURAL)
list(APPEND MY_LIBRARIES osgEarthProcedural)
endif()

if(OSGEARTHCESIUM_LIBRARY)
add_definitions(-DHAVE_OSGEARTHCESIUM)
list(APPEND MY_LIBRARIES osgEarthCesium)
endif()
else()
message(STATUS "ImGui application '${MY_TARGET}' skipped")
if (NOT GLEW_FOUND)
message(STATUS " ...because GLEW not found")
elseif (NOT EXISTS "${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui.cpp")
message(STATUS " ...because ImGui git submodule not found")
endif()
set(OK_TO_BUILD FALSE)
endif()
endif()
# list(APPEND MY_SOURCES
# ${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui.cpp
# ${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui_demo.cpp
# ${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui_draw.cpp
# ${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui_widgets.cpp
# ${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui_tables.cpp
# ${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/backends/imgui_impl_opengl3.cpp
# ${OSGEARTH_SOURCE_DIR}/src/osgEarth/ImGui/ImGui.cpp )

# list(APPEND MY_LIBRARIES
# ${MY_LIBRARIES} ${GLEW_LIBRARIES} ${CMAKE_DL_LIBS} OpenGL::GL)

# # define for conditional compilation (esp for imgui headers)
# if(OSGEARTHPROCEDURAL_LIBRARY)
# add_definitions(-DHAVE_OSGEARTHPROCEDURAL)
# list(APPEND MY_LIBRARIES osgEarthProcedural)
# endif()

# if(OSGEARTHCESIUM_LIBRARY)
# add_definitions(-DHAVE_OSGEARTHCESIUM)
# list(APPEND MY_LIBRARIES osgEarthCesium)
# endif()
# else()
# message(STATUS "ImGui application '${MY_TARGET}' skipped")
# if (NOT GLEW_FOUND)
# message(STATUS " ...because GLEW not found")
# elseif (NOT EXISTS "${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui.cpp")
# message(STATUS " ...because ImGui git submodule not found")
# endif()
# set(OK_TO_BUILD FALSE)
# endif()
# endif()

if (OK_TO_BUILD)
set(ALL_HEADERS ${MY_HEADERS})
Expand All @@ -244,19 +244,19 @@ macro(add_osgearth_app)
target_link_libraries(${MY_TARGET} PRIVATE osgEarth ${OPENSCENEGRAPH_LIBRARIES} ${MY_LIBRARIES})

# ImGui apps may use panels that require linking to all nodekits
if (MY_USE_IMGUI)
if(OSGEARTH_HAVE_PROCEDURAL_NODEKIT)
target_link_libraries(${MY_TARGET} PRIVATE osgEarthProcedural)
endif()

if (OSGEARTH_HAVE_LEGACY_SPLAT_NODEKIT)
target_link_libraries(${MY_TARGET} PRIVATE osgEarthSplat)
endif()

if (OSGEARTH_HAVE_CESIUM_NODEKIT)
target_link_libraries(${MY_TARGET} PRIVATE osgEarthCesium)
endif()
endif()
# if (MY_USE_IMGUI)
# if(OSGEARTH_HAVE_PROCEDURAL_NODEKIT)
# target_link_libraries(${MY_TARGET} PRIVATE osgEarthProcedural)
# endif()

# if (OSGEARTH_HAVE_LEGACY_SPLAT_NODEKIT)
# target_link_libraries(${MY_TARGET} PRIVATE osgEarthSplat)
# endif()

# if (OSGEARTH_HAVE_CESIUM_NODEKIT)
# target_link_libraries(${MY_TARGET} PRIVATE osgEarthCesium)
# endif()
# endif()

set_target_properties(${MY_TARGET} PROPERTIES PROJECT_LABEL "${MY_TARGET}")

Expand Down Expand Up @@ -293,13 +293,13 @@ endmacro(add_osgearth_app)
#
# add_osgearth_library(
# TARGET [name of the application]
# HEADERS [list of header files to include in the project]
# IMGUI_HEADERS [list of header files with imgui code]
# PUBLIC_HEADERS [list of headers to be installed]
# STATIC
# HEADERS [list of private header files to include in the project]
# PUBLIC_HEADERS [list of public headers to be installed]
# SOURCES [list of source files]
# TEMPLATES [list of cmake .in files]
# SHADERS [list of GLSL shader files]
# LIBRARIES [list of additional libraries to link with]
# LIBRARIES [list of additional private libraries to link with]
# INCLUDE_DIRECTORIES [list of additional include folders to use]
# FOLDER [name of IDE folder in which to place target]
#
Expand All @@ -308,8 +308,8 @@ endmacro(add_osgearth_app)
macro(add_osgearth_library)

set(options "")
set(oneValueArgs TARGET FOLDER MY_DYNAMIC_OR_STATIC)
set(multiValueArgs SOURCES HEADERS PUBLIC_HEADERS IMGUI_HEADERS SHADERS TEMPLATES LIBRARIES INCLUDE_DIRECTORIES)
set(oneValueArgs TARGET FOLDER STATIC)
set(multiValueArgs SOURCES HEADERS PUBLIC_HEADERS SHADERS TEMPLATES LIBRARIES PUBLIC_LIBRARIES INCLUDE_DIRECTORIES)
cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

set(INSTALL_INCLUDE_FOLDER include/${MY_TARGET})
Expand All @@ -323,10 +323,14 @@ macro(add_osgearth_library)
source_group("Shaders" FILES ${MY_SHADERS} )
source_group("Templates" FILES ${MY_TEMPLATES} )

if(NOT MY_STATIC)
set(MY_STATIC ${OSGEARTH_DYNAMIC_OR_STATIC})
endif()

# create the library.
add_library(
${MY_TARGET}
${OSGEARTH_DYNAMIC_OR_STATIC}
${MY_STATIC}
${ALL_HEADERS}
${MY_SOURCES}
${MY_SHADERS}
Expand All @@ -340,6 +344,9 @@ macro(add_osgearth_library)
else()
target_link_libraries(${MY_TARGET} PRIVATE ${OPENSCENEGRAPH_LIBRARIES} ${MY_LIBRARIES})
endif()
if(MY_PUBLIC_LIBRARIES)
target_link_libraries(${MY_TARGET} PUBLIC ${MY_PUBLIC_LIBRARIES})
endif()

# profiler:
if(Tracy_FOUND)
Expand Down Expand Up @@ -401,15 +408,6 @@ macro(add_osgearth_library)
if (MY_FOLDER)
set_property(TARGET ${MY_TARGET} PROPERTY FOLDER "${MY_FOLDER}")
endif()


# custom install for ImGui headers.
if(OSGEARTH_HAVE_IMGUI)
source_group("Headers\\ImGui" FILES ${MY_IMGUI_HEADERS})
install(
FILES ${MY_IMGUI_HEADERS}
DESTINATION include/${MY_TARGET}/ImGui)
endif()

endmacro()

Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ if(OSGEARTH_BUILD_LEGACY_SPLAT_NODEKIT)
add_subdirectory(osgEarthSplat)
endif()

if(OSGEARTH_BUILD_IMGUI_NODEKIT)
add_subdirectory(osgEarthImGui)
endif()

# plugins:
add_subdirectory(osgEarthDrivers)

Expand Down
2 changes: 1 addition & 1 deletion src/applications/osgearth_biome/osgearth_biome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include <osgEarth/ImGui/ImGuiApp>
#include <osgEarthImGui/ImGuiApp>

#include <osgEarth/Notify>
#include <osgEarth/EarthManipulator>
Expand Down
2 changes: 1 addition & 1 deletion src/applications/osgearth_collecttriangles/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_osgearth_app(
TARGET osgearth_collecttriangles
SOURCES osgearth_collecttriangles.cpp
USE_IMGUI
LIBRARIES osgEarthImGui
FOLDER Examples )

11 changes: 9 additions & 2 deletions src/applications/osgearth_imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
add_osgearth_app(
TARGET osgearth_imgui
SOURCES osgearth_imgui.cpp
USE_IMGUI
LIBRARIES osgEarthImGui
FOLDER Tools )


if(OSGEARTH_BUILD_PROCEDURAL_NODEKIT)
target_link_libraries(osgearth_imgui PRIVATE osgEarthProcedural)
endif()

if(OSGEARTH_BUILD_CESIUM_NODEKIT)
target_link_libraries(osgearth_imgui PRIVATE osgEarthCesium)
endif()
2 changes: 1 addition & 1 deletion src/applications/osgearth_imgui/osgearth_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include <osgEarth/ImGui/ImGuiApp>
#include <osgEarthImGui/ImGuiApp>
#include <osgEarth/EarthManipulator>
#include <osgEarth/ExampleResources>
#include <osgEarth/Metrics>
Expand Down
12 changes: 10 additions & 2 deletions src/applications/osgearth_pick/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
add_osgearth_app(
TARGET osgearth_pick
SOURCES osgearth_pick.cpp
USE_IMGUI
LIBRARIES osgEarthImGui
FOLDER Examples )


if(OSGEARTH_BUILD_PROCEDURAL_NODEKIT)
target_link_libraries(osgearth_pick PRIVATE osgEarthProcedural)
endif()

if(OSGEARTH_BUILD_CESIUM_NODEKIT)
target_link_libraries(osgearth_pick PRIVATE osgEarthCesium)
endif()

2 changes: 1 addition & 1 deletion src/applications/osgearth_pick/osgearth_pick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include <osgEarth/ImGui/ImGuiApp>
#include <osgEarthImGui/ImGuiApp>

#include <osgEarth/Registry>
#include <osgEarth/ObjectIndex>
Expand Down
2 changes: 1 addition & 1 deletion src/osgEarth/BuildConfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#cmakedefine OSGEARTH_HAVE_BLOSC
#cmakedefine OSGEARTH_HAVE_GEOS
#cmakedefine OSGEARTH_HAVE_GEOCODER
#cmakedefine OSGEARTH_HAVE_IMGUI
#cmakedefine OSGEARTH_HAVE_MESH_OPTIMIZER
#cmakedefine OSGEARTH_HAVE_MBTILES
#cmakedefine OSGEARTH_HAVE_MVT
Expand All @@ -18,6 +17,7 @@
#cmakedefine OSGEARTH_HAVE_PROCEDURAL_NODEKIT
#cmakedefine OSGEARTH_HAVE_TRITON_NODEKIT
#cmakedefine OSGEARTH_HAVE_SILVERLINING_NODEKIT
#cmakedefine OSGEARTH_HAVE_IMGUI_NODEKIT

#cmakedefine OSGEARTH_HAVE_LEGACY_SPLAT_NODEKIT
#cmakedefine OSGEARTH_HAVE_LEGACY_CONTROLS_API
25 changes: 0 additions & 25 deletions src/osgEarth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -459,30 +459,6 @@ SET(TARGET_H
${OSGEARTH_VERSION_HEADER}
)

if(OSGEARTH_HAVE_IMGUI)
set(TARGET_H_IMGUI
ImGui/ImGui
ImGui/ImGuiPanel
ImGui/ImGuiApp
ImGui/AnnotationsGUI
ImGui/ContentBrowserGUI
ImGui/LayersGUI
ImGui/NetworkMonitorGUI
ImGui/NotifyGUI
ImGui/PickerGUI
ImGui/SceneGraphGUI
ImGui/SearchGUI
ImGui/TextureInspectorGUI
ImGui/ViewpointsGUI
ImGui/SystemGUI
ImGui/EnvironmentGUI
ImGui/ShaderGUI
ImGui/TerrainGUI
ImGui/CameraGUI
ImGui/RenderingGUI
)
endif()

if(OSGEARTH_BUILD_LEGACY_CONTROLS_API)
list(APPEND TARGET_H
ActivityMonitorTool
Expand Down Expand Up @@ -856,7 +832,6 @@ set(OSGEARTH_BUILDCONFIG_HEADER "${OSGEARTH_BUILDTIME_INCLUDE_DIR}/osgEarth/Buil
add_osgearth_library(
TARGET ${LIB_NAME}
PUBLIC_HEADERS ${TARGET_H} ${OSGEARTH_VERSION_HEADER} ${OSGEARTH_BUILDCONFIG_HEADER}
IMGUI_HEADERS ${TARGET_H_IMGUI}
SOURCES ${TARGET_SRC}
SHADERS ${TARGET_GLSL}
TEMPLATES ${TARGET_IN} )
Expand Down
Loading

0 comments on commit 2267aaf

Please sign in to comment.