|
4
|
|
,
- delphi directx 8.1 |
|
Delphi. |
|
[]
[ 1] []
[ ] |
|
,
D3D-.
DirectX C++, Delphi.
. |
|
Direct3D-,
. |
|
CD3DApplication,
, ,
", !" . |
|
CD3DApplication
D3DApp.pas common delphi directx 8.1 |
|
( TForm),
,
, ,
DirectX SDK. |
|
CD3DApplication
TObject.
- WinAPI-
DirectX API,
Windows
DirectX. |
|
-
Create
Destroy
Create_
Run
MsgProc
, ,
OneTimeSceneInit
InitDeviceObjects
RestoreDeviceObjects
FrameMove
Render
InvalidateDeviceObjects
DeleteDeviceObjects
FinalCleanup
,
. |
|
SwitchScreenModes
: 3430
. CD3DApplication
D3DApp.pas
. Delphi
common,
D3DApp.pas |
|
CD3DApplication ,
. |
|
Create
,
-
g_pD3DApp
:= Self;
m_dwCreationWidth
:= 400;
m_dwCreationHeight := 300;
, |
|
- ,
, ,
nil ( ) |
|
Destroy - ,
.
.
,
- , ,
, ?
.
,
( ),
.. -
, - , , ,
, ..
, .
, ,
. |
|
, ,
Free. SAFE_DELETE FreeAndNil |
|
Create_ -
. Create
C++. Delphi
(Create Destroy), C++
,
. ,
, !
,
DirectX-:
Direct3D, ,
( ), ,
, DXTimer
D3D- - ,
OneTimeSceneInit ,
,
, , Initialize3DEnvironment
3D-,
IDirect3DDevice8 ,
.
. ,
, :
Run - WinAPI,
WinAPI-.
MsgProc -
,
. , ..
Windows. -
, ,
.
, .
-
MsgProc /
, .. |
|
- OneTimeSceneInit,
InitDeviceObjects, RestoreDeviceObjects,
FrameMove, Render, InvalidateDeviceObjects, DeleteDeviceObjects, FinalCleanup
- ,
, ,
, , , ,
( ).
|
|
OneTimeSceneInit
.
,
- DirectInput, ,
.
InitDeviceObjects
- ,
DeleteDeviceObjects
..
, .
RestoreDeviceObjects
InvalidateDeviceObjects
.
, .
. ,
. ,
, .
, . |
|
FrameMove - "
" - .
. -
UpdateInput ,
,
,
,
,
Render DXTimer
, FPS - .
Render - ""
, .. - ,
.
, ,
, .
( FrameMove, Render)
, " "
.
,
. |
|
,
. .
CD3DApplication.
, ,
. ,
.
,
.
. |
|
SwitchScreenModes D3DApp.pas,
common
D3DApp.pas - SwitchModesUnit.pas
D3DApp uses [Ctrl]
.
D3DApp.pas . ,
, common,
. , common,
, ! |
|
CD3DApplication.Create_
:
- BuildDeviceList
Initialize3DEnvironment
3D- |
|
- -
{hr:=
BuildDeviceList;
if FAILED(hr) then
begin
SAFE_RELEASE(m_pD3D);
Result:= DisplayErrorMsg(hr, MSGERR_APPMUSTEXIT);
Exit;
end;}
, ,
.
Generic application error .
CD3DApplication ,
.
BuildDeviceList
.
,
, -
3D- |
|
BuildDeviceList
[Ctrl].
.
. |
|
|
|
( ). |
|
|
|
Run . |
|
[F8].
[F7].
.
- >= 640x480
, .
,
.
,
HAL ( ),
, ,
,
..
-
.
|
|
?
m_Adapters
. ,
, ..
-
m_Adapters[a].dwCurrentDevice
:= d;
m_dwAdapter := a;
m_bWindowed := True;
,
- .
Create_
BuildDeviceList -
var
//**
cd: Cardinal; //
Create_
//**
{...}
//
Create_
hr:= BuildDeviceList;
if FAILED(hr) then
begin
SAFE_RELEASE(m_pD3D);
Result:= DisplayErrorMsg(hr, MSGERR_APPMUSTEXIT);
Exit;
end;
//**
cd := m_Adapters[m_dwAdapter].dwCurrentDevice;
//** |
|
, -.
, BuildDeviceList
-
var
//**
CurrentDevice, DeviceModeNum: Cardinal;
DesktopMode: TD3DDisplayMode;
p_AdapterInfo: PD3DAdapterInfo;
pDeviceInfo: PD3DDeviceInfo;
DeviceCurrentMode: TD3DModeInfo;
//**
//
Create_,
, -
,
//**
CurrentDevice := m_Adapters[m_dwAdapter].dwCurrentDevice;
DesktopMode := m_Adapters[m_dwAdapter].d3ddmDesktop;
p_AdapterInfo := @m_Adapters[m_dwAdapter];
pDeviceInfo := @p_AdapterInfo^.devices[CurrentDevice];
DeviceModeNum := pDeviceInfo^.dwCurrentMode;
DeviceCurrentMode := pDeviceInfo^.modes[DeviceModeNum];
//**
-
CurrentDevice,
( ), ,
pDeviceInfo,
|
|
. , m_hWnd , ..
WinAPI, . ,
, , , , .
,
,
MsgProc, .
VCL- TApplication,
",
!". -
D3D-,
. |
|
OneTimeSceneInit .
Initialize3DEnvironment .
|
|
,
pModeInfo
AdjustWindowForChange;
,
,
3
// Create the device
{//**
hr := m_pD3D.CreateDevice(m_dwAdapter, pDeviceInfo^.DeviceType,
m_hWndFocus, pModeInfo^.dwBehavior, m_d3dpp,
m_pd3dDevice);
}
hr := m_pD3D.CreateDevice(m_dwAdapter, pDeviceInfo^.DeviceType,
m_hWndFocus,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
m_d3dpp,
m_pd3dDevice);
? DirectX 8 ,
IDirect3D8::CreateDevice
BehaviorFlags
D3DCREATE_PUREDEVICE = $10; D3DCREATE_HARDWARE_VERTEXPROCESSING
= $40; ,
, (
)
!
DirectX 8 -
D3DCREATE_PUREDEVICE
Specifies that Direct3D does not support Get* calls for anything that
can be stored in state blocks. It also tells Direct3D not to provide any
emulation services for vertex processing. This means that if the device
does not support vertex processing, then the application can use only
post-transformed vertices.
.
. Get*
- . GetViewport
! |
|
( ),
m_strDeviceStats, -,
,
InitDeviceObjects RestoreDeviceObjects,
Initialize3DEnvironment. |
|
Create_
FrameMove
Render. TAppForm.ApplicationEventsIdle |
|
|
|
[]
[ 1] []
[ ] |
|
|
|