Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions cmake/third_party_deps/dear_imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,65 @@
# limitations under the License.

add_library(dear_imgui STATIC)
set(MUJOCO_DEAR_IMGUI_SOURCE_DIR "${dear_imgui_SOURCE_DIR}" CACHE INTERNAL "")
target_include_directories(dear_imgui
PUBLIC
${dear_imgui_SOURCE_DIR}
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}
)
target_sources(dear_imgui
PUBLIC
${dear_imgui_SOURCE_DIR}/imgui.h
${dear_imgui_SOURCE_DIR}/imgui.cpp
${dear_imgui_SOURCE_DIR}/imgui_internal.h
${dear_imgui_SOURCE_DIR}/imgui_draw.cpp
${dear_imgui_SOURCE_DIR}/imgui_tables.cpp
${dear_imgui_SOURCE_DIR}/imgui_widgets.cpp
${dear_imgui_SOURCE_DIR}/imgui_demo.cpp
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui.h
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui.cpp
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_internal.h
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_draw.cpp
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_tables.cpp
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_widgets.cpp
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/imgui_demo.cpp
)

# SDL2 backend
# TODO: I don't know how to correctly check for dependencies in cmake. This
# assumes that SDL2 is pulled in _before_ dear_imgui, but that seems fragile.
# For now, we'll just assume SDL2 is available as dear_imgui is only being used
# in contexts which depend on SDL2.
#if(TARGET SDL2)
function(mujoco_add_dear_imgui_sdl2_backend)
if(TARGET dear_imgui_SDL2 OR NOT TARGET SDL2::SDL2-static)
return()
endif()

add_library(dear_imgui_SDL2 STATIC)
target_include_directories(dear_imgui_SDL2
PUBLIC
${dear_imgui_SOURCE_DIR}
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}
)
target_sources(dear_imgui_SDL2
PUBLIC
${dear_imgui_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp
)
target_link_libraries(dear_imgui_SDL2
SDL2::SDL2-static
)
#endif()
endfunction()

# SDL2 backend. Filament uses base dear_imgui without SDL2; platform calls this
# helper again after SDL2 is pulled in.
mujoco_add_dear_imgui_sdl2_backend()

# OpenGL3 backend
add_library(dear_imgui_OpenGL3 STATIC)
target_include_directories(dear_imgui_OpenGL3
PUBLIC
${dear_imgui_SOURCE_DIR}
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}
)
target_sources(dear_imgui_OpenGL3
PUBLIC
${dear_imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.h
${dear_imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.h
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
)

# stdlib
add_library(dear_imgui_stdlib STATIC)
target_include_directories(dear_imgui_stdlib
PUBLIC
${dear_imgui_SOURCE_DIR}
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}
)
target_sources(dear_imgui_stdlib
PUBLIC
${dear_imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.h
${dear_imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/misc/cpp/imgui_stdlib.h
${MUJOCO_DEAR_IMGUI_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
)
20 changes: 20 additions & 0 deletions cmake/third_party_deps/filament.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,32 @@ set(FILAMENT_PATCH_COMMAND
git apply --reject --whitespace=fix ${mujoco_SOURCE_DIR}/cmake/filament-allow-clang-windows.patch
)

# MuJoCo fetches Abseil before Filament is configured. Filament's
# FILAMENT_USE_EXTERNAL_ABSL path calls find_package(absl), which can otherwise
# discover an unrelated package-manager Abseil config and collide with the
# targets already created by MuJoCo's fetched Abseil.
if(DEFINED CMAKE_DISABLE_FIND_PACKAGE_absl)
set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED TRUE)
set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD "${CMAKE_DISABLE_FIND_PACKAGE_absl}")
else()
set(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED FALSE)
endif()
set(CMAKE_DISABLE_FIND_PACKAGE_absl TRUE)

fetchpackage(
PACKAGE_NAME filament
GIT_REPO https://github.com/google/filament.git
GIT_TAG ${MUJOCO_DEP_VERSION_filament}
PATCH_COMMAND ${FILAMENT_PATCH_COMMAND}
)

if(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED)
set(CMAKE_DISABLE_FIND_PACKAGE_absl "${MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD}")
else()
unset(CMAKE_DISABLE_FIND_PACKAGE_absl)
endif()
unset(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_WAS_DEFINED)
unset(MUJOCO_CMAKE_DISABLE_FIND_PACKAGE_ABSL_OLD)

set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_OLD}")
3 changes: 2 additions & 1 deletion src/experimental/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ target_include_directories(${MUJOCO_PLATFORM_TARGET_NAME}
${PROJECT_SOURCE_DIR}/src
)

include(third_party_deps/sdl2)
include(third_party_deps/dear_imgui)
mujoco_add_dear_imgui_sdl2_backend()
include(third_party_deps/implot)
include(third_party_deps/sdl2)
include(third_party_deps/libwebp)

target_link_libraries(${MUJOCO_PLATFORM_TARGET_NAME}
Expand Down
41 changes: 41 additions & 0 deletions src/experimental/studio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,47 @@ bash build.sh
> [!NOTE]
> For now [`build.sh`](build.sh) script works on windows in a git bash shell.

To keep Studio build artifacts separate from other MuJoCo builds, you can also
configure an isolated build directory manually:

```
cmake -B build-studio \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_STATIC_LIBCXX=OFF \
-DBUILD_SHARED_LIB=OFF \
-DMUJOCO_USE_FILAMENT=ON \
-DMUJOCO_BUILD_EXAMPLES=OFF \
-DMUJOCO_BUILD_SIMULATE=OFF \
-DMUJOCO_BUILD_TESTS=OFF \
-DMUJOCO_TEST_PYTHON_UTIL=OFF \
-DMUJOCO_WITH_USD=OFF \
-DMUJOCO_BUILD_STUDIO=ON \
-DFILAMENT_SKIP_SAMPLES=ON \
-DCMAKE_CXX_FLAGS=-Wno-error=deprecated-declarations \
-DFILAMENT_SHORTEN_MSVC_COMPILATION=OFF
cmake --build build-studio --config Release --target mujoco_studio --parallel
```

Run `mujoco_studio` from the build output directory so it can find the copied
font and Filament assets:

```
cd build-studio/bin
./mujoco_studio --gfx=opengl
```

On macOS, Studio defaults to Filament OpenGL. The OpenGL implementation may be
provided by Apple's Metal-backed OpenGL layer, so runtime logs can mention both
OpenGL and Metal/Apple GPU details.

### Troubleshooting

If configure fails while resolving Filament dependencies, check whether CMake is
finding package-manager CMake configs from environments such as Anaconda. In
particular, an unrelated `abslConfig.cmake` can conflict with MuJoCo's fetched
Abseil targets. Remove that prefix from `CMAKE_PREFIX_PATH`, or configure with
`CMAKE_IGNORE_PREFIX_PATH` pointing at the conflicting environment prefix.

## Development

The [`build.sh`](build.sh) script is intended to get you up and running quickly.
Expand Down
Loading