dxut 框架依次执行IsD3D9DeviceAcceptable(), ModifyDeviceSettings(), OnD3D9CreateDevice(),OnD3DResetDevice() 四个函数,接下来看看MSDN对以上几个函数的评述:
1.Customize Device Settings in the IsDeviceAcceptable callback
To help DXUT choose the best device settings, use the IsDeviceAcceptable callback function  (either DXUTSetCallbackD3D9DeviceAcceptable or DXUTSetCallbackD3D10DeviceAcceptable) to filter out any settings that are not appropriate for your application.Within the callback function, the application can reject any combination that it does not support or want by returning false in the callback. For instance, this example rejects 16-bit back-buffer formats and devices that do not support at least pixel shader model 2.
bool CALLBACK IsD3D9DeviceAcceptable(
   
D3DCAPS9*     pCaps,
   
D3DFORMAT     AdapterFormat,
   
D3DFORMAT     BackBufferFormat,
   
bool          bWindowed
)
{
    if( BackBufferFormat == D3DFMT_X1R5G5B5 ||
BackBufferFormat == D3DFMT_R5G6B5
)
        return
false;
    if( pCaps->PixelShaderVersion <
D3DPS_VERSION(2,0) )
        return
false;

    return true;
}

2. Change Device Settings in the ModifyDeviceSettings callback
After choosing the best settings, there is one more callback that DXUT uses which can be used to modify the settings. This is the ModifyDeviceSettings callback function. This callback function takes a DXUTDeviceSettings structure.  This structure is a union of DXUTD3D10DeviceSettings and DXUTD3D9DeviceSettings.  It contains everything needed to create a device.  The ver field of the structure indicates whether the settings structure is for a Direct3D 9 or Direct3D 10 device.
3. onD3D9CreateDevice()
创建设备之后,接下来调用OnD3D9CreateDevice() callback, 在此函数中创建内存池类型为D3DPOOL_MANAGED 或者 D3DPOOL_SYSTEMMEM资源。以类型D3DPOOL_MANAGED创建的设备由Direct3D系统代替管理(位于显存或系统内存中),以类型D3DPOOL_SYSTEMMEM创建的设备位于系统内存中,在程序退出之前,这些资源常驻内存,不会出现设备丢失的现象。也就是说,以这两种内存类型创建的资源不需要程序员进行管理。
4.OnD3D9ResetDevice()
DXUT框架在调用OnD3D9CreateDevice()回调函数之后,将调用OnD3D9ResetDevice()回调函数。我们可在函数OnD3D9ResetDevice()中创建所有内存池类型为D3DPOOL_DEFAULT的资源,这一类资源将尽可能存放在显存中,这样可以提高程序的运行速度。但是,这类资源在程序运行时会出现设备丢失的现象,因此需要程序员自己管理。在设备丢失时释放它的内存,当设备恢复时重新为它分配内存。此外,观察变换矩阵和投影变换矩阵以及在整个程序运行期间保持不变的渲染状态通常也在该回调函数中设置。






 
L"string" represents string decoded with Unicode, a data type of const WCHAR *, 16 bits
_T"string" is related to _UNICODE micro definition, if _UNICODE exists, _T"string" is same to L"string", else the result is like common string data type.
2011/4/29
jack.y
 
最明显的区别:
main是dos的C程序入口
winmain是windows的程序入口,也就是GUI的程序入口
wmain用于Unicode, wWinMain是unicode版,WinMain , main 是ANSI版,若要有中文,则使用wWinMain, 也可以使用_tWinMain.
dllmain 是DLL的程序入口.
2011/4/29
 
在windef.h头文件中有如下定义
#define   WINAPI                  __stdcall
#define
   APIENTRY            WINAPI

VC有两种函数调用方式   一种是__stdcall,另一种是__cdecl

函数的调用方式有两种一种是PASCAL调用方式,另一种是C调用方式
使用PASCAL调用方式,函数在返回到调用者之前将参数从栈中删除

使用C调用方式,参数的删除是调用者完成的
WinMain函数是由系统调用的,Windows系统规定由系统调用的函数都遵守PASCAL调用方式

但是VC中函数的缺省调用方式是__cdecl,也就是C调用方式
所以在WinMain前显示的声明。

在Windows编程中将遇到很多声明修饰符,如CALLBACK,WINAPI,PASCAL这些在IntelCPU的计算机上都是__stdcall

详细的声明细节请看windef.h文件      
2011/4/29
 
Hi, I don't have  been here for a long long time, just like a year. Today, I learn a new operator boost::bind, from the open-source C++ Libraries BOOST. Boost::bind is to bind arguments with a "thing" like the function, and run it like a real function. Following is the example:
1.bind free function
int add(int x, int y){ return x+y ;}
add(1, 2)
<===> boost::bind(add, 1, 2);
add(x, y) <===> boost::bind(add,
_1, _2)(x, y);
add(x, x) <===> boost::bind(add, _1, _1)(x, y);


2.bind functor
int operator()(int a, int b)(return a - b;)
bool operator()(long a, long b) {return a == b;}
F f;
int x =
104;
bind<int>(f, _1, _1)(x);
bind<int>(F(), _1, _1)(X);
3
bind class method
struct X
{
 bool f(int a);
};
sample code:
X x;
shared_prt<X> p = new X;
int i(5);
bind(&X::f, boost::ref(x), _1)(i);// x.f(i)
bind(&X::f, x, _1)(i);// x_copy = x, x_copy.f(i), less effective than the one above
bind(&X::f, &x, _1)(i);// (&x)->f(i);
bind(&X::f, p, _1)(i);// smart pointer , p_copy = p, p_copy.f(i);

4. a question what''s the return value ?
EX. bind(add, bind(add, 1,2), bind(add, 1, 2));