BOOL cApp::Init() { // Initialize the graphics device and set display mode m_Graphics.Init(); m_Graphics.SetMode(GethWnd(), TRUE, TRUE); // Initialize input and input devices m_Input.Init(GethWnd(), GethInst()); m_Keyboard.Create(&m_Input, KEYBOARD); m_Mouse.Create(&m_Input, MOUSE, TRUE); //-------------------------------------------------- // Add your codes below... //-------------------------------------------------- m_pMesh = new cSkinMesh; m_pMesh->OnCreate(m_Graphics.GetDeviceCOM(), L"tiny_4anim.x"); // 构造世界变换 m_World.Rotate(-D3DX_PI/2, D3DX_PI, 0); m_World.Move(0, -250.0f, 0); m_Graphics.SetWorldPosition(&m_World); // 初始摄像机位置 m_XPos = 0;m_YPos = 0;m_ZPos = -1000.0f; // 设置投影矩阵 m_Graphics.SetPerspective(D3DX_PI/4, m_Width/m_Height, 1.0f, 2000.0f); // 设置灯光 m_Light.SetType(D3DLIGHT_DIRECTIONAL); m_Light.SetDiffuseColor(255, 255, 255); m_Light.Point(0, 0, 0, 0, -1.0f, 1.0f); m_Graphics.SetLight(0, &m_Light); m_Graphics.EnableLight(0, TRUE); m_Graphics.EnableLighting(TRUE); //设置环境光 m_Graphics.GetDeviceCOM()->SetRenderState( D3DRS_AMBIENT, 0x00505050); return TRUE; }
BOOL cApp::Init() { HRESULT hr = S_OK; // Initialize the graphics device and set display mode m_Graphics.Init(); m_Graphics.SetMode(GethWnd(), TRUE, TRUE); // Initialize input and input devices m_Input.Init(GethWnd(), GethInst()); m_Keyboard.Create(&m_Input, KEYBOARD); m_Mouse.Create(&m_Input, MOUSE, TRUE); m_pMesh = new cAnimMesh(); V_RETURN(m_pMesh->OnCreate(m_Graphics.GetDeviceCOM(), L"emr.x")); // 构造世界变换 m_World.Rotate(-D3DX_PI/2, 0, 0); m_World.Move(0, -8.0f, 0); m_Graphics.SetWorldPosition(&m_World); // 初始摄像机位置 m_XPos = 0;m_YPos = 0;m_ZPos = -50.0f; // 设置投影矩阵 m_Graphics.SetPerspective(D3DX_PI/4, (float)(m_Width / m_Height), 1.0f, 100.0f); // 设置灯光 m_Light.SetType(D3DLIGHT_DIRECTIONAL); m_Light.SetDiffuseColor(255, 255, 255); m_Light.Point(0, 0, 0, 0, -1.0f, 1.0f); m_Graphics.SetLight(0, &m_Light); m_Graphics.EnableLight(0, TRUE); m_Graphics.EnableLighting(TRUE); //设置环境光 m_Graphics.GetDeviceCOM()->SetRenderState( D3DRS_AMBIENT, 0x00ffffff); return TRUE; }
BOOL Init(){ m_CGraphics.Init(); m_CGraphics.SetMode(GethWnd(), TRUE, TRUE, 640, 480, 16); //m_CGraphics.SetMode(GethWnd(), FALSE, FALSE); m_CGraphics.EnableAlphaBlending(FALSE); m_CGraphics.EnableAlphaTesting(FALSE); m_CGraphics.SetPerspective(D3DX_PI/4, 1.3333f, 1.0f, 10000.0f); m_mesh = new CDXMesh(m_CGraphics.GetD3DDevice()); m_mesh->LoadMesh("./strider/lkj.x","./strider/"); m_pFlexCamera = new CCamera(); return TRUE; }
// ---------------------------------------------------------------------------------------------------- // Init(): Create a IDirectInput8 // ---------------------------------------------------------------------------------------------------- BOOL Input::Init(HWND hWnd, HINSTANCE hInst){ // Free a prior Init Shutdown(); // Record parent Window handle i_hWnd = hWnd; // Create a DirectInput interface if(FAILED(DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&i_DI, NULL))){ MessageBox(GethWnd(), "Error 1", "Input::Init()", MB_OK | MB_ICONSTOP); return FALSE; } // Return a success return TRUE; }
/* ----------------------------------------- ・Exec() : 実行関数 ------------------------------------------ */ void CSceneTitle::Exec() { MoveCursor(); // カーソル移動処理 // もしエンターが押されたらシーンを変更 if(CDIKeyBoard::GetKeyPrs( DIK_RETURN )) { switch( m_nowSelect ) { case Start: CGame::ChangeScene( Scene_GAMEMAIN ); break; case Option: break; case End: PostMessage(GethWnd(), WM_QUIT, 0, 0); // メインループを抜けて終了 break; } //return; } Draw(); // 描画処理 }