多层纹理混合

None.gif//=============================================================================
None.gif
//Desc:主程序源文件
None.gif
//=============================================================================
None.gif
#include"dxstdafx.h"
None.gif#include
"resource.h"
None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//全局变量
None.gif
//-----------------------------------------------------------------------------
None.gif
ID3DXFont*g_pFont=NULL;//ID3DXFont字体对象
None.gif
ID3DXSprite*g_pTextSprite=NULL;//ID3DXSprite文本精灵对象
None.gif
boolg_bShowHelp=true;//标识是否显示简单说明文本
None.gif

None.gifCDXUTDialogResourceManagerg_DialogResourceManager;
//对话框资源管理器
None.gif
CD3DSettingsDlgg_SettingsDlg;//Direct3D设备设置对话框
None.gif
CDXUTDialogg_HUD;//
None.gif
CDXUTDialogg_SampleUI;//
None.gif

None.gifLPDIRECT3DVERTEXBUFFER9g_pVB
=NULL;//顶点缓冲区
None.gif
LPDIRECT3DTEXTURE9g_pTexture1=NULL;//第一层纹理
None.gif
LPDIRECT3DTEXTURE9g_pTexture2=NULL;//第二层纹理
None.gif
None.gif
None.gif
//定义顶点结构和灵活顶点格式
None.gif
structCUSTOMVERTEX
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gifFLOATx,y,z;
//未经过坐标转换的顶点坐标
InBlock.gif
DWORDcolor;//顶点漫反射颜色值
InBlock.gif
FLOATu,v;//顶点纹理坐标
InBlock.gif
FLOATu1,v1;//顶点纹理坐标
InBlock.gif

ExpandedBlockEnd.gif}
;
None.gif
#defineD3DFVF_CUSTOMVERTEX(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX2)
None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//控件ID
None.gif
//-----------------------------------------------------------------------------
None.gif
#defineIDC_TOGGLEFULLSCREEN1
None.gif
#defineIDC_TOGGLEREF2
None.gif
#defineIDC_CHANGEDEVICE3
None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:函数声明
None.gif
//------------------------------------------------------------------------------
None.gif
boolCALLBACKIsDeviceAcceptable(D3DCAPS9*pCaps,D3DFORMATAdapterFormat,D3DFORMATBackBufferFormat,boolbWindowed,void*pUserContext);
None.gif
boolCALLBACKModifyDeviceSettings(DXUTDeviceSettings*pDeviceSettings,constD3DCAPS9*pCaps,void*pUserContext);
None.gifHRESULTCALLBACKOnCreateDevice(IDirect3DDevice9
*pd3dDevice,constD3DSURFACE_DESC*pBackBufferSurfaceDesc,void*pUserContext);
None.gifHRESULTCALLBACKOnResetDevice(IDirect3DDevice9
*pd3dDevice,constD3DSURFACE_DESC*pBackBufferSurfaceDesc,void*pUserContext);
None.gif
voidCALLBACKOnFrameMove(IDirect3DDevice9*pd3dDevice,doublefTime,floatfElapsedTime,void*pUserContext);
None.gif
voidCALLBACKOnFrameRender(IDirect3DDevice9*pd3dDevice,doublefTime,floatfElapsedTime,void*pUserContext);
None.gifLRESULTCALLBACKMsgProc(HWNDhWnd,UINTuMsg,WPARAMwParam,LPARAMlParam,
bool*pbNoFurtherProcessing,void*pUserContext);
None.gif
voidCALLBACKKeyboardProc(UINTnChar,boolbKeyDown,boolbAltDown,void*pUserContext);
None.gif
voidCALLBACKOnGUIEvent(UINTnEvent,intnControlID,CDXUTControl*pControl,void*pUserContext);
None.gif
voidCALLBACKOnLostDevice(void*pUserContext);
None.gif
voidCALLBACKOnDestroyDevice(void*pUserContext);
None.gif
None.gif
voidInitApp();
None.gif
voidRenderText();
None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:入口函数
None.gif
//-----------------------------------------------------------------------------
None.gif
INTWINAPIWinMain(HINSTANCE,HINSTANCE,LPSTR,int)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
//为Debug配置启用运行时内存检查功能
InBlock.gif
#ifdefined(DEBUG)|defined(_DEBUG)
InBlock.gif_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
|_CRTDBG_LEAK_CHECK_DF);
InBlock.gif
#endif
InBlock.gif
InBlock.gif
//设置回调函数
InBlock.gif
DXUTSetCallbackDeviceCreated(OnCreateDevice);
InBlock.gifDXUTSetCallbackDeviceReset(OnResetDevice);
InBlock.gifDXUTSetCallbackDeviceLost(OnLostDevice);
InBlock.gifDXUTSetCallbackDeviceDestroyed(OnDestroyDevice);
InBlock.gifDXUTSetCallbackMsgProc(MsgProc);
InBlock.gifDXUTSetCallbackKeyboard(KeyboardProc);
InBlock.gifDXUTSetCallbackFrameRender(OnFrameRender);
InBlock.gifDXUTSetCallbackFrameMove(OnFrameMove);
InBlock.gif
InBlock.gif
//应用程序相关的初始化
InBlock.gif
InitApp();
InBlock.gif
InBlock.gif
//初始化DXUT,创建窗口,创建Direct3D设备对象
InBlock.gif
DXUTInit(true,true,true);
InBlock.gifDXUTSetCursorSettings(
true,true);
InBlock.gifDXUTCreateWindow(L
"MultiTexture");
InBlock.gifDXUTCreateDevice(D3DADAPTER_DEFAULT,
true,640,480,
InBlock.gifIsDeviceAcceptable,ModifyDeviceSettings);
InBlock.gif
InBlock.gif
//进入消息循环和场景渲染
InBlock.gif
DXUTMainLoop();
InBlock.gif
InBlock.gif
//在此进行应用程序相关的清除工作
InBlock.gif

InBlock.gif
returnDXUTGetExitCode();
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:应用程序相关初始化
None.gif
//-----------------------------------------------------------------------------
None.gif
voidInitApp()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
//初始化对话框
InBlock.gif
g_SettingsDlg.Init(&g_DialogResourceManager);
InBlock.gifg_HUD.Init(
&g_DialogResourceManager);
InBlock.gifg_SampleUI.Init(
&g_DialogResourceManager);
InBlock.gif
InBlock.gif
//为g_HUD对话框设置消息处理函数,添加控件
InBlock.gif
g_HUD.SetCallback(OnGUIEvent);intiY=10;
InBlock.gifg_HUD.AddButton(IDC_TOGGLEFULLSCREEN,L
"Togglefullscreen",35,iY,125,22);
InBlock.gifg_HUD.AddButton(IDC_TOGGLEREF,L
"ToggleREF(F3)",35,iY+=24,125,22);
InBlock.gifg_HUD.AddButton(IDC_CHANGEDEVICE,L
"Changedevice(F2)",35,iY+=24,125,22,VK_F2);
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:设备能力检查
None.gif
//-----------------------------------------------------------------------------
None.gif
boolCALLBACKIsDeviceAcceptable(D3DCAPS9*pCaps,D3DFORMATAdapterFormat,
None.gifD3DFORMATBackBufferFormat,
boolbWindowed,
None.gif
void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
//检查后台缓冲区格式是否支持Alpha混合等操作(postpixelblendingoperations)
InBlock.gif
IDirect3D9*pD3D=DXUTGetD3DObject();
InBlock.gif
if(FAILED(pD3D->CheckDeviceFormat(pCaps->AdapterOrdinal,pCaps->DeviceType,
InBlock.gifAdapterFormat,D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,
InBlock.gifD3DRTYPE_TEXTURE,BackBufferFormat)))
InBlock.gif
returnfalse;
InBlock.gif
InBlock.gif
//检查当前渲染设备是否支持多层纹理混合
InBlock.gif
if(pCaps->MaxTextureBlendStages<=1)
InBlock.gif
returnfalse;
InBlock.gif
InBlock.gif
returntrue;
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:修改Direct3D渲染设备设置
None.gif
//-----------------------------------------------------------------------------
None.gif
boolCALLBACKModifyDeviceSettings(DXUTDeviceSettings*pDeviceSettings,
None.gif
constD3DCAPS9*pCaps,void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
//如果不支持硬件顶点处理则使用软件顶点处理
InBlock.gif
if((pCaps->DevCaps&D3DDEVCAPS_HWTRANSFORMANDLIGHT)==0)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gifpDeviceSettings
->BehaviorFlags=D3DCREATE_SOFTWARE_VERTEXPROCESSING;
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gif
//如果使用参考设备,则弹出警告对话框
InBlock.gif
staticbools_bFirstTime=true;
InBlock.gif
if(s_bFirstTime)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gifs_bFirstTime
=false;
InBlock.gif
if(pDeviceSettings->DeviceType==D3DDEVTYPE_REF)
InBlock.gifDXUTDisplaySwitchingToREFWarning();
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gif
returntrue;
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:在此创建管理内存资源对象
None.gif
//-----------------------------------------------------------------------------
None.gif
HRESULTCALLBACKOnCreateDevice(IDirect3DDevice9*pd3dDevice,
None.gif
constD3DSURFACE_DESC*pBackBufferSurfaceDesc,
None.gif
void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gifHRESULThr;
InBlock.gif
InBlock.gifV_RETURN(g_DialogResourceManager.OnCreateDevice(pd3dDevice));
InBlock.gifV_RETURN(g_SettingsDlg.OnCreateDevice(pd3dDevice));
InBlock.gif
InBlock.gif
//创建字体
InBlock.gif
V_RETURN(D3DXCreateFont(pd3dDevice,15,0,FW_BOLD,1,FALSE,DEFAULT_CHARSET,
InBlock.gifOUT_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH
|FF_DONTCARE,
InBlock.gifL
"Arial",&g_pFont));
InBlock.gif
InBlock.gif
InBlock.gif
//创建第一层纹理对象
InBlock.gif
V_RETURN(D3DXCreateTextureFromFile(pd3dDevice,L"Wall.bmp",&g_pTexture1));
InBlock.gif
InBlock.gif
//创建第二层纹理对象
InBlock.gif
V_RETURN(D3DXCreateTextureFromFile(pd3dDevice,L"light.jpg",&g_pTexture2));
InBlock.gif
InBlock.gif
//设置顶点数据
InBlock.gif
CUSTOMVERTEXg_Vertices[]=
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{-3.0f,-3.0f,0.0f,0xffffffff,0.0f,1.0f,0.0f,1.0f},
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{-3.0f,3.0f,0.0f,0xffffffff,0.0f,0.0f,0.0f,0.0f},
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{3.0f,-3.0f,0.0f,0xffffffff,1.0f,1.0f,1.0f,1.0f},
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{3.0f,3.0f,0.0f,0xffffffff,1.0f,0.0f,1.0f,0.0f}
ExpandedSubBlockEnd.gif}
;
InBlock.gif
InBlock.gif
//创建顶点缓冲区
InBlock.gif
V_RETURN(pd3dDevice->CreateVertexBuffer(4*sizeof(CUSTOMVERTEX),
InBlock.gif
0,D3DFVF_CUSTOMVERTEX,
InBlock.gifD3DPOOL_MANAGED,
&g_pVB,NULL));
InBlock.gif
//填充顶点数据
InBlock.gif
VOID*pVertices;
InBlock.gifV_RETURN(g_pVB
->Lock(0,sizeof(g_Vertices),(void**)&pVertices,0));
InBlock.gifmemcpy(pVertices,g_Vertices,
sizeof(g_Vertices));
InBlock.gifg_pVB
->Unlock();
InBlock.gif
InBlock.gif
returnS_OK;
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:在此创建默认内存类型资源对象
None.gif
//-----------------------------------------------------------------------------
None.gif
HRESULTCALLBACKOnResetDevice(IDirect3DDevice9*pd3dDevice,
None.gif
constD3DSURFACE_DESC*pBackBufferSurfaceDesc,
None.gif
void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gifHRESULThr;
InBlock.gif
InBlock.gifV_RETURN(g_DialogResourceManager.OnResetDevice());
InBlock.gifV_RETURN(g_SettingsDlg.OnResetDevice());
InBlock.gif
InBlock.gif
//设置对话框位置和尺寸
InBlock.gif
g_HUD.SetLocation(pBackBufferSurfaceDesc->Width-170,0);
InBlock.gifg_HUD.SetSize(
170,170);
InBlock.gifg_SampleUI.SetLocation(pBackBufferSurfaceDesc
->Width-170,
InBlock.gifpBackBufferSurfaceDesc
->Height-350);
InBlock.gifg_SampleUI.SetSize(
170,300);
InBlock.gif
InBlock.gif
//恢复字体
InBlock.gif
if(g_pFont)
InBlock.gifV_RETURN(g_pFont
->OnResetDevice());
InBlock.gif
InBlock.gif
//创建ID3DXSprite接口对象
InBlock.gif
V_RETURN(D3DXCreateSprite(pd3dDevice,&g_pTextSprite));
InBlock.gif
InBlock.gif
//设置观察矩阵
InBlock.gif
D3DXMATRIXA16matView;
InBlock.gifD3DXVECTOR3vEyePt(
0.0f,0.0f,-8);
InBlock.gifD3DXVECTOR3vLookatPt(
0.0f,0.0f,0.0f);
InBlock.gifD3DXVECTOR3vUpVec(
0.0f,1.0f,0.0f);
InBlock.gifD3DXMatrixLookAtLH(
&matView,&vEyePt,&vLookatPt,&vUpVec);
InBlock.gifpd3dDevice
->SetTransform(D3DTS_VIEW,&matView);
InBlock.gif
InBlock.gif
//设置投影矩阵
InBlock.gif
D3DXMATRIXA16matProj;
InBlock.gif
floatfAspectRatio=(float)pBackBufferSurfaceDesc->Width/pBackBufferSurfaceDesc->Height;
InBlock.gifD3DXMatrixPerspectiveFovLH(
&matProj,D3DX_PI/4,fAspectRatio,1.0f,100.0f);
InBlock.gifpd3dDevice
->SetTransform(D3DTS_PROJECTION,&matProj);
InBlock.gif
InBlock.gif
//设置第层纹理、纹理阶段状态和纹理坐标索引
InBlock.gif
pd3dDevice->SetTexture(0,g_pTexture1);
InBlock.gifpd3dDevice
->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
InBlock.gifpd3dDevice
->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
InBlock.gifpd3dDevice
->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
InBlock.gifpd3dDevice
->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
InBlock.gifpd3dDevice
->SetTextureStageState(0,D3DTSS_TEXCOORDINDEX,0);
InBlock.gifpd3dDevice
->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
InBlock.gifpd3dDevice
->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
InBlock.gif
InBlock.gif
//设置第层纹理、纹理阶段状态和纹理坐标索引
InBlock.gif
pd3dDevice->SetTexture(1,g_pTexture2);
InBlock.gifpd3dDevice
->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_ADD);
InBlock.gifpd3dDevice
->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE);
InBlock.gifpd3dDevice
->SetTextureStageState(1,D3DTSS_COLORARG2,D3DTA_CURRENT);
InBlock.gifpd3dDevice
->SetTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
InBlock.gifpd3dDevice
->SetTextureStageState(1,D3DTSS_TEXCOORDINDEX,1);
InBlock.gifpd3dDevice
->SetSamplerState(1,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
InBlock.gifpd3dDevice
->SetSamplerState(1,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
InBlock.gif
InBlock.gif
//关闭光照计算
InBlock.gif
pd3dDevice->SetRenderState(D3DRS_LIGHTING,false);
InBlock.gif
InBlock.gif
returnS_OK;
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:更新场景
None.gif
//-----------------------------------------------------------------------------
None.gif
voidCALLBACKOnFrameMove(IDirect3DDevice9*pd3dDevice,doublefTime,
None.gif
floatfElapsedTime,void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:渲染场景
None.gif
//-----------------------------------------------------------------------------
None.gif
voidCALLBACKOnFrameRender(IDirect3DDevice9*pd3dDevice,doublefTime,
None.gif
floatfElapsedTime,void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gifHRESULThr;
InBlock.gif
InBlock.gif
//如果正在利用Direct3D设备设置对话框进行设置,则不渲染场景
InBlock.gif
if(g_SettingsDlg.IsActive())
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gifg_SettingsDlg.OnRender(fElapsedTime);
InBlock.gif
return;
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gif
//清除后台颜色缓冲区和深度缓冲区
InBlock.gif
V(pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
InBlock.gifD3DCOLOR_ARGB(
0,45,50,170),1.0f,0));
InBlock.gif
InBlock.gif
//渲染场景
InBlock.gif
if(SUCCEEDED(pd3dDevice->BeginScene()))
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gifpd3dDevice
->SetStreamSource(0,g_pVB,0,sizeof(CUSTOMVERTEX));
InBlock.gifpd3dDevice
->SetFVF(D3DFVF_CUSTOMVERTEX);
InBlock.gifpd3dDevice
->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
InBlock.gif
InBlock.gif
//渲染文本和控件
InBlock.gif
DXUT_BeginPerfEvent(DXUT_PERFEVENTCOLOR,L"HUD/Stats");
InBlock.gifRenderText();
InBlock.gifV(g_HUD.OnRender(fElapsedTime));
InBlock.gifV(g_SampleUI.OnRender(fElapsedTime));
InBlock.gifDXUT_EndPerfEvent();
InBlock.gif
InBlock.gifV(pd3dDevice
->EndScene());
ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:渲染文本
None.gif
//-----------------------------------------------------------------------------
None.gif
voidRenderText()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gifCDXUTTextHelpertxtHelper(g_pFont,g_pTextSprite,
15);
InBlock.gif
InBlock.gif
//显示当前Direct3D设备状态和渲染帧速率
InBlock.gif
txtHelper.Begin();
InBlock.giftxtHelper.SetInsertionPos(
5,5);
InBlock.giftxtHelper.SetForegroundColor(D3DXCOLOR(
1.0f,1.0f,0.0f,1.0f));
InBlock.giftxtHelper.DrawTextLine(DXUTGetFrameStats(
true));
InBlock.giftxtHelper.DrawTextLine(DXUTGetDeviceStats());
InBlock.gif
InBlock.gif
//显示其他简要信息
InBlock.gif
txtHelper.SetForegroundColor(D3DXCOLOR(1.0f,1.0f,1.0f,1.0f));
InBlock.giftxtHelper.DrawTextLine(L
"多层纹理混合");
InBlock.gif
InBlock.gif
//显示简单帮助文本
InBlock.gif
constD3DSURFACE_DESC*pd3dsdBackBuffer=DXUTGetBackBufferSurfaceDesc();
InBlock.gif
if(g_bShowHelp)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.giftxtHelper.SetInsertionPos(
10,pd3dsdBackBuffer->Height-15*6);
InBlock.giftxtHelper.SetForegroundColor(D3DXCOLOR(
1.0f,0.75f,0.0f,1.0f));
InBlock.giftxtHelper.DrawTextLine(L
"Controls(F1tohide):");
InBlock.gif
InBlock.giftxtHelper.SetInsertionPos(
40,pd3dsdBackBuffer->Height-15*5);
InBlock.giftxtHelper.DrawTextLine(L
"Quit:ESC");
ExpandedSubBlockEnd.gif}

InBlock.gif
else
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.giftxtHelper.SetInsertionPos(
10,pd3dsdBackBuffer->Height-15*2);
InBlock.giftxtHelper.SetForegroundColor(D3DXCOLOR(
1.0f,1.0f,1.0f,1.0f));
InBlock.giftxtHelper.DrawTextLine(L
"PressF1forhelp");
ExpandedSubBlockEnd.gif}

InBlock.giftxtHelper.End();
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:消息处理
None.gif
//-----------------------------------------------------------------------------
None.gif
LRESULTCALLBACKMsgProc(HWNDhWnd,UINTuMsg,WPARAMwParam,LPARAMlParam,
None.gif
bool*pbNoFurtherProcessing,void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
*pbNoFurtherProcessing=g_DialogResourceManager.MsgProc(hWnd,uMsg,wParam,lParam);
InBlock.gif
if(*pbNoFurtherProcessing)
InBlock.gif
return0;
InBlock.gif
InBlock.gif
if(g_SettingsDlg.IsActive())
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gifg_SettingsDlg.MsgProc(hWnd,uMsg,wParam,lParam);
InBlock.gif
return0;
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gif
*pbNoFurtherProcessing=g_HUD.MsgProc(hWnd,uMsg,wParam,lParam);
InBlock.gif
if(*pbNoFurtherProcessing)
InBlock.gif
return0;
InBlock.gif
InBlock.gif
*pbNoFurtherProcessing=g_SampleUI.MsgProc(hWnd,uMsg,wParam,lParam);
InBlock.gif
if(*pbNoFurtherProcessing)
InBlock.gif
return0;
InBlock.gif
InBlock.gif
return0;
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:键盘消息处理
None.gif
//-----------------------------------------------------------------------------
None.gif
voidCALLBACKKeyboardProc(UINTnChar,boolbKeyDown,boolbAltDown,void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
if(bKeyDown)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif
switch(nChar)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif
caseVK_F1:g_bShowHelp=!g_bShowHelp;break;
ExpandedSubBlockEnd.gif}

ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:处理各种控件消息
None.gif
//-----------------------------------------------------------------------------
None.gif
voidCALLBACKOnGUIEvent(UINTnEvent,intnControlID,CDXUTControl*pControl,
None.gif
void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
switch(nControlID)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif
caseIDC_TOGGLEFULLSCREEN:
InBlock.gifDXUTToggleFullScreen();
InBlock.gif
break;
InBlock.gif
InBlock.gif
caseIDC_TOGGLEREF:
InBlock.gifDXUTToggleREF();
InBlock.gif
break;
InBlock.gif
InBlock.gif
caseIDC_CHANGEDEVICE:
InBlock.gifg_SettingsDlg.SetActive(
!g_SettingsDlg.IsActive());
InBlock.gif
break;
ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//-----------------------------------------------------------------------------
None.gif
//Desc:释放在OnResetDevice()中创建的资源
None.gif
//-----------------------------------------------------------------------------
None.gif
voidCALLBACKOnLostDevice(void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gifg_DialogResourceManager.OnLostDevice();
InBlock.gifg_SettingsDlg.OnLostDevice();
InBlock.gif
if(g_pFont)
InBlock.gifg_pFont
->OnLostDevice();
InBlock.gifSAFE_RELEASE(g_pTextSprite);
ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
//------------------------------------------------------------------------------
None.gif
//Desc:释放在OnCreateDevice()中创建的资源
None.gif
//------------------------------------------------------------------------------
None.gif
voidCALLBACKOnDestroyDevice(void*pUserContext)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gifg_DialogResourceManager.OnDestroyDevice();
InBlock.gifg_SettingsDlg.OnDestroyDevice();
InBlock.gifSAFE_RELEASE(g_pFont);
InBlock.gif
InBlock.gifSAFE_RELEASE(g_pVB);
InBlock.gifSAFE_RELEASE(g_pTexture1);
InBlock.gifSAFE_RELEASE(g_pTexture2);
ExpandedBlockEnd.gif}

None.gif
None.gif
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页