diff --git a/CHANGELOG.md b/CHANGELOG.md index eaa031792..02c37e5b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,6 @@ * Added `spVertexEffect` and corresponding implementations `spJitterVertexEffect` and `spSwirlVertexEffect`. Create/dispose through the corresponding `spXXXVertexEffect_create()/dispose()` functions. Set on framework/engine specific renderer. See changes for spine-c based frameworks/engines below. * Functions in `extension.h` are not prefixed with `_sp` instead of just `_` to avoid interference with other libraries. * Introduced `SP_API` macro. Every spine-c function is prefixed with this macro. By default, it is an empty string. Can be used to markup spine-c functions with e.g. ``__declspec` when compiling to a dll or linking to that dll. - * Added `void* userData` to `spAnimationState` to be consumed in callbacks. ### Cocos2d-X * Fixed renderer to work with 3.6 changes @@ -65,6 +64,7 @@ * SkeletonRenderer now combines the displayed color of the Node (cascaded from all parents) with the skeleton color for tinting. * Added support for vertex effects. See `RaptorExample.cpp`. * Added ETC1 alpha support, thanks @halx99! Does not work when two color tint is enabled. + * Added `spAtlasPage_setCustomTextureLoader()` which let's you do texture loading manually. Thanks @jareguo. ### Cocos2d-Objc * Fixed renderer to work with 3.6 changes @@ -85,7 +85,6 @@ * Added support for two color tinting. All base materials, e.g. SpineUnlitNormalMaterial, now do proper two color tinting. No material parameters have changed. * Updated to Unreal Engine 4.16.1. Note that 4.16 has a regression which will make it impossible to compile plain .c files! * spine-c is now exposed from the plugin shared library on Windows via __declspec. - * `SkeletonRenderComponent` now generates collision meshes by default. ## C# * **Breaking changes** diff --git a/spine-cocos2dx/src/spine/spine-cocos2dx.cpp b/spine-cocos2dx/src/spine/spine-cocos2dx.cpp index 4a7378fb1..150700261 100644 --- a/spine-cocos2dx/src/spine/spine-cocos2dx.cpp +++ b/spine-cocos2dx/src/spine/spine-cocos2dx.cpp @@ -31,6 +31,13 @@ #include #include +namespace spine { + static CustomTextureLoader _customTextureLoader = nullptr; + void spAtlasPage_setCustomTextureLoader (CustomTextureLoader texLoader) { + _customTextureLoader = texLoader; + } +} + USING_NS_CC; GLuint wrap (spAtlasWrap wrap) { @@ -60,7 +67,13 @@ GLuint filter (spAtlasFilter filter) { } void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { - Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path); + Texture2D* texture = nullptr; + if (spine::_customTextureLoader) { + texture = spine::_customTextureLoader(path); + } + if (!texture) { + texture = Director::getInstance()->getTextureCache()->addImage(path); + } CCASSERT(texture != nullptr, "Invalid image"); texture->retain(); diff --git a/spine-cocos2dx/src/spine/spine-cocos2dx.h b/spine-cocos2dx/src/spine/spine-cocos2dx.h index 81e2d7f12..497d12796 100644 --- a/spine-cocos2dx/src/spine/spine-cocos2dx.h +++ b/spine-cocos2dx/src/spine/spine-cocos2dx.h @@ -38,4 +38,10 @@ #include #include +namespace spine { + typedef cocos2d::Texture2D* (*CustomTextureLoader)(const char* path); + // set custom texture loader for _spAtlasPage_createTexture + void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader); +} + #endif /* SPINE_COCOS2DX_H_ */