Skip to content

Commit

Permalink
Expose aiGetEmbeddedTexture to C-API (assimp#5382)
Browse files Browse the repository at this point in the history
Co-authored-by: Kim Kulling <[email protected]>
  • Loading branch information
sacereda and kimkulling authored Aug 21, 2024
1 parent bc6710a commit d83904e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
32 changes: 18 additions & 14 deletions code/Common/Assimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ void aiGetMemoryRequirements(const C_STRUCT aiScene *pIn,
ASSIMP_END_EXCEPTION_REGION(void);
}

// ------------------------------------------------------------------------------------------------
ASSIMP_API const C_STRUCT aiTexture *aiGetEmbeddedTexture(const C_STRUCT aiScene *pIn, const char *filename) {
return pIn->GetEmbeddedTexture(filename);
}

// ------------------------------------------------------------------------------------------------
ASSIMP_API aiPropertyStore *aiCreatePropertyStore(void) {
return reinterpret_cast<aiPropertyStore *>(new PropertyMap());
Expand Down Expand Up @@ -1268,7 +1273,6 @@ ASSIMP_API void aiQuaternionInterpolate(
aiQuaternion::Interpolate(*dst, *start, *end, factor);
}


// stb_image is a lightweight image loader. It is shared by:
// - M3D import
// - PBRT export
Expand All @@ -1279,21 +1283,21 @@ ASSIMP_API void aiQuaternionInterpolate(
#define ASSIMP_HAS_M3D ((!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_M3D_EXPORTER) || !ASSIMP_BUILD_NO_M3D_IMPORTER)

#ifndef STB_USE_HUNTER
# if ASSIMP_HAS_PBRT_EXPORT
# define ASSIMP_NEEDS_STB_IMAGE 1
# elif ASSIMP_HAS_M3D
# define ASSIMP_NEEDS_STB_IMAGE 1
# define STBI_ONLY_PNG
# endif
#if ASSIMP_HAS_PBRT_EXPORT
#define ASSIMP_NEEDS_STB_IMAGE 1
#elif ASSIMP_HAS_M3D
#define ASSIMP_NEEDS_STB_IMAGE 1
#define STBI_ONLY_PNG
#endif
#endif

// Ensure all symbols are linked correctly
#if ASSIMP_NEEDS_STB_IMAGE
// Share stb_image's PNG loader with other importers/exporters instead of bringing our own copy.
# define STBI_ONLY_PNG
# ifdef ASSIMP_USE_STB_IMAGE_STATIC
# define STB_IMAGE_STATIC
# endif
# define STB_IMAGE_IMPLEMENTATION
# include "Common/StbCommon.h"
// Share stb_image's PNG loader with other importers/exporters instead of bringing our own copy.
#define STBI_ONLY_PNG
#ifdef ASSIMP_USE_STB_IMAGE_STATIC
#define STB_IMAGE_STATIC
#endif
#define STB_IMAGE_IMPLEMENTATION
#include "Common/StbCommon.h"
#endif
8 changes: 8 additions & 0 deletions include/assimp/cimport.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern "C" {
#endif

struct aiScene;
struct aiTexture;
struct aiFileIO;

typedef void (*aiLogStreamCallback)(const char * /* message */, char * /* user */);
Expand Down Expand Up @@ -373,6 +374,13 @@ ASSIMP_API void aiGetMemoryRequirements(
const C_STRUCT aiScene *pIn,
C_STRUCT aiMemoryInfo *in);

// --------------------------------------------------------------------------------
/** Returns an embedded texture, or nullptr.
* @param pIn Input asset.
* @param filename Texture path extracted from aiGetMaterialString.
*/
ASSIMP_API const C_STRUCT aiTexture *aiGetEmbeddedTexture(const C_STRUCT aiScene *pIn, const char *filename);

// --------------------------------------------------------------------------------
/** Create an empty property store. Property stores are used to collect import
* settings.
Expand Down

0 comments on commit d83904e

Please sign in to comment.