From ff60e4c2b5c6b7da9e6b6d69b5ff787104797084 Mon Sep 17 00:00:00 2001 From: Brian L <130494071+csciguy8@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:10:41 -0600 Subject: [PATCH 1/2] Put STB in the Cesium namespace --- CesiumGltfContent/src/ImageManipulation.cpp | 12 ++++++++++-- CesiumGltfReader/src/GltfReader.cpp | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CesiumGltfContent/src/ImageManipulation.cpp b/CesiumGltfContent/src/ImageManipulation.cpp index c9c6cae6f..4ff08c488 100644 --- a/CesiumGltfContent/src/ImageManipulation.cpp +++ b/CesiumGltfContent/src/ImageManipulation.cpp @@ -1,12 +1,20 @@ #include #include -#include - #include #include + +namespace Cesium { +// Use STB in our own namespace to avoid conflicts from other native +// implementations, override STBIRDEF to allow this +#define STBIRDEF + +#include #define STB_IMAGE_WRITE_IMPLEMENTATION #include +}; // namespace Cesium + +using namespace Cesium; namespace CesiumGltfContent { diff --git a/CesiumGltfReader/src/GltfReader.cpp b/CesiumGltfReader/src/GltfReader.cpp index eccb919e7..f269309dc 100644 --- a/CesiumGltfReader/src/GltfReader.cpp +++ b/CesiumGltfReader/src/GltfReader.cpp @@ -28,11 +28,17 @@ #include #include -#define STB_IMAGE_IMPLEMENTATION -#define STB_IMAGE_RESIZE_IMPLEMENTATION +namespace Cesium { +// Use STB in our own namespace to avoid conflicts from other native +// implementations, override STBIRDEF to allow this +#define STBIRDEF #define STBI_FAILURE_USERMSG +#define STB_IMAGE_IMPLEMENTATION #include +#define STB_IMAGE_RESIZE_IMPLEMENTATION #include +}; // namespace Cesium + #include using namespace CesiumAsync; @@ -40,6 +46,7 @@ using namespace CesiumGltf; using namespace CesiumGltfReader; using namespace CesiumJsonReader; using namespace CesiumUtility; +using namespace Cesium; namespace { #pragma pack(push, 1) From 5817d88224ad1b64a9314f77b826f806f435090b Mon Sep 17 00:00:00 2001 From: Brian L <130494071+csciguy8@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:21:24 -0600 Subject: [PATCH 2/2] Only put stb resize into own our namespace (others can stay put) --- CesiumGltfContent/src/ImageManipulation.cpp | 10 +++++----- CesiumGltfReader/src/GltfReader.cpp | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CesiumGltfContent/src/ImageManipulation.cpp b/CesiumGltfContent/src/ImageManipulation.cpp index 4ff08c488..5a9918e1d 100644 --- a/CesiumGltfContent/src/ImageManipulation.cpp +++ b/CesiumGltfContent/src/ImageManipulation.cpp @@ -5,17 +5,17 @@ #include namespace Cesium { -// Use STB in our own namespace to avoid conflicts from other native -// implementations, override STBIRDEF to allow this +// Use STB resize in our own namespace to avoid conflicts from other libs #define STBIRDEF - #include -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include +#undef STBIRDEF }; // namespace Cesium using namespace Cesium; +#define STB_IMAGE_WRITE_IMPLEMENTATION +#include + namespace CesiumGltfContent { void ImageManipulation::unsafeBlitImage( diff --git a/CesiumGltfReader/src/GltfReader.cpp b/CesiumGltfReader/src/GltfReader.cpp index f269309dc..862408454 100644 --- a/CesiumGltfReader/src/GltfReader.cpp +++ b/CesiumGltfReader/src/GltfReader.cpp @@ -28,17 +28,18 @@ #include #include +#define STBI_FAILURE_USERMSG + namespace Cesium { -// Use STB in our own namespace to avoid conflicts from other native -// implementations, override STBIRDEF to allow this +// Use STB resize in our own namespace to avoid conflicts from other libs #define STBIRDEF -#define STBI_FAILURE_USERMSG -#define STB_IMAGE_IMPLEMENTATION -#include #define STB_IMAGE_RESIZE_IMPLEMENTATION #include +#undef STBIRDEF }; // namespace Cesium +#define STB_IMAGE_IMPLEMENTATION +#include #include using namespace CesiumAsync;