Exemple #1
0
Effect::Effect(ID3D10Device* device, const std::string& filename) :
	mDevice(device),
	mEffect(NULL)
{
	if (!LoadEffectFile(filename))
	{
		throw std::runtime_error("Failed to load and compile effect file: " + filename);
	}
}
//-----------------------------------------------------------------------------
// Name: wWinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, INT)
{
	UNREFERENCED_PARAMETER(hInst);

	// Register the window class
	WNDCLASSEX wc =
	{
		sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
		GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
		"Shader Tutorial", NULL
	};
	RegisterClassEx(&wc);

	// Create the application's window
	HWND hWnd = CreateWindow("Shader Tutorial", "Shader Tutorial 00",
		WS_OVERLAPPEDWINDOW, 100, 100, 500, 500,
		NULL, NULL, wc.hInstance, NULL);

	// Direct3Dを初期化。
	InitD3D(hWnd);
	//モデルを初期化。
	InitGeometry();
	//エフェクトファイルのロード。
	LoadEffectFile();
	
	ZeroMemory( g_diffuseLightDirection, sizeof(g_diffuseLightDirection) );
	ZeroMemory( g_diffuseLightColor, sizeof(g_diffuseLightColor) );
			
	D3DXMatrixIdentity(&g_worldMatrix);
	D3DXMatrixIdentity(&g_rotationMatrix);
	//カメラの初期化。
	camera.Init();
	// Show the window
	ShowWindow(hWnd, SW_SHOWDEFAULT);
	UpdateWindow(hWnd);

	// ゲームループ
	MSG msg;
	ZeroMemory(&msg, sizeof(msg));
	while (msg.message != WM_QUIT)
	{
		if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else {
			Update();
			Render();
		}
	}
	

	UnregisterClass("Shader Tutorial", wc.hInstance);
	return 0;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : device - 
// Output : static void
//-----------------------------------------------------------------------------
static void LoadEffectFiles( LPDIRECTINPUTDEVICE8 device )
{
	int c = ARRAYSIZE( g_EffectMap );
	for ( int i = 0; i < c; ++i )
	{
		EffectMap_t& map = g_EffectMap[ i ];

		LoadEffectFile( device, map );
	}
}