博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Delphi 与 DirectX 之 DelphiX(1): 安装测试
阅读量:6810 次
发布时间:2019-06-26

本文共 13520 字,大约阅读时间需要 45 分钟。

  hot3.png

测试 Demo 下载: (在 Delphi 2007 和 2009 下均编译通过)
其实按照 的介绍, 比下载来的快, 也不需要下载.

DirectX, 微软很久的技术了; 从 Windows Vista 开始, DirectX 已经是微软操作系统的界面基础了.
在 Delphi 下使用 DirectX 比较流行的有下面四种方式:
(?)
DelphiX 是最早的(十年了), 也是最简单的, 也是和 Delphi 结合最密切的;
但为了入手简单, 准备从 DelphiX 开始, 先有个宏观概念, 同时也学习一下 DelphiX 构造手法;
不过, 我想最终使用的应该是: Delphi DirectX.
DelphiX 从 2000.07.17 就没在更新过, 不过另有热心的支持者一直维护着, 甚至让它支持了 Delphi 2009.
我现在使用的版本是从这里下载的:
使用了它的自动安装文件:
尽管介绍是支持 Delphi 2009, 我还是发现了很多问题; 经过修正最后在 2009 下能用了.
但很多例子并不支持 2009, 因为在 2007 下要稳定得多, 所以选择在 Delphi 2007 下学习 DelphiX; 同时争取让代码兼容 2009.
为了保证运行所有的例子, 还需要把 DelphiXcfg.inc 的倒数第二行的 {.$Define D3DRM} 改为 {$Define D3DRM}
另外, 因为有些日文的注释乱码, 也会让有些例子运行不了, 修改下乱码的地方即可.
目前我抽样测试了一些, 都没问题了.
总感觉学晚了, 争取尽快超越它!

先从网上学了个例子, 作为开盘测试吧:

本例效果图:
26153112_VGHZ.gif

代码文件:

unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, DXDraws, StdCtrls, DXClass;type  TForm1 = class(TDXForm)    DXDraw1: TDXDraw;    DXTimer1: TDXTimer;    DXImageList1: TDXImageList;    procedure FormCreate(Sender: TObject);    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);    procedure DXDraw1Initialize(Sender: TObject);    procedure DXDraw1Finalize(Sender: TObject);    procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);  private    procedure CalculateTables;    procedure PlotPoint(XCenter, YCenter, Radius, Angle: Word);  end;var  Form1: TForm1;implementation{$R *.dfm}var  SineMove: array[0..255] of integer;  CosineMove: array[0..255] of integer;  SineTable: array[0..449] of integer;  CenterX, CenterY: Integer;  x: Word = 0;  y: Word = 0;procedure TForm1.CalculateTables;var  wCount: Word;begin  for wCount := 0 to 255 do  begin    SineMove[wCount] := round( sin( pi*wCount/128 ) * 45 );    CosineMove[wCount] := round( cos( pi*wCount/128 ) * 60 );  end;   for wCount := 0 to 449 do  begin    SineTable[wCount] := round( sin( pi*wCount/180 ) * 128);  end;end;procedure TForm1.PlotPoint(XCenter, YCenter, Radius, Angle: Word);var   a, b : Word;begin  a := ( Radius * SineTable[90 + Angle]);  asm    sar a,7  end;  a := CenterX + XCenter + a;  b := ( Radius * SineTable[Angle] );  asm    sar b,7  end;  b := CenterY + YCenter + b;  if (a < Width ) and ( b < Height ) then  begin    DXImageList1.Items[0].Draw(DXDraw1.Surface, a, b, 0 );  end;end;procedure TForm1.FormCreate(Sender: TObject);begin  DXDraw1.Align := alClient;  CenterX := Width div 2;  CenterY := Height div 2;  CalculateTables;end;procedure TForm1.DXDraw1Finalize(Sender: TObject);begin  DXTimer1.Enabled := False;end;procedure TForm1.DXDraw1Initialize(Sender: TObject);begin  DXTimer1.Enabled := True;end;procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);const  IncAngle = 12;  XMove = 7;  YMove = 8;var  CountAngle : Word;  CountLong : Word;  IncLong :Word;begin  if not DXDraw1.CanDraw then exit;  IncLong := 2;   CountLong := 20;   DXDraw1.Surface.Fill(0);  repeat    CountAngle := 0;    repeat      PlotPoint(CosineMove[(x + (200 - CountLong)) mod 255],                SineMove[(y + (200 - CountLong)) mod 255], CountLong, CountAngle);      Inc(CountAngle, IncAngle);    until CountAngle >= 360;    inc(CountLong, IncLong);    if (CountLong mod 3) = 0 then     begin      inc(IncLong);    end;  until CountLong >= 270;  x := XMove + x mod 255;  y := YMove + y mod 255;  with DXDraw1.Surface.Canvas do  begin    Brush.Style := bsClear;     Font.Color := clWhite;    Font.Size := 12;    Textout(0, 0, 'FPS: '+inttostr( DXTimer1.FrameRate)); { 录制动画是丢了这句 }    Release;  end;  DXDraw1.Flip;end;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);begin  if Key = VK_ESCAPE then Close;end;end.
窗体文件:

object Form1: TForm1  Left = 0  Top = 0  Caption = 'Form1'  ClientHeight = 206  ClientWidth = 339  Color = clBtnFace  Font.Charset = DEFAULT_CHARSET  Font.Color = clWindowText  Font.Height = -11  Font.Name = 'Tahoma'  Font.Style = []  OldCreateOrder = False  OnCreate = FormCreate  OnKeyDown = FormKeyDown  PixelsPerInch = 96  TextHeight = 13  object DXDraw1: TDXDraw    Left = 8    Top = 8    Width = 249    Height = 177    AutoInitialize = True    AutoSize = True    Color = clBlack    Display.FixedBitCount = False    Display.FixedRatio = True    Display.FixedSize = True    Options = [doAllowReboot, doWaitVBlank, doCenter, do3D, doDirectX7Mode, doHardware, doSelectDriver]    SurfaceHeight = 177    SurfaceWidth = 249    OnFinalize = DXDraw1Finalize    OnInitialize = DXDraw1Initialize    TabOrder = 0    Traces = <      item        Name = 'aaa'        Active = True        Tag = 0        Blit.Active = True        Blit.Z = 0        Blit.Width = 0        Blit.Height = 0        Blit.Paths = {          200000000080A8430000FE420000000019000000000000000000000000000000          0000000000000000000000000000000000B0D7E2000080A74300000C43000000          0019000000000000000000000000000000000000000000000000000000000000          000030BD77050080A44300001843000000001900000000000000000000000000          00000000000000000000000000000000000000F0BE770500809F430000234300          0000001900000000000000000000000000000000000000000000000000000000          00000000B0C077050080984300002D4300000000190000000000000000000000          00000000000000000000000000000000000000000070C2770500809043000035          4300000000190000000000000000000000000000000000000000000000000000          00000000000030C477050000874300003B430000000019000000000000000000          0000000000000000000000000000000000000000000000F0C577050000794300          003F430000000019000000000000000000000000000000000000000000000000          0000000000000000B0C777050000644300004043000000001900000000000000          0000000000000000000000000000000000000000000000000070C9770500004F          4300003F43000000001900000000000000000000000000000000000000000000          0000000000000000000030CB770500003A4300003B4300000000190000000000          000000000000000000000000000000000000000000000000000000C099400700          0027430000354300000000190000000000000000000000000000000000000000          000000000000000000000000809B40070000174300002D430000000019000000          0000000000000000000000000000000000000000000000000000000000409D40          0700000943000023430000000019000000000000000000000000000000000000          0000000000000000000000000000009F40070000FE4200001843000000001900          00000000000000000000000000000000000000000000000000000000000000C0          A040070000F24200000C43000000001900000000000000000000000000000000          0000000000000000000000000000000080A240070000EE420000FE4200000000          1900000000000000000000000000000000000000000000000000000000000000          0040A440070000F2420000E44200000000190000000000000000000000000000          00000000000000000000000000000000000000A640070000FE420000CC420000          0000190000000000000000000000000000000000000000000000000000000000          000000C0A74007000009430000B6420000000019000000000000000000000000          000000000000000000000000000000000000000080A94007000017430000A242          0000000019000000000000000000000000000000000000000000000000000000          000000000040AB40070000274300009242000000001900000000000000000000          0000000000000000000000000000000000000000000000AD400700003A430000          8642000000001900000000000000000000000000000000000000000000000000          00000000000000C0AE400700004F4300007C4200000000190000000000000000          00000000000000000000000000000000000000000000000080B0400700006443          0000784200000000190000000000000000000000000000000000000000000000          00000000000000000040B240070000794300007C420000000019000000000000          000000000000000000000000000000000000000000000000000000B440070000          8743000086420000000019000000000000000000000000000000000000000000          0000000000000000000000C0B540070080904300009242000000001900000000          0000000000000000000000000000000000000000000000000000000080B74007          008098430000A242000000001900000000000000000000000000000000000000          0000000000000000000000000040B9400700809F430000B64200000000190000          00000000000000000000000000000000000000000000000000000000000000BB          40070080A4430000CC4200000000190000000000000000000000000000000000          000000000000000000000000000000C0BC40070080A7430000E4420000000019          0000000000000000000000000000000000000000000000000000000000000000          80BE4007}      end>  end  object DXTimer1: TDXTimer    ActiveOnly = True    Enabled = False    Interval = 10    OnTimer = DXTimer1Timer    Left = 160    Top = 104  end  object DXImageList1: TDXImageList    DXDraw = DXDraw1    Items.ColorTable = {      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000      0000000000000000000000000000000000000000000000000000000000000000}    Items = <      item        PatternHeight = 0        PatternWidth = 0        Picture.Data = {          0454444942280000000200000001000000010008000000000004000000000000          0000000000000000000000000099FFFF00FFFFFF000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000000000000000000000000000000000000000000          0000000000000000000000000001000000}        SystemMemory = False        Transparent = True        TransparentColor = clWhite      end>    Left = 192    Top = 96  endend

转载于:https://my.oschina.net/hermer/blog/319364

你可能感兴趣的文章
Android LayoutInflater学习
查看>>
C# GIZP解码
查看>>
Java并发编程:并发容器之ConcurrentHashMap(转载)
查看>>
Java ConcurrentModificationException异常原因和解决方法
查看>>
traceroute
查看>>
使用FileUpload控件上传文件时对文件大小的限制
查看>>
C#线程系列讲座(1):BeginInvoke和EndInvoke方法
查看>>
马的日字走法和knight是同意类型的。
查看>>
Web.config自定义节点configSections
查看>>
codility上的问题 (23)Chi 2012
查看>>
sort uniq妙用
查看>>
用2263份证件照图片样本测试how-old.net的人脸识别
查看>>
递归控件以加入JS方法
查看>>
PHP面试题(English)
查看>>
[转]Git详解之六 Git工具
查看>>
MVC验证13-2个属性至少输入一项
查看>>
Delphi跨平台下的GetTickCount,GetCurrentThreadID
查看>>
得到目录大小
查看>>
值得推荐的C/C++框架和库
查看>>
Linux 命令详解手册(世界著名Linux技术专家力作)
查看>>