diff --git a/CMakeLists.txt b/CMakeLists.txt index 42ef2411f..67a8e860f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ endif() if((${SPINE_SFML}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-sfml")) if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(CMAKE_OSX_ARCHITECTURES x86_64;arm64) + set(CMAKE_OSX_ARCHITECTURES x86_64) set(ONLY_ACTIVE_ARCH NO) endif() add_subdirectory(spine-c) diff --git a/spine-cocos2dx/README.md b/spine-cocos2dx/README.md index 7c3a0b643..e169faae9 100644 --- a/spine-cocos2dx/README.md +++ b/spine-cocos2dx/README.md @@ -74,6 +74,8 @@ open build-macos/spine-cocos2dx-example.xcodeproj This will generate an Xcode project in `build-macos/spine-cocos2dx-example.xcodeproj` and open it in Xcode. To build and run the example, select the `spine-cocos2dx-example` scheme and press `CMD + R`. +> **Note**: cocos2d-x only ships pre-built external libraries like Bullet or FreeType for x86_64. If you build on a machine with Apple Silicon, adjust the `cmake` command above to `mkdir build-macos && cmake . -GXcode -Bbuild-macos -DCMAKE_OSX_ARCHITECTURES=x86_64`. + ### iOS Execute the following on the command line: diff --git a/spine-cocos2dx/spine-cocos2dx/src/spine/spine-cocos2dx.cpp b/spine-cocos2dx/spine-cocos2dx/src/spine/spine-cocos2dx.cpp index fae4aec65..f9b2d5e20 100644 --- a/spine-cocos2dx/spine-cocos2dx/src/spine/spine-cocos2dx.cpp +++ b/spine-cocos2dx/spine-cocos2dx/src/spine/spine-cocos2dx.cpp @@ -41,8 +41,7 @@ static void deleteAttachmentVertices(void *vertices) { static unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0}; static void setAttachmentVertices(RegionAttachment *attachment) { - AtlasRegion *region = (AtlasRegion *) attachment->getRendererObject(); - AttachmentVertices *attachmentVertices = new AttachmentVertices((Texture2D *) region->page->getRendererObject(), 4, quadTriangles, 6); + AttachmentVertices *attachmentVertices = new AttachmentVertices((Texture2D *) attachment->getRegion()->rendererObject, 4, quadTriangles, 6); V3F_C4B_T2F *vertices = attachmentVertices->_triangles->verts; for (int i = 0, ii = 0; i < 4; ++i, ii += 2) { vertices[i].texCoords.u = attachment->getUVs()[ii]; @@ -52,8 +51,7 @@ static void setAttachmentVertices(RegionAttachment *attachment) { } static void setAttachmentVertices(MeshAttachment *attachment) { - AtlasRegion *region = (AtlasRegion *) attachment->getRendererObject(); - AttachmentVertices *attachmentVertices = new AttachmentVertices((Texture2D *) region->page->getRendererObject(), + AttachmentVertices *attachmentVertices = new AttachmentVertices((Texture2D *)attachment->getRegion()->rendererObject, attachment->getWorldVerticesLength() >> 1, attachment->getTriangles().buffer(), attachment->getTriangles().size()); V3F_C4B_T2F *vertices = attachmentVertices->_triangles->verts; for (int i = 0, ii = 0, nn = attachment->getWorldVerticesLength(); ii < nn; ++i, ii += 2) { @@ -149,7 +147,7 @@ void Cocos2dTextureLoader::load(AtlasPage &page, const spine::String &path) { #endif texture->setTexParameters(textureParams); - page.setRendererObject(texture); + page.texture = texture; page.width = texture->getPixelsWide(); page.height = texture->getPixelsHigh(); } diff --git a/spine-cpp/spine-cpp/include/spine/MeshAttachment.h b/spine-cpp/spine-cpp/include/spine/MeshAttachment.h index 757a85385..6961a2dd3 100644 --- a/spine-cpp/spine-cpp/include/spine/MeshAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/MeshAttachment.h @@ -39,7 +39,7 @@ namespace spine { /// Attachment that displays a texture region using a mesh. - class SP_API MeshAttachment : public VertexAttachment { + class SP_API MeshAttachment : public VertexAttachment, public HasRendererObject { friend class SkeletonBinary; friend class SkeletonJson; diff --git a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h index 2202fb402..bd8cc1827 100644 --- a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h @@ -44,7 +44,7 @@ namespace spine { class Bone; /// Attachment that displays a texture region. - class SP_API RegionAttachment : public Attachment { + class SP_API RegionAttachment : public Attachment, public HasRendererObject { friend class SkeletonBinary; friend class SkeletonJson; diff --git a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp index 57562f508..0a0f913a5 100644 --- a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp @@ -34,7 +34,7 @@ using namespace spine; RTTI_IMPL(MeshAttachment, VertexAttachment) -MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), +MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), HasRendererObject(), _parentMesh(NULL), _path(), _color(1, 1, 1, 1), diff --git a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp index 54252d8c9..da15c053c 100644 --- a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp @@ -47,7 +47,7 @@ const int RegionAttachment::URY = 5; const int RegionAttachment::BRX = 6; const int RegionAttachment::BRY = 7; -RegionAttachment::RegionAttachment(const String &name) : Attachment(name), +RegionAttachment::RegionAttachment(const String &name) : Attachment(name), HasRendererObject(), _x(0), _y(0), _rotation(0), diff --git a/spine-sdl/src/spine-sdl-cpp.cpp b/spine-sdl/src/spine-sdl-cpp.cpp index 365abf221..c97931af0 100644 --- a/spine-sdl/src/spine-sdl-cpp.cpp +++ b/spine-sdl/src/spine-sdl-cpp.cpp @@ -101,7 +101,7 @@ void SkeletonDrawable::draw(SDL_Renderer *renderer) { uvs = ®ionAttachment->getUVs(); indices = &quadIndices; indicesCount = 6; - texture = (SDL_Texture *) ((AtlasRegion *) regionAttachment->getRendererObject())->page->getRendererObject(); + texture = (SDL_Texture *)regionAttachment->getRegion()->rendererObject; } else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) { MeshAttachment *mesh = (MeshAttachment *) attachment; @@ -114,7 +114,7 @@ void SkeletonDrawable::draw(SDL_Renderer *renderer) { } worldVertices.setSize(mesh->getWorldVerticesLength(), 0); - texture = (SDL_Texture *) ((AtlasRegion *) mesh->getRendererObject())->page->getRendererObject(); + texture = (SDL_Texture *)mesh->getRegion()->rendererObject; mesh->computeWorldVertices(slot, 0, mesh->getWorldVerticesLength(), worldVertices.buffer(), 0, 2); verticesCount = mesh->getWorldVerticesLength() >> 1; uvs = &mesh->getUVs(); @@ -201,7 +201,7 @@ SDL_Texture *loadTexture(SDL_Renderer *renderer, const String &path) { void SDLTextureLoader::load(AtlasPage &page, const String &path) { SDL_Texture *texture = loadTexture(renderer, path); if (!texture) return; - page.setRendererObject(texture); + page.texture = texture; SDL_QueryTexture(texture, nullptr, nullptr, &page.width, &page.height); switch (page.magFilter) { case TextureFilter_Nearest: diff --git a/spine-sfml/cpp/src/spine/spine-sfml.cpp b/spine-sfml/cpp/src/spine/spine-sfml.cpp index 98962be00..114dbba2b 100644 --- a/spine-sfml/cpp/src/spine/spine-sfml.cpp +++ b/spine-sfml/cpp/src/spine/spine-sfml.cpp @@ -103,7 +103,6 @@ namespace spine { } Vector *vertices = &worldVertices; - int verticesCount = 0; Vector *uvs = NULL; Vector *indices = NULL; int indicesCount = 0; @@ -121,11 +120,10 @@ namespace spine { worldVertices.setSize(8, 0); regionAttachment->computeWorldVertices(slot, worldVertices, 0, 2); - verticesCount = 4; uvs = ®ionAttachment->getUVs(); indices = &quadIndices; indicesCount = 6; - texture = (Texture *) ((AtlasRegion *) regionAttachment->getRendererObject())->page->getRendererObject(); + texture = (Texture *)regionAttachment->getRegion()->rendererObject; } else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) { MeshAttachment *mesh = (MeshAttachment *) attachment; @@ -138,9 +136,8 @@ namespace spine { } worldVertices.setSize(mesh->getWorldVerticesLength(), 0); - texture = (Texture *) ((AtlasRegion *) mesh->getRendererObject())->page->getRendererObject(); + texture = (Texture *)mesh->getRegion()->rendererObject; mesh->computeWorldVertices(slot, 0, mesh->getWorldVerticesLength(), worldVertices.buffer(), 0, 2); - verticesCount = mesh->getWorldVerticesLength() >> 1; uvs = &mesh->getUVs(); indices = &mesh->getTriangles(); indicesCount = mesh->getTriangles().size(); @@ -216,7 +213,6 @@ namespace spine { if (clipper.isClipping()) { clipper.clipTriangles(worldVertices, *indices, *uvs, 2); vertices = &clipper.getClippedVertices(); - verticesCount = clipper.getClippedVertices().size() >> 1; uvs = &clipper.getClippedUVs(); indices = &clipper.getClippedTriangles(); indicesCount = clipper.getClippedTriangles().size(); @@ -245,7 +241,7 @@ namespace spine { if (page.magFilter == TextureFilter_Linear) texture->setSmooth(true); if (page.uWrap == TextureWrap_Repeat && page.vWrap == TextureWrap_Repeat) texture->setRepeated(true); - page.setRendererObject(texture); + page.texture = texture; Vector2u size = texture->getSize(); page.width = size.x; page.height = size.y;