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:
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
as you can see it's almost nothing compared to the size of the runtime code itself (~2700 lines).
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.
Bookmarks