前面只是初始化, 现在在上面画上一张图片.
窗体代码:
var
// 精灵
GameSprite1 : TGameSprite;
// 渲染器
CreatorRenderer : TCreatorRenderer;
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
// 创建
CreatorRenderer := TCreatorRenderer.Create();
CreatorRenderer.CreateDevice(self.Handle,self.Width,self.Height ,true);
GameSprite1 := TGameSprite.Create('e:\zss.png',0.0,0.0,1.0);
GameSprite1.Init();
// 开启定时器
Timer1.Enabled := True;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
CreatorRenderer.Free;
GameSprite1.Free;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
CreatorRenderer.BeginRender();
CreatorRenderer.BeginRenderSprite();
GameSprite1.Draw();
CreatorRenderer.EndRenderSprite();
CreatorRenderer.EndRender();
end;
封装一下精灵类
// 精灵类
// warrially
unit xGameSprite;
interface
uses
D3DX9, Direct3D9, Windows, Classes;
type
{ TGameSprite }
TRGBChannels = record
m_ucRChannel, m_ucGChannel, m_ucBChannel : UCHAR;
end;
RGBCHANNELS = TRGBChannels;
_RGBCHANNELS = TRGBChannels;
PRGBCHANNELS = ^TRGBChannels;
TTextColor = record
m_ucR, m_ucG, m_ucB : UCHAR;
end;
TEXTCOLOR = TTextColor;
_TEXTCOLOR = TTextColor;
PTEXTCOLOR = ^TTextColor;
TGameSprite = class(TObject)
private
m_pTex : IDirect3DTexture9;
m_szResourcePath: PWideChar;