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
16 changes: 14 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ gz_configure_project(VERSION_SUFFIX)
# Set project-specific options
#============================================================================
option(USE_UNOFFICIAL_OGRE_VERSIONS "Accept unsupported Ogre versions in the build" OFF)
option(USE_OGRE2_OVERLAY "Enable OGRE2 Overlay support" ON)

#============================================================================
# Search for project-specific dependencies
Expand Down Expand Up @@ -102,21 +103,32 @@ endif()
# Find OGRE2: first try to find OGRE2 built with PlanarReflections support and
# fallback to look for OGRE2 without it. Both seems to works for gz-rendering.
# See https://github.com/gazebosim/gz-rendering/issues/597

# Build the list of OGRE2 components based on the options
set(OGRE2_COMPONENTS HlmsPbs HlmsUnlit PlanarReflections)
if(USE_OGRE2_OVERLAY)
list(APPEND OGRE2_COMPONENTS Overlay)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ABI checker picked up some compatibility issues. I think we need to set GZ_RENDERING_HAVE_OGRE2_OVERLAY to TRUE here as well.

endif()

gz_find_package(GzOGRE2 VERSION 2.3.1
COMPONENTS HlmsPbs HlmsUnlit Overlay PlanarReflections
COMPONENTS ${OGRE2_COMPONENTS}
PRIVATE_FOR ogre2
QUIET)

if ("${OGRE2-PlanarReflections}" STREQUAL "OGRE2-PlanarReflections-NOTFOUND")
message(STATUS "PlanarReflections component was not found. Try looking without it:")
gz_find_package(GzOGRE2 VERSION 2.3.1
COMPONENTS HlmsPbs HlmsUnlit Overlay
COMPONENTS ${OGRE2_COMPONENTS}
REQUIRED_BY ogre2
PRIVATE_FOR ogre2)
endif()

if (OGRE2_FOUND)
set(GZ_RENDERING_HAVE_OGRE2 TRUE)

if(NOT USE_OGRE2_OVERLAY)
message(STATUS "OGRE2 Overlay support disabled by configuration")
endif()
endif()

#--------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

### Gazebo Rendering 9.X

1. Conditional OGRE2 Overlay Support
* By default, OGRE2 overlay support is enabled, but it can be disabled using the
CMake option `USE_OGRE2_OVERLAY=OFF`. This is useful for builds using libc++
version 19 or greater than are broken, see (<https://github.com/OGRECave/ogre-next/issues/541>).
* [Pull request]()

### Gazebo Rendering 9.4.0 (2025-09-05)

1. Add bazel build for ogre2 engine
Expand Down
1 change: 1 addition & 0 deletions include/gz/rendering/config.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#cmakedefine GZ_RENDERING_HAVE_OGRE 1
#cmakedefine GZ_RENDERING_HAVE_OGRE2 1
#cmakedefine GZ_RENDERING_HAVE_OGRE2_OVERLAY 1
#cmakedefine GZ_RENDERING_HAVE_OPTIX 1
#cmakedefine GZ_RENDERING_HAVE_VULKAN 1

Expand Down
4 changes: 4 additions & 0 deletions ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_
#define GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_

#include "gz/rendering/config.hh"

// This disables warning messages for OGRE
#ifndef _MSC_VER
#pragma GCC system_header
Expand Down Expand Up @@ -96,12 +98,14 @@
#include <Compositor/Pass/PassScene/OgreCompositorPassScene.h>
#include <Compositor/Pass/PassScene/OgreCompositorPassSceneDef.h>

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
#include <Overlay/OgreOverlayPrerequisites.h>
#include <Overlay/OgreOverlayManager.h>
#include <Overlay/OgreOverlayElement.h>
#include <Overlay/OgreOverlayContainer.h>
#include <Overlay/OgreFontManager.h>
#include <Overlay/OgreOverlaySystem.h>
#endif

// TODO(anyone): enable when ogre 2.1 fully supports paging
// and terrain components
Expand Down
9 changes: 9 additions & 0 deletions ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <gz/common/SingletonT.hh>

#include "gz/rendering/config.hh"
#include "gz/rendering/GraphicsAPI.hh"
#include "gz/rendering/RenderEnginePlugin.hh"
#include "gz/rendering/base/BaseRenderEngine.hh"
Expand All @@ -37,10 +38,12 @@ namespace Ogre
class LogManager;
class Root;
class Window;
#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
namespace v1
{
class OverlaySystem;
}
#endif

class HlmsPbsTerraShadows;
class CompositorWorkspaceListener;
Expand Down Expand Up @@ -161,8 +164,10 @@ namespace gz
/// \brief Create ogre root
private: void CreateRoot();

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
/// \brief Create ogre overlay component
private: void CreateOverlay();
#endif

/// \brief Create ogre plugins.
private: void LoadPlugins();
Expand All @@ -187,10 +192,12 @@ namespace gz
/// \return Ogre HLMS customizations
public: Ogre2GzHlmsSphericalClipMinDistance &SphericalClipMinDistance();

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
/// \internal
/// \brief Get a pointer to the Ogre overlay system.
/// \return Pointer to the ogre overlay system.
public: Ogre::v1::OverlaySystem *OverlaySystem() const;
#endif

/// \internal
/// \brief Sets the current rendering mode. See GzOgreRenderingMode
Expand Down Expand Up @@ -221,8 +228,10 @@ namespace gz
/// \return a pointer to the render engine
public: static Ogre2RenderEngine *Instance();

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
/// \brief Pointer to the ogre's overlay system
private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr;
#endif

/// \brief List of scenes managed by the render engine
private: Ogre2SceneStorePtr scenes;
Expand Down
6 changes: 6 additions & 0 deletions ogre2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ set_property(
target_compile_definitions(${ogre2_target}
PRIVATE OGRE_IGNORE_UNKNOWN_DEBUG)

# Add overlay support definition if enabled
if(USE_OGRE2_OVERLAY)
target_compile_definitions(${ogre2_target}
PRIVATE GZ_RENDERING_HAVE_OGRE2_OVERLAY=1)
endif()

# Add OGRE2_LIBRARY_DIRS to INSTALL_RPATH
# Append to a copy of CMAKE_INSTALL_RPATH since that is the default
set(ogre2_target_install_rpath ${CMAKE_INSTALL_RPATH})
Expand Down
9 changes: 9 additions & 0 deletions ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <gz/plugin/Register.hh>

#include "gz/rendering/config.hh"
#include "gz/rendering/GraphicsAPI.hh"
#include "gz/rendering/InstallationDirectories.hh"
#include "gz/rendering/RenderEngineManager.hh"
Expand Down Expand Up @@ -190,8 +191,10 @@ void Ogre2RenderEngine::Destroy()
this->scenes->RemoveAll();
}

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
delete this->ogreOverlaySystem;
this->ogreOverlaySystem = nullptr;
#endif

this->dataPtr->hlmsPbsTerraShadows.reset();

Expand Down Expand Up @@ -501,7 +504,9 @@ void Ogre2RenderEngine::LoadAttempt()
}

this->CreateRoot();
#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
this->CreateOverlay();
#endif
this->LoadPlugins();
this->CreateRenderSystem();
this->ogreRoot->initialise(false);
Expand Down Expand Up @@ -636,11 +641,13 @@ void Ogre2RenderEngine::CreateRoot()
}
}

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
//////////////////////////////////////////////////
void Ogre2RenderEngine::CreateOverlay()
{
this->ogreOverlaySystem = new Ogre::v1::OverlaySystem();
}
#endif

//////////////////////////////////////////////////
void Ogre2RenderEngine::LoadPlugins()
Expand Down Expand Up @@ -1416,11 +1423,13 @@ SphericalClipMinDistance()
return this->dataPtr->sphericalClipMinDistance;
}

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
/////////////////////////////////////////////////
Ogre::v1::OverlaySystem *Ogre2RenderEngine::OverlaySystem() const
{
return this->ogreOverlaySystem;
}
#endif

/////////////////////////////////////////////////
void Ogre2RenderEngine::SetGzOgreRenderingMode(
Expand Down
7 changes: 7 additions & 0 deletions ogre2/src/Ogre2Scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <gz/common/Console.hh>

#include "gz/rendering/config.hh"
#include "gz/rendering/base/SceneExt.hh"
#include "gz/rendering/GraphicsAPI.hh"
#include "gz/rendering/RenderTypes.hh"
Expand Down Expand Up @@ -83,8 +84,10 @@
#include <OgrePlatformInformation.h>
#include <OgreRoot.h>
#include <OgreSceneManager.h>
#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
#include <Overlay/OgreOverlayManager.h>
#include <Overlay/OgreOverlaySystem.h>
#endif
#if OGRE_VERSION_MAJOR == 2 && OGRE_VERSION_MINOR == 1
#include <OgreHlms.h>
#include <OgreHlmsManager.h>
Expand Down Expand Up @@ -501,11 +504,13 @@ void Ogre2Scene::Destroy()

BaseScene::Destroy();

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
if (this->ogreSceneManager)
{
this->ogreSceneManager->removeRenderQueueListener(
Ogre2RenderEngine::Instance()->OverlaySystem());
}
#endif

if (this->dataPtr->activeGi)
{
Expand Down Expand Up @@ -1477,12 +1482,14 @@ void Ogre2Scene::CreateContext()
this->ogreSceneManager = root->createSceneManager(Ogre::ST_GENERIC,
numThreads);

#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
this->ogreSceneManager->addRenderQueueListener(
Ogre2RenderEngine::Instance()->OverlaySystem());

this->ogreSceneManager->getRenderQueue()->setSortRenderQueue(
Ogre::v1::OverlayManager::getSingleton().mDefaultRenderQueueId,
Ogre::RenderQueue::StableSort);
#endif

// Set sane defaults for proper shadow mapping
this->ogreSceneManager->setShadowDirectionalLightExtrusionDistance(500.0f);
Expand Down
Loading