Skip to content

Commit 2a116b0

Browse files
committed
Fix web build data loading
1 parent d407fee commit 2a116b0

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/skeleton_drawable.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ void TextureLoader::unload(void* texture) {
3232
delete (jngl::Sprite*)texture;
3333
}
3434

35+
namespace {
36+
struct SpineExtension : spine::DefaultSpineExtension {
37+
SpineExtension() {
38+
spine::SpineExtension::setInstance(this);
39+
}
40+
char* _readFile(const spine::String& path, int* length) override {
41+
const auto str = jngl::readAsset(path.buffer()).str();
42+
*length = static_cast<int>(str.length());
43+
char* buf = static_cast<char*>(malloc(str.length())); // NOLINT
44+
std::ranges::copy(str, buf);
45+
return buf;
46+
}
47+
} gSpineExtension;
48+
} // namespace
49+
3550
TextureLoader SkeletonDrawable::textureLoader;
3651

3752
SkeletonDrawable::SkeletonDrawable(spine::SkeletonData& skeletonData,

0 commit comments

Comments
 (0)