Skip to content

Commit

Permalink
Moved stb_image.h from STBImpl.cpp to Image.cpp and made it local
Browse files Browse the repository at this point in the history
This is needed to avoid duplicate symbol errors as cesium-native
also uses stb_image
  • Loading branch information
TheMostDiligent committed May 9, 2024
1 parent ec78ae9 commit 9f06174
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
8 changes: 0 additions & 8 deletions TextureLoader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ set(SOURCE
add_library(Diligent-TextureLoader STATIC ${SOURCE} ${INCLUDE} ${INTERFACE})
set_common_target_properties(Diligent-TextureLoader)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_source_files_properties(
src/STBImpl.cpp
PROPERTIES
COMPILE_FLAGS "-Wno-unused-function"
)
endif()

set_property(SOURCE src/PNGCodec.c src/Image.cpp
APPEND PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/libpng" # png_static target does not define any public include directories
Expand Down
14 changes: 11 additions & 3 deletions TextureLoader/src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@
#include "StringTools.hpp"
#include "TextureUtilities.h"

extern "C" float* stbi_loadf_from_memory(const unsigned char* buffer, int len, int* x, int* y, int* channels_in_file, int desired_channels);

extern "C" void stbi_image_free(void* retval_from_stbi_load);
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-function"
#endif
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_STATIC
#define STBI_ONLY_HDR
#include "../../ThirdParty/stb/stb_image.h"
#ifdef __clang__
# pragma clang diagnostic pop
#endif

namespace Diligent
{
Expand Down
5 changes: 0 additions & 5 deletions TextureLoader/src/STBImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,3 @@
#include <cstring>
#define STB_DXT_IMPLEMENTATION
#include "../../ThirdParty/stb/stb_dxt.h"


#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_HDR
#include "../../ThirdParty/stb/stb_image.h"

0 comments on commit 9f06174

Please sign in to comment.