directx6.0ForDelphi sdk 的使用(20分)

  • 主题发起人 主题发起人 liujiyun
  • 开始时间 开始时间
L

liujiyun

Unregistered / Unconfirmed
GUEST, unregistred user!
最近拿到一份 directx6.0forDelphi sdk , 在目录下有多个.dcu。
请问该东东如何使用。
 
use ddraw,d3drm...
然后调用其中的函数,具体的可见C++Builder中有不少directX的例子程序。
最好是搞一本directx的书。
 
执行安装程序会自动将构件加到构件板上
 
to www:
他说的是sdk,不是控件。
 
to: cytown,pxlei
中国科大主页的科大虫虫下
202.38.79.17/~chenlee/download/dx/dx6sdk_for_delphi4.zip
问了一个问题,好象是为科大作了一个广告!
bye!
 
to: hubdog
.dcu 怎么办?
Thanks
 
我很奇怪为什么只有dcu,应该也有pas,实际上他就是由c语言的头文件翻译过来的
如果你只用到2维的图象功能,你可以只use ddraw,下面是一个C++Builder的例子
,他随机填充颜色。可以很容易的该成delphi的。若用3维功能就很麻烦,不封装的
话会累死人的,我推荐CDX lib(VC++)写的,相当不错(封装的比较简单好学)
不象delphiX,很难用,很难改。我觉得DirectX调试极困难,动不动就死,nt支
持又不好,不太好学。
头文件
//---------------------------------------------------------------------------
#ifndef cfillH
#define cfillH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published: // IDE-managed Components
TTimer *GameTimer;
void __fastcall FormDestroy(TObject *Sender);
void __fastcall GameTimerTimer(TObject *Sender);
void __fastcall FormKeyDown(TObject *Sender, WORD &amp;Key,
TShiftState Shift);

private: // User declarations
LPDIRECTDRAW lpDD;
LPDIRECTDRAWSURFACE lpDDSurPrimary,lpDDSurBack;
bool GameActive;
byte phase;
void __fastcall Start();
public: // User declarations
__fastcall TMainForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif

主文件
cpp文件
//---------------------------------------------------------------------------
#include <vcl.h>
#include <ddraw.h>
#pragma hdrstop

#include "cfill.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
lpDD = NULL;
phase = 0;
GameActive = false;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormDestroy(TObject *Sender)
{
if(lpDD !=NULL)
{
if(lpDDSurPrimary !=NULL)
{
lpDDSurPrimary->Release();
lpDDSurPrimary = NULL;
}
lpDD->Release();
lpDD = NULL;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Start()
{
HRESULT hres;
DDSURFACEDESC ddSurDesc;
char buf[256];

hres = DirectDrawCreate(NULL,&amp;lpDD,NULL);
if(hres == DD_OK)
{
hres = lpDD->SetCooperativeLevel(Handle,
DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
if(hres == DD_OK)
{
hres = lpDD->SetDisplayMode(640, 480, 8);
if(hres == DD_OK)
{
ddSurDesc.dwSize = sizeof(ddSurDesc);
ddSurDesc.dwFlags = DDSD_CAPS;
ddSurDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

hres = lpDD->CreateSurface(&amp;ddSurDesc,&amp;lpDDSurPrimary, NULL);
if(hres == DD_OK)
{
GameTimer->Enabled = True;
GameActive = True;
return;
}
}
}
}
wsprintf(buf, "Direct Draw Init Failed (%08lx)/n", hres);
MessageBox(Handle, buf, "ERROR", MB_OK);
Close();
}
//--------------------------------------------------------------
void __fastcall TMainForm::GameTimerTimer(TObject *Sender)
{
DDBLTFX ddbltfx;
HRESULT hres;

randomize;
ddbltfx.dwSize= sizeof (DDBLTFX);
ddbltfx.dwFillColor= RGB(random(256),random(256),random(256));

//lpDDSurPrimary->Lock(NULL,NULL,DDLOCK_WAIT,NULL);
hres = lpDDSurPrimary->Blt (NULL,NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &amp;ddbltfx);
//lpDDSurPrimary->Unlock(NULL);
//Form的属性最好是无边框,无标题栏
if(hres == DDERR_SURFACELOST)
{
hres = lpDDSurPrimary->Restore();
if (hres == DD_OK)
lpDDSurPrimary->Blt(NULL,NULL,NULL, DDBLT_WAIT | DDBLT_COLORFILL,&amp;ddbltfx);
}
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::FormKeyDown(TObject *Sender, WORD &amp;Key,
TShiftState Shift)
{

switch (Key)
{
case VK_F3:
Start();
break;

case VK_ESCAPE:
Close();
break;
}

}
 
Thank you very much!
想问一问版主能否多加 30 分!
Thank you again!
 
to hubdog:
能否妹我一份SDK?或告知地址,我去科大但上不去
谢谢,pywhm@sina.com
 
后退
顶部