亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? application.cpp

?? real-time(實(shí)時(shí)渲染技術(shù)DirectX)6-12
?? CPP
字號(hào):
/***************************************************************
* Application.cpp                                              *
*                                                              *
* This file contains the implementation of the                 *
* CHostApplication class.									   *
* To compile correctly, this file must be linked with:         *
* kernel32.lib                                                 *
* user32.lib                                                   *
* d3dx8dt.lib                                                  *
* d3d8.lib                                                     *
*                                                              *
* Changes:                                                     *
*	*  Added Direct3D device support to CHostApplication       *
*	*  Added several virtual functions to allow easy           *
*      subclassing  in later chapters.                         *
*   *  Removed previous comments and commented new code        *
***************************************************************/

#include "Executable.h"
#include "Application.h"

CHostApplication::CHostApplication()
{
	m_WindowWidth  = 640;
	m_WindowHeight = 480;
}

void CHostApplication::Go()
{
	WNDCLASSEX WindowClass = {sizeof(WNDCLASSEX), 
							  CS_CLASSDC,
							  EntryMessageHandler,
							  0,
							  0, 
							  GetModuleHandle(NULL),
							  NULL,
							  NULL,
							  NULL,
							  NULL,
							  "Host Application",
							  NULL};

	RegisterClassEx(&WindowClass);

    m_hWnd = CreateWindow("Host Application",
							"Host Application", 
							WS_OVERLAPPEDWINDOW,
							0,
							0,
							m_WindowWidth,
							m_WindowHeight,
							GetDesktopWindow(),
							NULL,
							WindowClass.hInstance,
							NULL);

	if(m_hWnd)
		ShowWindow(m_hWnd, SW_SHOW);

	//Initialize the Continue flag.
	m_Continue = TRUE;

	//Call the PreInitialize function to allow any children
	//to preset anything
	if (!PreInitialize())
		return;

	//Initialize the D3D object.
	InitializeD3D();


	//We're going to use EasyCreateWindowed for now.  
	//If we fail, stop everything...
	//if (FAILED(EasyCreateWindowed(m_hWnd, D3DDEVTYPE_HAL, 
	//				  D3DCREATE_HARDWARE_VERTEXPROCESSING)))
	//	return;

	/*  FOR FULLSCREEN TEST
	D3DDISPLAYMODE mode;
	mode.Width = 640;
	mode.Height = 480;
	mode.RefreshRate = 60;
	mode.Format = D3DFMT_X8R8G8B8;

	if (FAILED(EasyCreateFullScreen(&mode, D3DDEVTYPE_HAL, 
						  D3DCREATE_HARDWARE_VERTEXPROCESSING)))
		return;
*/

	//Call the PostIinitialize function to allow any children
	//to continue initializing anything
	if (!PostInitialize())
		return;
	
	MSG Message; 
	PeekMessage(&Message, 0, 0, 0, PM_REMOVE);

	while (Message.message != WM_QUIT && m_Continue)
    {
		//Call PreRender first
		PreRender();

		//Call the main render function
		Render();

		//Present the backbuffer contents to the display.  If
		//we lose the device, let the device class get it back.
		if (D3DERR_DEVICELOST == PostRender())
		{
			//do any pre-cleanup
			PreReset();
			
			//Let the device class reset the device
			RestoreDevice();

			//Tell the rest of the app that this has happened
			PostReset();
		}


		TranslateMessage(&Message);
        DispatchMessage(&Message);
		PeekMessage(&Message, 0, 0, 0, PM_REMOVE);

		//If the child class returns false, stop the program.
		m_Continue = HandleMessage(&Message);
    }

	//Call the PreTerminate function in case there is any 
	//pre-cleanup to do.
	PreTerminate();

	//Destroy the Device
	DestroyDevice();

	//Call the PostTerminate function in case there is any 
	//post-cleanup to do.
	PostTerminate();
}

//The prerender function handles everything that happens before
//rendering, such as clearing the buffers.  If an application
//implements its own PreRender function, that function MUST
//call BeginScene.
void CHostApplication::PreRender()
{
	//Clear the device
	m_pD3DDevice->Clear(0, NULL,
						D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
						D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

	//Call BeginScene to set up the device
	m_pD3DDevice->BeginScene();
		
	return;
}

//The PostRender function stops the rendering process.  If
//another application implements this function, it MUST
//call EndScene. It returns the result of Present so that
//the device restoration function knows what to do...
HRESULT CHostApplication::PostRender()
{
	// End the scene
	m_pD3DDevice->EndScene();

	return m_pD3DDevice->Present(NULL, NULL, NULL, NULL);
}


CHostApplication::~CHostApplication()
{
	//Release the D3D object
	if (m_pD3D)
		m_pD3D->Release();

	m_pD3D = NULL;
}

LRESULT WINAPI CHostApplication::MessageHandler(HWND hWnd, 
												UINT Message, 
												WPARAM wParam,
												LPARAM lParam)
{
	switch(Message)
    {
		case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    }
	return DefWindowProc(hWnd, Message, wParam, lParam);
}

HRESULT CHostApplication::InitializeD3D()
{
	//Create the actual D3D object.
	m_pD3D = Direct3DCreate8(D3D_SDK_VERSION);

	//Set the default device value to NULL
	m_pD3DDevice = NULL;

	//Return a default value
	return S_OK;
}

HRESULT CHostApplication::CreateDevice(
			D3DDEVICE_CREATION_PARAMETERS *pCreateParms,
			D3DPRESENT_PARAMETERS         *pPresentParms)
{
	//Save the parameter blocks
	memcpy(&m_CreationParameters, pCreateParms, 
		   sizeof(D3DDEVICE_CREATION_PARAMETERS));
	memcpy(&m_PresentParameters, pPresentParms,
		   sizeof(D3DPRESENT_PARAMETERS));

	//Create the device
	return m_pD3D->CreateDevice(pCreateParms->AdapterOrdinal, 
		                        pCreateParms->DeviceType,
						        pCreateParms->hFocusWindow,
						        pCreateParms->BehaviorFlags,
						        pPresentParms,
						        &m_pD3DDevice);
}

HRESULT CHostApplication::DestroyDevice()
{
	//Release the D3D Device
	if (m_pD3DDevice)
		m_pD3DDevice->Release();

	m_pD3DDevice = NULL;

	//return a default value
	return S_OK;
}

long CHostApplication::EnumerateModes(D3DDISPLAYMODE *pModes,
									  long ModeCount)
{
	//Get the actual number of available modes
	long Count = m_pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT);

	//If they asked for more than what is available, only give
	//them what is available.
	if (ModeCount > Count)
		ModeCount = Count;

	//Loop through the available modes, filling the array until
	//it is full.
	for (long ModeIndex = 0; ModeIndex < ModeCount; ModeIndex++)
	{
		m_pD3D->EnumAdapterModes(D3DADAPTER_DEFAULT, ModeIndex, 
							     &(pModes[ModeIndex]));
	}

	//Return the actual number available, in case they want to
	//ask for more.
	return Count;
}

HRESULT CHostApplication::RestoreDevice()
{
	HRESULT Result = m_pD3DDevice->TestCooperativeLevel();

	//If the device is lost, enter a loop waiting for
	//it to be restored.
	while(Result == D3DERR_DEVICELOST)
	{
		//Keep testing the level until it says we 
		//can reset.
		while(Result != D3DERR_DEVICENOTRESET)
		{
			//Give up control to other applications
			Sleep(1000);

			//Pump messages in order to respond to messages
			//that may lead to restoration.
			MSG Message;
			PeekMessage(&Message, 0, 0, 0, PM_REMOVE);
			TranslateMessage(&Message);
			DispatchMessage(&Message);

			//Check to see if things are ready to be reset
			Result = m_pD3DDevice->TestCooperativeLevel();
		}

		//Reset the device using the saved parameters
		if (FAILED(m_pD3DDevice->Reset(&m_PresentParameters)))
			Result = D3DERR_DEVICELOST;
	}	

	return S_OK;
}

HRESULT CHostApplication::EasyCreateWindowed(HWND WindowHandle, 
							                 D3DDEVTYPE DeviceType, 
							                 DWORD Behavior)
{
	D3DDISPLAYMODE CurrentMode;
	if (SUCCEEDED(m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,
								                &CurrentMode)))
	{
		//Since this is a convenience function for the developer,
		//make sure your settings make sense for your hardware.
		//These settings work well for a geForce3.
		ZeroMemory(&m_PresentParameters, 
				   sizeof(D3DPRESENT_PARAMETERS));
		m_PresentParameters.Windowed = TRUE;
		m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
		m_PresentParameters.BackBufferFormat = CurrentMode.Format;
		m_PresentParameters.EnableAutoDepthStencil = TRUE;
		m_PresentParameters.AutoDepthStencilFormat = D3DFMT_D24S8;

		m_CreationParameters.AdapterOrdinal = 
											D3DADAPTER_DEFAULT;
		m_CreationParameters.DeviceType     = DeviceType;
		m_CreationParameters.hFocusWindow   = WindowHandle;
		m_CreationParameters.BehaviorFlags  = Behavior;

		return CreateDevice(&m_CreationParameters, 
							&m_PresentParameters);
	}

	//if we got this far, we've failed
	return E_FAIL;
}

HRESULT CHostApplication::EasyCreateFullScreen(D3DDISPLAYMODE *pMode,
							                   D3DDEVTYPE DeviceType, 
							                   DWORD Behavior)
{
	//Since this is a convenience function for the developer,
	//make sure your settings make sense for your hardware.
	//These settings work well for a geForce3.
	ZeroMemory(&m_PresentParameters, 
			   sizeof(D3DPRESENT_PARAMETERS));
	m_PresentParameters.Windowed = FALSE;
	m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
	m_PresentParameters.BackBufferWidth = pMode->Width;
	m_PresentParameters.BackBufferHeight = pMode->Height;
	m_PresentParameters.BackBufferFormat = pMode->Format;
	m_PresentParameters.FullScreen_RefreshRateInHz = 
										pMode->RefreshRate;
	m_PresentParameters.EnableAutoDepthStencil = TRUE;
	m_PresentParameters.AutoDepthStencilFormat = D3DFMT_D24S8;

	m_CreationParameters.AdapterOrdinal = 
										D3DADAPTER_DEFAULT;
	m_CreationParameters.DeviceType     = DeviceType;
	m_CreationParameters.BehaviorFlags  = Behavior;
	m_CreationParameters.hFocusWindow   = m_hWnd;

	return CreateDevice(&m_CreationParameters, 
						&m_PresentParameters);
}

//This is our overridable message processor.  We handle the
//escape key as an example of how to use this function
BOOL CHostApplication::HandleMessage(MSG *pMessage)
{
	if (pMessage->message == WM_KEYDOWN && 
		pMessage->wParam == VK_ESCAPE)
		return FALSE;
	return TRUE;
}

//These are placeholders for functions that can be implemented
//by other classes.  They will be discussed more in later 
//code samples.
//If any of these functions return FALSE, the application will
//stop.
void CHostApplication::Render(){}
BOOL CHostApplication::PreInitialize(){return TRUE;}
BOOL CHostApplication::PreTerminate(){return TRUE;}
BOOL CHostApplication::PostInitialize(){return TRUE;}
BOOL CHostApplication::PostTerminate(){return TRUE;}
BOOL CHostApplication::PreReset(){return TRUE;}
BOOL CHostApplication::PostReset(){return TRUE;}



?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国内精品视频| 欧美网站大全在线观看| 久久精品噜噜噜成人88aⅴ| 亚洲高清视频的网址| 亚洲自拍偷拍麻豆| 亚洲黄色小视频| 亚洲在线视频一区| 亚洲国产精品久久艾草纯爱| 亚洲精品老司机| 亚洲高清免费视频| 视频一区欧美日韩| 久久精品国产在热久久| 黄色成人免费在线| 成人深夜视频在线观看| av不卡一区二区三区| 91麻豆免费在线观看| 在线观看日韩电影| 欧美一区二区三区四区五区| 日韩午夜小视频| 国产亚洲欧洲一区高清在线观看| 国产欧美日产一区| 亚洲美女精品一区| 视频在线在亚洲| 国产一区二区美女诱惑| 成人av一区二区三区| 色综合久久88色综合天天| 欧美日韩三级在线| 亚洲精品一区二区精华| 国产精品无人区| 亚洲欧美国产77777| 日日摸夜夜添夜夜添国产精品| 麻豆免费精品视频| 粉嫩av一区二区三区| 色吧成人激情小说| 日韩欧美在线影院| 国产精品入口麻豆原神| 亚洲午夜电影在线观看| 美女尤物国产一区| 99综合电影在线视频| 欧美日韩另类国产亚洲欧美一级| 欧美电影免费观看高清完整版在线观看 | 青青草97国产精品免费观看无弹窗版| 激情五月激情综合网| 91香蕉国产在线观看软件| 91精品一区二区三区久久久久久 | 欧美日本一道本| 久久久久久久网| 亚洲愉拍自拍另类高清精品| 日本欧美韩国一区三区| proumb性欧美在线观看| 91精品国产综合久久久久久| 中文字幕免费观看一区| 三级久久三级久久久| 成人自拍视频在线| 88在线观看91蜜桃国自产| 欧美国产日韩a欧美在线观看 | 91在线观看高清| 日韩欧美一区电影| 亚洲精品成a人| 国产精选一区二区三区| 欧美日韩五月天| 国产精品无圣光一区二区| 美腿丝袜亚洲三区| 欧美性色aⅴ视频一区日韩精品| 久久久五月婷婷| 三级在线观看一区二区| 91老师片黄在线观看| 久久综合给合久久狠狠狠97色69| 亚洲国产另类精品专区| 69堂国产成人免费视频| 亚洲天堂a在线| 国产一区三区三区| 欧美一区二区三区免费观看视频| 中文字幕一区二区在线播放| 国产一区二区免费在线| 欧美一级久久久| 午夜一区二区三区视频| 99久久伊人网影院| 国产欧美日韩精品一区| 激情五月激情综合网| 欧美一卡二卡在线| 亚瑟在线精品视频| 在线观看欧美日本| 亚洲四区在线观看| 成人h版在线观看| 久久久不卡影院| 另类成人小视频在线| 欧美日韩国产另类不卡| 亚洲影院免费观看| 色欲综合视频天天天| 国产精品不卡在线| 不卡的av中国片| 国产精品三级视频| 成人av先锋影音| 国产精品久久久爽爽爽麻豆色哟哟| 国产一区二区三区精品欧美日韩一区二区三区 | 日本电影亚洲天堂一区| 亚洲欧美自拍偷拍| 粉嫩高潮美女一区二区三区 | 日韩国产欧美在线视频| 欧美偷拍一区二区| 亚洲人成人一区二区在线观看| 大白屁股一区二区视频| 久久精品在这里| 国产精品一二三四区| 久久综合狠狠综合| 国产美女精品一区二区三区| 欧美岛国在线观看| 黑人巨大精品欧美一区| 久久久一区二区三区| 国产米奇在线777精品观看| 久久久亚洲午夜电影| 国产激情一区二区三区| 国产色产综合色产在线视频| 国产成人av一区二区| 亚洲欧洲性图库| 精品成人一区二区三区四区| 狠狠狠色丁香婷婷综合久久五月| 国产日韩精品一区| www.亚洲色图| 亚洲黄色av一区| 欧美精品欧美精品系列| 久久精品国产精品亚洲综合| 久久麻豆一区二区| 99视频一区二区| 一区二区三区不卡视频| 欧美日韩电影在线播放| 麻豆视频观看网址久久| 日本一区二区成人| 色88888久久久久久影院按摩| 亚洲国产裸拍裸体视频在线观看乱了| 欧美精品高清视频| 精品亚洲国产成人av制服丝袜 | 日本网站在线观看一区二区三区| 日韩欧美国产一区二区在线播放 | 91精品国产综合久久久久久漫画 | 亚洲国产精品成人久久综合一区| 成人激情午夜影院| 亚洲一区二区成人在线观看| 日韩三级av在线播放| 国产精品夜夜爽| 亚洲女人的天堂| 91精品国产91热久久久做人人| 国产精品一级片| 亚洲精品成人精品456| 精品久久久久99| 99久久久久久| 美女视频网站黄色亚洲| 国产精品免费av| 4438x成人网最大色成网站| 国产白丝网站精品污在线入口| 一区二区三区视频在线看| 26uuu国产电影一区二区| 91麻豆福利精品推荐| 麻豆91免费观看| 一级特黄大欧美久久久| 欧美精品一区二区三区在线播放| 97精品久久久久中文字幕| 日本不卡不码高清免费观看| 成人欧美一区二区三区小说| 欧美一区二区三区在| 91蝌蚪porny成人天涯| 久久国产精品无码网站| 亚洲精品少妇30p| 国产日韩三级在线| 欧美精品久久一区二区三区| 成人精品国产一区二区4080| 日欧美一区二区| 中文字幕亚洲不卡| 精品国产乱码久久久久久浪潮| 色天天综合久久久久综合片| 国产麻豆精品视频| 日本成人在线电影网| 一二三四社区欧美黄| 国产精品五月天| 久久久久久9999| 日韩一级二级三级精品视频| 在线日韩av片| thepron国产精品| 国产不卡视频在线观看| 久久99精品国产.久久久久| 亚洲一二三区不卡| 最新日韩在线视频| 国产视频911| 久久久影视传媒| 精品人伦一区二区色婷婷| 欧美日韩一级黄| 色欧美88888久久久久久影院| 成人综合婷婷国产精品久久蜜臀 | 免播放器亚洲一区| 亚洲午夜久久久| 亚洲欧美视频在线观看| 国产精品毛片大码女人| 国产亚洲精久久久久久| 精品国产99国产精品| 日韩精品在线网站| 欧美成人免费网站| 欧美一级理论性理论a| 欧美一区二区精品久久911| 欧美日韩国产高清一区二区|