資源簡(jiǎn)介
DirectX D3D 編程最好的學(xué)習(xí)實(shí)例
代碼片段和文件信息
#include?
//窗口類的名字
LPCWSTR?m_applicationName;
//應(yīng)用程序?qū)嵗浔?br/>HINSTANCE?m_hinstance;
//窗口句柄
HWND?m_hwnd;
//用來(lái)判斷是否按ESC鍵按下ESC鍵,則退出程序
bool?bexit?=?false;
//初始化窗口類,創(chuàng)建應(yīng)用程序窗口
void?InitializeWindows(int&?screenWidth?int&?screenHeight);
//調(diào)用初始化窗口函數(shù),以及其它的接口類的初始化函數(shù)
bool?Initialize();
//處理消息循環(huán)
void?Run();
//關(guān)閉窗口
void?ShutdownWindows();
//這兩個(gè)函數(shù)是窗口的回調(diào)函數(shù)
static?LRESULT?CALLBACK?MessageHandler(HWND?UINT?WPARAM?LPARAM);
LRESULT?CALLBACK?WndProc(HWND?UINT?WPARAM?LPARAM);
//判斷是否全屏,全屏和窗口模式窗口使用不同的創(chuàng)建窗口參數(shù)
const?bool?FULL_SCREEN?=?false;
//應(yīng)用程序入口main函數(shù)
int?WINAPI?WinMain(HINSTANCE?hInstance?HINSTANCE?hPrevInstance?PSTR?pScmdline?int?iCmdshow)
{
Initialize();
Run();
ShutdownWindows();
return?0;
}
//調(diào)用窗口初始化函數(shù)和其它一些類的初始化函數(shù)
//本例子中,只調(diào)用初始化窗口函數(shù)
bool?Initialize()
{
int?screenWidth?=?0?screenHeight?=?0;
//?初始化窗口
InitializeWindows(screenWidth?screenHeight);
return?true;
}
void?InitializeWindows(int&?screenWidth?int&?screenHeight)
{
WNDCLASSEX?wc;
DEVMODE?dmScreenSettings;
int?posX?posY;
//?得到應(yīng)用程序?qū)嵗浔?br/> m_hinstance?=?GetModuleHandle(NULL);
//?應(yīng)用程序名字
m_applicationName?=?L“Engine“;
//?設(shè)置窗口類參數(shù).
wc.style?????????=?CS_HREDRAW?|?CS_VREDRAW?|?CS_OWNDC;
wc.lpfnWndProc???=?WndProc;?//指定回調(diào)函數(shù)
wc.cbClsExtra????=?0;
wc.cbWndExtra????=?0;
wc.hInstance?????=?m_hinstance;
wc.hIcon ?=?LoadIcon(NULL?IDI_WINLOGO);
wc.hIconSm???????=?wc.hIcon;
wc.hCursor???????=?LoadCursor(NULL?IDC_ARROW);
wc.hbrBackground?=?(HBRUSH)GetStockobject(BLACK_BRUSH);?//默認(rèn)黑色窗口黑色背景
wc.lpszMenuName??=?NULL;
wc.lpszClassName?=?m_applicationName;
wc.cbSize????????=?sizeof(WNDCLASSEX);
//?注冊(cè)窗口類
RegisterClassEx(&wc);
//?得到windows桌面分辨率
screenWidth??=?GetSystemMetrics(SM_CXSCREEN);
screenHeight?=?GetSystemMetrics(SM_CYSCREEN);
//?根據(jù)是否全屏設(shè)置不同的分辨率.
if(FULL_SCREEN)
{
//全屏模式下,設(shè)置窗口大小為windows桌面分辨率.
memset(&dmScreenSettings?0?sizeof(dmScreenSettings));
dmScreenSettings.dmSize???????=?sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth??=?(unsigned?long)screenWidth;
dmScreenSettings.dmPelsHeight?=?(unsigned?long)screenHeight;
dmScreenSettings.dmBitsPerPel?=?32;
dmScreenSettings.dmFields?????=?DM_BITSPERPEL?|?DM_PELSWIDTH?|?DM_PELSHEIGHT;
//?臨時(shí)設(shè)置顯示設(shè)備為全屏模式,注意:應(yīng)用程序退出時(shí)候,將恢復(fù)系統(tǒng)默認(rèn)設(shè)置。
ChangeDisplaySettings(&dmScreenSettings?CDS_FULLSCREEN);
//?設(shè)置窗口的左上角位置為(00).
posX?=?posY?=?0;
}
else
{
//?窗口模式:800*600.
screenWidth??=?800;
screenHeight?=?600;
//?窗口位置左上角坐標(biāo)位置posx,posy
posX?=?(GetSystemMetrics(SM_CXSCREEN)?-?screenWidth)??/?2;
posY?=?(GetSystemMetrics(SM_CYSCREEN)?-?screenHeight)?/?2;
}
//?全屏和窗口使用不同的參數(shù).
if(?FULL_SCREEN)
{
m_hwnd?=?CreateWindowEx(WS_EX_APPWINDOW?m_applicationName?m_applicationName?
WS_CLIPSIBLINGS?|?WS_CLIPCHILDREN?|?WS_POPUP
posX?posY?screenWidth?screenHeight?NULL?NULL?m_hinstance?NULL);
}
else
{
m_hwnd?=?CreateWindowEx(WS_EX_APPWINDOW?m_applicationN
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????31232??2013-03-31?21:47??D3D\Debug\myTutorialD3D11.exe
?????文件?????358484??2013-03-31?21:47??D3D\Debug\myTutorialD3D11.ilk
?????文件?????445440??2013-03-31?21:47??D3D\Debug\myTutorialD3D11.pdb
?????文件??????38400??2013-03-31?21:50??D3D\Debug\myTutorialD3D11_2.exe
?????文件?????374208??2013-03-31?21:50??D3D\Debug\myTutorialD3D11_2.ilk
?????文件?????470016??2013-03-31?21:50??D3D\Debug\myTutorialD3D11_2.pdb
?????文件???32112640??2013-12-05?12:32??D3D\ipch\mytutoriald3d11_9-318d8c42\mytutoriald3d11_9-2d624f1b.ipch
?????文件????????602??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\cl.command.1.tlog
?????文件??????12422??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\CL.read.1.tlog
?????文件????????264??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\CL.write.1.tlog
?????文件??????????2??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件??????????2??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件??????????2??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件??????????2??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件??????????2??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件??????????2??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件???????1402??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件???????2800??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件????????638??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\li
?????文件??????31512??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\main.obj
?????文件????????408??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\mt.command.1.tlog
?????文件????????370??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\mt.read.1.tlog
?????文件????????302??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\mt.write.1.tlog
?????文件????????406??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\myTutorialD3D11.exe.em
?????文件????????472??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\myTutorialD3D11.exe.em
?????文件????????381??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\myTutorialD3D11.exe.intermediate.manifest
?????文件?????????40??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\myTutorialD3D11.lastbuildstate
?????文件???????3066??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\myTutorialD3D11.log
?????文件????????220??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\myTutorialD3D11_manifest.rc
?????文件????????560??2013-03-31?21:47??D3D\myTutorialD3D11\Debug\rc.command.1.tlog
............此處省略707個(gè)文件信息
評(píng)論
共有 條評(píng)論