mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
Fixed up SFML.
This commit is contained in:
parent
878a6e6435
commit
dc4ab94644
@ -34,7 +34,7 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace Spine;
|
||||
using namespace spine;
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -127,7 +127,7 @@ void spineboy (SkeletonData* skeletonData, Atlas* atlas) {
|
||||
|
||||
Slot* headSlot = skeleton->findSlot("head");
|
||||
|
||||
drawable->state->setOnAnimationEventFunc(callback);
|
||||
drawable->state->setListener(callback);
|
||||
drawable->state->addAnimation(0, "walk", true, 0);
|
||||
drawable->state->addAnimation(0, "jump", false, 3);
|
||||
drawable->state->addAnimation(0, "run", true, 0);
|
||||
@ -452,7 +452,7 @@ void test (SkeletonData* skeletonData, Atlas* atlas) {
|
||||
}
|
||||
|
||||
int main () {
|
||||
DebugExtension dbgExtension;
|
||||
DebugExtension dbgExtension(SpineExtension::getInstance());
|
||||
SpineExtension::setInstance(&dbgExtension);
|
||||
|
||||
testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
|
||||
|
||||
@ -48,7 +48,7 @@ sf::BlendMode additivePma = sf::BlendMode(sf::BlendMode::One, sf::BlendMode::One
|
||||
sf::BlendMode multiplyPma = sf::BlendMode(sf::BlendMode::DstColor, sf::BlendMode::OneMinusSrcAlpha);
|
||||
sf::BlendMode screenPma = sf::BlendMode(sf::BlendMode::One, sf::BlendMode::OneMinusSrcColor);
|
||||
|
||||
namespace Spine {
|
||||
namespace spine {
|
||||
|
||||
SkeletonDrawable::SkeletonDrawable(SkeletonData *skeletonData, AnimationStateData *stateData) :
|
||||
timeScale(1),
|
||||
@ -115,13 +115,13 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
||||
uvs = ®ionAttachment->getUVs();
|
||||
indices = &quadIndices;
|
||||
indicesCount = 6;
|
||||
texture = (Texture *) ((AtlasRegion *) regionAttachment->getRendererObject())->page->rendererObject;
|
||||
texture = (Texture *) ((AtlasRegion *) regionAttachment->getRendererObject())->page->getRendererObject();
|
||||
attachmentColor = ®ionAttachment->getColor();
|
||||
|
||||
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
||||
MeshAttachment *mesh = (MeshAttachment *) attachment;
|
||||
worldVertices.setSize(mesh->getWorldVerticesLength(), 0);
|
||||
texture = (Texture *) ((AtlasRegion *) mesh->getRendererObject())->page->rendererObject;
|
||||
texture = (Texture *) ((AtlasRegion *) mesh->getRendererObject())->page->getRendererObject();
|
||||
mesh->computeWorldVertices(slot, 0, mesh->getWorldVerticesLength(), worldVertices, 0, 2);
|
||||
verticesCount = mesh->getWorldVerticesLength() >> 1;
|
||||
uvs = &mesh->getUVs();
|
||||
@ -196,7 +196,7 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
||||
}
|
||||
|
||||
if (clipper.isClipping()) {
|
||||
clipper.clipTriangles(worldVertices, verticesCount << 1, *indices, indicesCount, *uvs);
|
||||
clipper.clipTriangles(worldVertices, *indices, *uvs, 2);
|
||||
vertices = &clipper.getClippedVertices();
|
||||
verticesCount = clipper.getClippedVertices().size() >> 1;
|
||||
uvs = &clipper.getClippedUVs();
|
||||
@ -257,6 +257,10 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
||||
if (vertexEffect != 0) vertexEffect->end();
|
||||
}
|
||||
|
||||
void deleteTexture(void* texture) {
|
||||
delete (Texture *) texture;
|
||||
}
|
||||
|
||||
void SFMLTextureLoader::load(AtlasPage &page, const String &path) {
|
||||
Texture *texture = new Texture();
|
||||
if (!texture->loadFromFile(path.buffer())) return;
|
||||
@ -264,18 +268,17 @@ void SFMLTextureLoader::load(AtlasPage &page, const String &path) {
|
||||
if (page.magFilter == TextureFilter_Linear) texture->setSmooth(true);
|
||||
if (page.uWrap == TextureWrap_Repeat && page.vWrap == TextureWrap_Repeat) texture->setRepeated(true);
|
||||
|
||||
page.rendererObject = texture;
|
||||
page.setRendererObject(texture, deleteTexture);
|
||||
Vector2u size = texture->getSize();
|
||||
page.width = size.x;
|
||||
page.height = size.y;
|
||||
}
|
||||
|
||||
void SFMLTextureLoader::unload(void *texture) {
|
||||
delete (Texture *) texture;
|
||||
deleteTexture(texture);
|
||||
}
|
||||
|
||||
String SFMLTextureLoader::toString() const {
|
||||
return String("SFMLTextureLoader");
|
||||
SpineExtension *getDefaultExtension() {
|
||||
return new DefaultSpineExtension();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
#include <SFML/Graphics/RenderStates.hpp>
|
||||
|
||||
|
||||
namespace Spine {
|
||||
namespace spine {
|
||||
|
||||
class SkeletonDrawable : public sf::Drawable {
|
||||
public:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user