MirrorDemo::MirrorDemo(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP) : D3DApp(hInstance, winCaption, devType, requestedVP) { if(!checkDeviceCaps()) { MessageBox(0, "checkDeviceCaps() Failed", 0, 0); PostQuitMessage(0); } InitAllVertexDeclarations(); mGfxStats = new GfxStats(); mCameraRadius = 15.0f; mCameraRotationY = 1.4f * D3DX_PI; mCameraHeight = 5.0f; mLightVecW = D3DXVECTOR3(0.0, 0.707f, -0.707f); mDiffuseLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mAmbientLight = D3DXCOLOR(0.6f, 0.6f, 0.6f, 1.0f); mSpecularLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mWhiteMtrl.ambient = WHITE; mWhiteMtrl.diffuse = WHITE; mWhiteMtrl.spec = WHITE * 0.8f; mWhiteMtrl.specPower = 16.0f; D3DXMatrixIdentity(&mRoomWorld); D3DXMatrixTranslation(&mTeapotWorld, 0.0f, 3.0f, -6.0f); HR(D3DXCreateTextureFromFile(gd3dDevice, "checkboard.dds", &mFloorTex)); HR(D3DXCreateTextureFromFile(gd3dDevice, "brick2.dds", &mWallTex)); HR(D3DXCreateTextureFromFile(gd3dDevice, "ice.dds", &mMirrorTex)); HR(D3DXCreateTextureFromFile(gd3dDevice, "brick1.dds", &mTeapotTex)); HR(D3DXCreateTeapot(gd3dDevice, &mTeapot, 0)); // Generate texture coordinates for the teapot. genSphericalTexCoords(); // Room geometry count. mGfxStats->addVertices(24); mGfxStats->addTriangles(8); // We draw the teapot twice--once normal and once reflected. mGfxStats->addVertices(mTeapot->GetNumVertices() * 2); mGfxStats->addTriangles(mTeapot->GetNumFaces() * 2); buildRoomGeometry(); buildFX(); onResetDevice(); }
StencilMirrorDemo::StencilMirrorDemo(HINSTANCE hInstance, std::wstring winCaption) : D3DApp(hInstance, winCaption) { InitAllVertexDeclarations(); mGfxStats = new GfxStats(); mCameraRadius = 15.0f; mCameraRotationY = 1.4f * D3DX_PI; mCameraHeight = 5.0f; mLightVecW = D3DXVECTOR3(0.0f, 0.707f, -0.707f); mDiffuseLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mAmbientLight = D3DXCOLOR(0.6f, 0.6f, 0.6f, 1.0f); mSpecularLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mWhiteMtrl.ambient = WHITE; mWhiteMtrl.diffuse = WHITE; mWhiteMtrl.spec = WHITE * 0.8f; mWhiteMtrl.specPower = 16.0f; D3DXMatrixIdentity(&mRoomWorld); D3DXMatrixTranslation(&mTeapotWorld, 0.0f, 3.0f, -6.0f); HR(D3DXCreateTextureFromFile(gd3dDevice, L"../src/chap13/StencilMirror/checkboard.dds", &mFloorTex)); HR(D3DXCreateTextureFromFile(gd3dDevice, L"../src/chap13/StencilMirror/brick2.dds", &mWallTex)); HR(D3DXCreateTextureFromFile(gd3dDevice, L"../src/chap13/StencilMirror/ice.dds", &mMirrorTex)); HR(D3DXCreateTextureFromFile(gd3dDevice, L"../src/chap13/StencilMirror/brick1.dds", &mTeapotTex)); HR(D3DXCreateTeapot(gd3dDevice, &mTeapot, 0)); genSphericalTexCoords(); mGfxStats->addVertices(24); mGfxStats->addTriangles(8); mGfxStats->addVertices(mTeapot->GetNumVertices()*2); mGfxStats->addTriangles(mTeapot->GetNumFaces()*2); buildRoomGeometry(); buildFX(); onResetDevice(); }