mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
So close, but alas must sleep :( 5am!
This commit is contained in:
parent
596b515e66
commit
9a0085c36b
@ -30,9 +30,10 @@
|
||||
<option id="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level.1284147695" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.1570084302" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.934414518" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""C:\Users\Nate\Desktop\SFML-2.0-rc\include""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/spine-c/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/spine-sfml/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/spine-c/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/spine-c/include}""/>
|
||||
<listOptionValue builtIn="false" value=""C:\Users\Nate\Desktop\SFML-2.0-rc\include""/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.warnings.allwarn.2053349441" name="All warnings (-Wall)" superClass="gnu.cpp.compiler.option.warnings.allwarn" value="true" valueType="boolean"/>
|
||||
<option id="gnu.cpp.compiler.option.preprocessor.def.1463772359" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def"/>
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include <spine/spine.h>
|
||||
#include <spine/spine-sfml.h>
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
using namespace std;
|
||||
@ -56,7 +56,7 @@ int main () {
|
||||
while (window.pollEvent(event))
|
||||
if (event.type == sf::Event::Closed) window.close();
|
||||
window.clear();
|
||||
//window.draw(*skeleton);
|
||||
window.draw(Skeleton_getDrawable(skeleton));
|
||||
window.display();
|
||||
|
||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include <spine/spine-sfml.h>
|
||||
#include <spine/spine.h>
|
||||
#include <spine/extension.h>
|
||||
#include <spine/util.h>
|
||||
@ -17,11 +18,6 @@ using sf::VertexArray;
|
||||
|
||||
namespace spine {
|
||||
|
||||
typedef struct {
|
||||
AtlasPage super;
|
||||
Texture *texture;
|
||||
} SfmlAtlasPage;
|
||||
|
||||
void _SfmlAtlasPage_dispose (AtlasPage* page) {
|
||||
SfmlAtlasPage* self = (SfmlAtlasPage*)page;
|
||||
_AtlasPage_deinit(&self->super);
|
||||
@ -42,14 +38,13 @@ AtlasPage* AtlasPage_create (const char* name) {
|
||||
|
||||
/**/
|
||||
|
||||
typedef struct {
|
||||
Skeleton super;
|
||||
VertexArray* vertexArray;
|
||||
Texture* texture; // All region attachments must use the same texture.
|
||||
} SfmlSkeleton;
|
||||
void _SfmlSkeleton_dispose (Skeleton* skeleton) {
|
||||
SfmlSkeleton* self = (SfmlSkeleton*)skeleton;
|
||||
_Skeleton_deinit(&self->super);
|
||||
|
||||
delete self->vertexArray;
|
||||
delete self->drawable;
|
||||
|
||||
void _SfmlSkeleton_dispose (Skeleton* self) {
|
||||
_Skeleton_deinit(self);
|
||||
FREE(self)
|
||||
}
|
||||
|
||||
@ -58,18 +53,30 @@ Skeleton* Skeleton_create (SkeletonData* data) {
|
||||
_Skeleton_init(&self->super, data);
|
||||
self->super._dispose = _SfmlSkeleton_dispose;
|
||||
|
||||
self->drawable = new SkeletonDrawable(&self->super);
|
||||
self->vertexArray = new VertexArray(Quads, data->boneCount * 4);
|
||||
|
||||
return &self->super;
|
||||
}
|
||||
|
||||
/**/
|
||||
SkeletonDrawable& Skeleton_getDrawable (const Skeleton* self) {
|
||||
return *((SfmlSkeleton*)self)->drawable;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
RegionAttachment super;
|
||||
Vertex vertices[4];
|
||||
Texture *texture;
|
||||
} SfmlRegionAttachment;
|
||||
SkeletonDrawable::SkeletonDrawable (Skeleton* self) {
|
||||
skeleton = (SfmlSkeleton*)self;
|
||||
}
|
||||
|
||||
void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const {
|
||||
skeleton->vertexArray->clear();
|
||||
for (int i = 0; i < skeleton->super.slotCount; ++i)
|
||||
if (skeleton->super.slots[i]->attachment) ; //skeleton->slots[i]->attachment->draw(slots[i]);
|
||||
// BOZO - Draw the slots!
|
||||
states.texture = skeleton->texture;
|
||||
target.draw(*skeleton->vertexArray, states);
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
void _SfmlRegionAttachment_dispose (Attachment* self) {
|
||||
_RegionAttachment_deinit((RegionAttachment*)self);
|
||||
|
||||
42
spine-sfml/src/spine/spine-sfml.h
Normal file
42
spine-sfml/src/spine/spine-sfml.h
Normal file
@ -0,0 +1,42 @@
|
||||
#include <spine/spine.h>
|
||||
#include <SFML/Graphics/Vertex.hpp>
|
||||
#include <SFML/Graphics/VertexArray.hpp>
|
||||
|
||||
namespace spine {
|
||||
|
||||
typedef struct {
|
||||
AtlasPage super;
|
||||
sf::Texture* texture;
|
||||
} SfmlAtlasPage;
|
||||
|
||||
/**/
|
||||
|
||||
class SkeletonDrawable;
|
||||
|
||||
typedef struct {
|
||||
Skeleton super;
|
||||
sf::VertexArray* vertexArray;
|
||||
sf::Texture* texture; // All region attachments must use the same texture.
|
||||
SkeletonDrawable* drawable;
|
||||
} SfmlSkeleton;
|
||||
|
||||
class SkeletonDrawable: public sf::Drawable {
|
||||
public:
|
||||
SfmlSkeleton* skeleton;
|
||||
|
||||
SkeletonDrawable (Skeleton* skeleton);
|
||||
|
||||
virtual void draw (sf::RenderTarget& target, sf::RenderStates states) const;
|
||||
};
|
||||
|
||||
SkeletonDrawable& Skeleton_getDrawable (const Skeleton* skeleton);
|
||||
|
||||
/**/
|
||||
|
||||
typedef struct {
|
||||
RegionAttachment super;
|
||||
sf::Vertex vertices[4];
|
||||
sf::Texture* texture;
|
||||
} SfmlRegionAttachment;
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user