First,you need to download a DirectX9 Sdk and setup it.( DX9 SDK June 2006 You can also use other versions of DX9 SDK.)
Then you need to build a empty Win32 project with you visual c++
(Why empty project?
Because empty project is easy to use.I dislike the code created automatically by VC++...
You may build a non-empty project as you know how to do it exactly.)
Add all files in Rap3d to your project
Like this:
Wanna konw how to work with Rap3d?
You may read the \Samples (included in Rap3d.rar)
Sample List:
--Work with 3D Model
--draw 2d on screen
--Bill Board
--Animation Board
--Music & Font
Now Let's have a look at how easy rap3d is.
This is the code of displaying 3d model for example.
How easy it is!
/* ***************************************
Rap3D Engine Sample
http://rap3d.sf.net
Author: Bill Hsu (C) All Rights Reserved
http://www.graptor.com
MSN/Email: bill # graptor.com (change" # "into @)
**************************************** */
#include " ..\\..\\Rap3d\\Rap3d.h "
#include " ..\\..\\Rap3d\\RapModel.h "
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void update( float timeDelta);
Rap3d rap3d;
RapModel model;
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE prevInstance,
PSTR cmdLine,
int showCmd)
{
rap3d.Init(hInstance, // instance
& WndProc, // LRESULT CALLBACK WndProc
800 , 600 , // width & height
true , // Full screen or not
" Rap3d Sample--3D Model " , // Window caption
IDI_APPLICATION, // Icon,if you add an icon in you resource,you may use (LPCTSTR)IDI_ICON1 here
D3DX_PI / 2.5f , // angle of view
1.33f , // Aspect
1.0f , // near plane
750.0f ); // far plane
model.SetEngine( & rap3d);
model.LoadXfile( " ..\\Media\\SpaceFighter01\\SpaceFighter01.X " );
model.SetPosition( 0.0f , 0.0f , 0.0f );
model.Scale( 0.03f , 0.03f , 0.03f );
model.InitRotate( 0.0f ,D3DX_PI, 0.0f ); // set the initial rotation for model
D3DXVECTOR3 eye( 0.0f , 5.0f , - 20.0f );
D3DXVECTOR3 lookat( 0.0f , 0.0f , 10.0f );
rap3d.SetCamera(eye,lookat);
MSG msg;
ZeroMemory( & msg, sizeof (msg));
static float lastTime = ( float )timeGetTime();
while (msg.message != WM_QUIT )
{
if (PeekMessage( & msg, 0 , 0 , 0 , PM_REMOVE))
{
TranslateMessage( & msg);
DispatchMessage( & msg);
}
else
{
float currTime = ( float )timeGetTime();
float timeDelta = currTime - lastTime;
update(timeDelta);
lastTime = currTime;
}
}
}
void update( float timeDelta)
{
model.Rotate(timeGetTime() / 1000.0f ,timeGetTime() / 1000.0f ,timeGetTime() / 1000.0f ); // Rotate modle
rap3d.Clear( 0x12345678 ); // clear screen
rap3d.BeginRender();
// All render must be between ->BeginRender() and ->EndRender
model.Render();
rap3d.EndRender();
}
LRESULT CALLBACK 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);
}