資源簡(jiǎn)介
基于MFC 的 DX 框架

代碼片段和文件信息
//?DirectXView.cpp?:?實(shí)現(xiàn)文件
//
#include?“stdafx.h“
#include?“SceneEdit.h“
#include?“DirectXView.h“
//#include?“.\directxview.h“
CDirectXView* g_lpDirectXView?=?NULL;
//?CDirectXView
IMPLEMENT_DYNCREATE(CDirectXView?CView)
CDirectXView::CDirectXView()
{
m_pD3D?=?NULL;
m_pD3DDevice?=?NULL;
g_lpDirectXView?=?this;
}
CDirectXView::~CDirectXView()
{
g_lpDirectXView?=?NULL;
}
BEGIN_MESSAGE_MAP(CDirectXView?CView)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_TIMER()
END_MESSAGE_MAP()
//?CDirectXView?繪圖
void?CDirectXView::OnDraw(CDC*?pDC)
{
CDocument*?pDoc?=?GetDocument();
//?TODO:?在此添加繪制代碼
//?Clear?the?back?buffer?to?a?blue?color
m_pD3DDevice->Clear(?0?NULL?D3DCLEAR_TARGET?
D3DCOLOR_XRGB(248248248)?1.0f?0?);
//?Begin?the?scene
m_pD3DDevice->BeginScene();
//?Rendering?of?scene?objects?happens?here
Render(m_pD3DDevice);
//?End?the?scene
m_pD3DDevice->EndScene();
m_pD3DDevice->Present(?NULL?NULL?NULL?NULL?);
}
//?CDirectXView?診斷
#ifdef?_DEBUG
void?CDirectXView::AssertValid()?const
{
CView::AssertValid();
}
void?CDirectXView::Dump(CDumpContext&?dc)?const
{
CView::Dump(dc);
}
#endif?//_DEBUG
//?CDirectXView?消息處理程序
int?CDirectXView::OnCreate(LPCREATESTRUCT?lpCreateStruct)
{
if?(CView::OnCreate(lpCreateStruct)?==?-1)
return?-1;
//?TODO:??在此添加您專用的創(chuàng)建代碼
if(?NULL?==?(m_pD3D?=?Direct3DCreate9(D3D_SDK_VERSION)))
return?-1;
D3DPRESENT_PARAMETERS?d3dpp;?
ZeroMemory(?&d3dpp?sizeof(d3dpp)?);
d3dpp.Windowed?=?TRUE;
d3dpp.SwapEffect?=?D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat?=?D3DFMT_UNKNOWN;
HRESULT hr?=?m_pD3D->CreateDevice(?
D3DADAPTER_DEFAULT?
D3DDEVTYPE_HAL?
GetSafeHwnd()
D3DCREATE_SOFTWARE_VERTEXPROCESSING
&d3dpp?
&m_pD3DDevice?)?;
if(?FAILED(?hr))
{
//DXTRACE_ERR(“創(chuàng)建DirectX失敗!“hr);
return?-1;
}
SetTimer(150NULL);
return?0;
}
void?CDirectXView::OnDestroy()
{
KillTimer(1);
if(m_pD3DDevice?!=?NULL)
{
m_pD3DDevice->Release();
}
if(?m_pD3D?!=?NULL)
{
m_pD3D->Release();
}
CView::OnDestroy();
//?TODO:?在此處添加消息處理程序代碼
}
void CDirectXView::Render(LPDIRECT3DDEVICE9 pD3DDevice)
{
ASSERT(pD3DDevice);
}
void?CDirectXView::OnTimer(UINT?nIDEvent)
{
//?TODO:?在此添加消息處理程序代碼和/或調(diào)用默認(rèn)值
Invalidate(FALSE);
CView::OnTimer(nIDEvent);
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????21630??2003-04-01?19:36??SceneEdit\res\SceneEdit.ico
?????文件????????698??2006-12-05?15:20??SceneEdit\res\SceneEdit.manifest
?????文件????????365??2006-12-05?15:20??SceneEdit\res\SceneEdit.rc2
?????文件????????598??2003-04-01?19:36??SceneEdit\res\Toolbar.bmp
????..A.SH.??????4096??2006-12-05?15:57??SceneEdit\res\Thumbs.db
?????目錄??????????0??2006-12-05?15:36??SceneEdit\res
?????文件???????2460??2006-12-05?15:56??SceneEdit\DirectXView.cpp
?????文件????????716??2006-12-05?15:30??SceneEdit\DirectXView.h
?????文件???????4251??2006-12-05?15:35??SceneEdit\MainFrm.cpp
?????文件???????1081??2006-12-05?15:38??SceneEdit\MainFrm.h
?????文件???????1126??2006-12-05?15:31??SceneEdit\ob
?????文件????????527??2006-12-05?15:31??SceneEdit\ob
?????文件???????2932??2006-12-05?15:20??SceneEdit\ReadMe.txt
?????文件????????681??2006-12-05?15:21??SceneEdit\resource.h
?????文件??????62748??2006-12-05?15:21??SceneEdit\SceneEdit.aps
?????文件???????2440??2006-12-05?15:20??SceneEdit\SceneEdit.cpp
?????文件????????495??2006-12-05?15:20??SceneEdit\SceneEdit.h
?????文件?????838656??2006-12-05?15:56??SceneEdit\SceneEdit.ncb
?????文件???????9040??2006-12-05?15:21??SceneEdit\SceneEdit.rc
?????文件????????907??2006-12-05?15:20??SceneEdit\SceneEdit.sln
????..A..H.?????13312??2006-12-05?15:56??SceneEdit\SceneEdit.suo
?????文件???????5024??2006-12-05?15:28??SceneEdit\SceneEdit.vcproj
?????文件????????138??2006-12-05?15:20??SceneEdit\stdafx.cpp
?????文件???????4238??2006-12-05?15:39??SceneEdit\stdafx.h
?????目錄??????????0??2006-12-05?15:36??SceneEdit
-----------?---------??----------?-----??----
???????????????978159????????????????????25
評(píng)論
共有 條評(píng)論