Skip to content

Add version guards and replace deprecated OGRE API usages (prepare ogre-1.12)#1283

Merged
j-rivero merged 12 commits intomainfrom
jrivero/ogre112-pr1-deprecated-apis-guarded
May 4, 2026
Merged

Add version guards and replace deprecated OGRE API usages (prepare ogre-1.12)#1283
j-rivero merged 12 commits intomainfrom
jrivero/ogre112-pr1-deprecated-apis-guarded

Conversation

@j-rivero
Copy link
Copy Markdown
Contributor

🎉 New feature

Part of #1281. Preparation for an ogre-1.12 migration.

Summary

Commits are self-explanatory. The PR contains many fixes for preparing the code base to be migrated to ogre 1.12.

Forward-compatible API renames, wrapped in version guards so the tree still builds on OGRE 1.9 and 1.12. No packages.apt change. New OGRE_VERSION_LT_1_10_0 / _LT_1_11_0 / _LT_1_12_0 / _LT_1_12_9 macros are added in ogre/src/CMakeLists.txt; an internal OgreCompat.hh shim provides Ogre::HBU_GPU_ONLY / HBU_CPU_TO_GPU aliases when building against pre-1.12.9 OGRE.

Renames covered: <OgreVector3.h> → <OgreVector.h>, ST_GENERIC → "DefaultSceneManager", HBU_*_WRITE_ONLY → Ogre::HBU_GPU_ONLY / HBU_CPU_TO_GPU, getBoneIterator() → range-for over getBones(), RGN_DEFAULT group on MaterialManager::getByName, internal OgreGLFBORenderTexture.h removed; defensive dynamic_cast + null-guard in OgreHeightmap::SetupShadows; SetNormalMap extracted into a shared CreateOgreTextureFromImage helper.

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the feature
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Generated-by: Claude Sonnet 4.6

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Backports: If this is a backport, please use Rebase and Merge instead.

j-rivero added 10 commits April 26, 2026 20:19
Adds two version-floor compile definitions used by the subsequent
deprecated-API renames so they can keep an OGRE 1.9 fallback path:

  OGRE_VERSION_LT_1_10_0  - <OgreVector.h>, getBones(),
                            GpuProgramParametersPtr were introduced in 1.10
  OGRE_VERSION_LT_1_12_9  - HBU_GPU_ONLY/HBU_CPU_TO_GPU and the free
                            Ogre::HBU_* enum scope were introduced in 1.12.9

The existing _LT_1_11_0 and _LT_1_12_0 guards remain unchanged.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
OGRE 1.12.4 deprecated <OgreVector3.h> in favour of the consolidated
<OgreVector.h>. The new header was introduced in 1.10, so guard the
new include behind OGRE_VERSION_LT_1_10_0 to keep 1.9 building.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Root::createSceneManager(SceneTypeMask) was deprecated in OGRE 1.10.9.
The replacement is createSceneManager("DefaultSceneManager"), which is
the string name equivalent of ST_GENERIC.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
OGRE 1.12.9 introduced HBU_GPU_ONLY / HBU_CPU_TO_GPU as a free-scope
Ogre::HardwareBufferUsage enum, deprecating
  Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY
  Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY
in the same release.

The 9 createVertexBuffer / createIndexBuffer call sites in
OgreDynamicRenderable, OgreMeshFactory, OgreScene and OgreText use the
modern names directly. To keep an OGRE 1.9 source-compat path we add a
small internal-only compat header that, on OGRE < 1.12.9, defines the
new identifiers as constexpr aliases for the old nested-scope values.
On 1.12.9+ the aliases are not redeclared; the native enum is used as
provided by upstream.

Combines the original D4 (5c833bf) and its scope fix-up (d92b9cd)
into a single guarded change so reviewers can see the full migration
together with its 1.9 fallback.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
…arget

The internal GL render-system header OgreGLFBORenderTexture.h may not be
present when OGRE is installed as a package. The GLId() function only
uses getCustomAttribute("GLID", ...) which is a standard public OGRE API
and does not require the internal header. Replace GLuint with unsigned int
to eliminate the dependency entirely.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
…ster

OGRE 1.10.3 deprecated resource lookups without an explicit group name.
Pass Ogre::RGN_DEFAULT to make the lookup unambiguous and silence the
deprecation warning from OGRE_RESOURCEMANAGER_STRICT.

The two-argument getByName overload exists since OGRE 1.0 (the second
arg has a default value), so this change is backwards-compatible with
1.9.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Skeleton::getBones() and the std::vector-based bone container were
introduced in OGRE 1.10. Older releases only expose
Skeleton::getBoneIterator(); guard the modern range-for behind
OGRE_VERSION_LT_1_10_0 and keep the iterator path available for 1.9.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
OGRE 1.10 introduced Ogre::GpuProgramParametersPtr (a std-pointer-based
typedef) and deprecated GpuProgramParametersSharedPtr. The deprecated
typedef remains available as an alias on 1.12 but emits a warning.

Switch local variables that hold the result of getFragmentProgramParameters
or getDefaultParameters to auto, which deduces to whichever name the
installed OGRE provides — silent on both 1.9 and 1.12.

Function signatures (OgreMaterial.hh::UpdateShaderParams,
OgreHeightmap.cc::updateVpParams) keep the explicit
GpuProgramParametersSharedPtr name to remain valid on 1.9, where
GpuProgramParametersPtr is undefined.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
OGRE 1.12 requires RTSS for GL3Plus/GLES2, so materials may not have a
technique with a fixed-function pass. In that case findSourceTechnique
returns nullptr and calling removeShaderBasedTechnique(nullptr, ...)
dereferences srcTech->getParent() and crashes. Guard against it.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
When OgreHeightmap relies on the stock TerrainMaterialGeneratorA (active
in OGRE >= 1.11 builds, see follow-up commits) the active terrain
profile is not the GzTerrainMatGen::SM2Profile we declare locally and
the static_cast we previously used produces a pointer that points
nowhere. Subsequent setReceiveDynamicShadowsLightTypes /
setReceiveDynamicShadowsPSSM calls then write through that bogus pointer
and corrupt the heap.

Use dynamic_cast and skip the SM2 profile setters when the cast fails;
this keeps the legacy 1.9 path working (where GzTerrainMatGen IS the
active profile) and silently does nothing on >= 1.11 paths.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
@j-rivero j-rivero requested a review from iche033 as a code owner April 28, 2026 10:53
@j-rivero
Copy link
Copy Markdown
Contributor Author

Failure could be #1280

Copy link
Copy Markdown
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

changes look safe and compatible with ogre 1.9

@github-project-automation github-project-automation Bot moved this from Inbox to In review in Core development Apr 30, 2026
@j-rivero j-rivero merged commit a17e1ae into main May 4, 2026
12 checks passed
@j-rivero j-rivero deleted the jrivero/ogre112-pr1-deprecated-apis-guarded branch May 4, 2026 14:49
@github-project-automation github-project-automation Bot moved this from In review to Done in Core development May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants