📄 expld.cpp
字号:
#include "d3dUtility.h"
#include "psystem.h"
#include "camera.h"
#include <cstdlib>
#include <ctime>
IDirect3DDevice9* Device = 0;
const int Width = 640;
const int Height = 480;
D3DXVECTOR3 a=D3DXVECTOR3(0.0f,0.0f,0.0f);
psys::PSystem* Sno = 0;
Camera TheCamera(Camera::AIRCRAFT);
bool Setup()
{
srand((unsigned int)time(0));
d3d::BoundingBox boundingBox;
boundingBox._min = D3DXVECTOR3(-90.0f, -15.0f, -90.0f);
boundingBox._max = D3DXVECTOR3( 90.0f, 25.0f, 90.0f);
Sno = new psys::Firework(&boundingBox,&a,5000);
Sno->init(Device, "null");
D3DXMATRIX proj;
D3DXMatrixPerspectiveFovLH(
&proj,
D3DX_PI / 4.0f, // 45 - degree
(float)Width / (float)Height,
1.0f,
5000.0f);
Device->SetTransform(D3DTS_PROJECTION, &proj);
return true;
}
void Cleanup()
{
d3d::Delete<psys::PSystem*>( Sno );
d3d::DrawBasicScene(0, 1.0f);
}
bool Display(float timeDelta)
{
if( Device )
{
D3DXMATRIX V;
TheCamera.getViewMatrix(&V);
Device->SetTransform(D3DTS_VIEW, &V);
Sno->update(timeDelta);
//
// Draw the scene:
//
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
Device->BeginScene();
D3DXMATRIX I;
D3DXMatrixIdentity(&I);
Device->SetTransform(D3DTS_WORLD, &I);
d3d::DrawBasicScene(Device, 1.0f);
Device->SetTransform(D3DTS_WORLD, &I);
Sno->render();
Device->EndScene();
Device->Present(0, 0, 0, 0);
}
return true;
}
LRESULT CALLBACK d3d::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
case WM_DESTROY:
::PostQuitMessage(0);
break;
case WM_KEYDOWN:
if( wParam == VK_ESCAPE )
::DestroyWindow(hwnd);
break;
}
return ::DefWindowProc(hwnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE prevInstance,
PSTR cmdLine,
int showCmd)
{
if(!d3d::InitD3D(hinstance,
Width, Height, true, D3DDEVTYPE_HAL, &Device))
{
::MessageBox(0, "InitD3D() - FAILED", 0, 0);
return 0;
}
if(!Setup())
{
::MessageBox(0, "Setup() - FAILED", 0, 0);
return 0;
}
d3d::EnterMsgLoop( Display );
Cleanup();
Device->Release();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -