you are welcome, I will upload the runtime some time this weekend. if anyone knows of similar tools that enhance the game development I would be happy to create pascal support for it.
you are welcome, I will upload the runtime some time this weekend. if anyone knows of similar tools that enhance the game development I would be happy to create pascal support for it.
ok here it is: http://gen2gdk.com/files/SpinePascal.rar
if anyone is interested I can make the demos with pure opnegl and direct3d. at the moment there is only one demo that uses g2mp.
Here is how much code I had to write to make it work with g2mp:
as you can see it's almost nothing compared to the size of the runtime code itself (~2700 lines).Code:TG2SpineTexture = class (TSpineTexture) public Texture: TG2Texture2D; constructor Create(const TextureName: AnsiString); destructor Destroy; override; function GetWidth: Integer; override; function GetHeight: Integer; override; end; TG2SpineTextureLoader = class (TSpineTextureLoader) public function LoadTexture(const TextureName: AnsiString): TSpineTexture; override; end; TG2SpineRender = class (TSpineRender) public procedure Render(const Texture: TSpineTexture; const Vertices: PSpineVertexArray); override; end; ... //TG2SpineTexture BEGIN constructor TG2SpineTexture.Create(const TextureName: AnsiString); begin inherited Create; Texture := TG2Texture2D.Create; Texture.Load(TextureName); end; destructor TG2SpineTexture.Destroy; begin Texture.Free; inherited Destroy; end; function TG2SpineTexture.GetWidth: Integer; begin Result := Texture.RealWidth; end; function TG2SpineTexture.GetHeight: Integer; begin Result := Texture.RealHeight; end; //TG2SpineTexture END //TG2SpineTextureLoader BEGIN function TG2SpineTextureLoader.LoadTexture(const TextureName: AnsiString): TSpineTexture; begin Result := TG2SpineTexture.Create(TextureName); end; //TG2SpineTextureLoader END //TG2SpineRender BEGIN procedure TG2SpineRender.Render(const Texture: TSpineTexture; const Vertices: PSpineVertexArray); var pv: PSpineVertexArray absolute Vertices; begin g2.PicQuadCol( pv^[0].x, pv^[0].y, pv^[1].x, pv^[1].y, pv^[3].x, pv^[3].y, pv^[2].x, pv^[2].y, pv^[0].u, pv^[0].v, pv^[1].u, pv^[1].v, pv^[3].u, pv^[3].v, pv^[2].u, pv^[2].v, G2Color(Round(pv^[0].r * $ff), Round(pv^[0].g * $ff), Round(pv^[0].b * $ff), Round(pv^[0].a * $ff)), G2Color(Round(pv^[1].r * $ff), Round(pv^[1].g * $ff), Round(pv^[1].b * $ff), Round(pv^[1].a * $ff)), G2Color(Round(pv^[3].r * $ff), Round(pv^[3].g * $ff), Round(pv^[3].b * $ff), Round(pv^[3].a * $ff)), G2Color(Round(pv^[2].r * $ff), Round(pv^[2].g * $ff), Round(pv^[2].b * $ff), Round(pv^[2].a * $ff)), TG2SpineTexture(Texture).Texture, bmNormal, tfLinear ); end; //TG2SpineRender END
I have only tested the runtime with the fpc. I think it should work with delphi as well, but if you have any problems please let me know.
I will later make a runtime for the smart mobile studio.
Thanks a lot Dan! =)... I will try to use it with ZenGL Engine. I will post the code here as soon I get it working!
It would be interesting to post about it on official forum, http://esotericsoftware.com/forum/viewforum.php?f=3, and if possible put it on https://github.com/!
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
There is some incompatibilities with Delphi 2010.
- Overloaded methods should explicitly use the overload clause.
- I had to add .Items in some places, by example need to change SpineTextures.[i] to SpineTextures.Items[i]
- Incompatible type Char and AnsiChar on lines like these one : _Chars[i] := Chr(b); I fixed it using _Chars[i] := AnsiChar(Chr(b)); but I don't know for sure if this is correct! =)
Everything else seems to be working well on Delphi 2010!
Everything else but the draw routine is working with ZenGL already! I'm not 100% sure but It seems ZenGL does not have a function to draw a array of vertices, but only to draw triangles pr2d_TriList. I think I will also need to use tess_Triangulate to convert from vertices to triangles but all of this mess with my head, probably I will need some help from Andrey! =)
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
thanks for testing it with delphi, when I have the time I will try it as well.
the rendering method is quite simple, the array always consists of 4 vertices and the vertex format is:
so you really just need to draw a quadrangle or basically two triangles.Code:TSpineVertexData = packed record x, y, u, v, r, g, b, a: Single; end;
Hummm... we are getting closer! =)
Code:var pv: PSpineVertexArray absolute Vertices; p, t: array of zglTPoint2D; begin SetLength(p, 6); // first triangle p[0].x := pv^[0].x; p[0].y := pv^[0].y; p[1].x := pv^[1].x; p[1].y := pv^[1].y; p[2].x := pv^[2].x; p[2].y := pv^[2].y; // second triangle p[3].x := pv^[1].x; p[3].y := pv^[1].y; p[4].x := pv^[2].x; p[4].y := pv^[2].y; p[5].x := pv^[3].x; p[5].y := pv^[3].y; pr2d_TriList(@Texture, @p[0], nil, 0, length(p) - 1, $FFFFFF, 255, FX_BLEND or PR2D_FILL); SetLength(t, 6); // first triangle t[0].x := pv^[0].u; t[0].y := pv^[0].v; t[1].x := pv^[1].u; t[1].y := pv^[1].v; t[2].x := pv^[2].u; t[2].y := pv^[2].v; // second triangle t[3].x := pv^[1].u; t[3].y := pv^[1].v; t[4].x := pv^[2].u; t[4].y := pv^[2].v; t[5].x := pv^[3].u; t[5].y := pv^[3].v; pr2d_TriList(@Texture, @p[0], @t[0], 0, length(p) - 1, $FFFFFF, 255, FX_BLEND or PR2D_FILL);
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
the second triangle should be 0,2,3 because the vertices are passed in clockwise order
Thanks Dan! =)
Ohh yes! It is working now! =)
Code:var pv: PSpineVertexArray absolute Vertices; vert, text: array of zglTPoint2D; begin //Vertices SetLength(vert, 6); // first triangle vert[0].x := pv^[0].x; vert[0].y := pv^[0].y; vert[1].x := pv^[1].x; vert[1].y := pv^[1].y; vert[2].x := pv^[2].x; vert[2].y := pv^[2].y; // second triangle vert[3].x := pv^[0].x; vert[3].y := pv^[0].y; vert[4].x := pv^[2].x; vert[4].y := pv^[2].y; vert[5].x := pv^[3].x; vert[5].y := pv^[3].y; //Texture SetLength(text, 6); // first triangle text[0].x := pv^[0].u; text[0].y := 1-pv^[0].v; text[1].x := pv^[1].u; text[1].y := 1-pv^[1].v; text[2].x := pv^[2].u; text[2].y :=1- pv^[2].v; // second triangle text[3].x := pv^[0].u; text[3].y := 1-pv^[0].v; text[4].x := pv^[2].u; text[4].y := 1-pv^[2].v; text[5].x := pv^[3].u; text[5].y := 1-pv^[3].v; pr2d_TriList(nil, @vert[0], @text[0], 0, length(vert) - 1, $FFFFFF, 255, FX_BLEND); pr2d_TriList(TG2SpineTexture(Texture).Texture, @vert[0], @text[0], 0, length(vert) - 1, $FFFFFF, 255, FX_BLEND or PR2D_FILL);
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
manipulating floats is a lot faster than integer types in this case. suppose you want to multiply two colors with floats you can do just that multiply them, with bytes you'll need to convert them to floats, multiply and convert them back.
also 12 bytes per vertex is not a major loss, since every attachment only has 4 vertices=)
Bookmarks