bool Box::Init() { if (!D3DApp::Init()) { return false; } HRESULT hr = S_OK; do { hr = BuildGeometryBuffers(); if (FAILED(hr)) { break; } hr = BuildShaders(); if (FAILED(hr)) { break; } hr = BuildInputLayout(); } while (false); if (FAILED(hr)) { D3DHelper::ShowResultMessage(hr); return false; } return true; }
bool BoxApp::Init() { if(!D3DApp::Init()) return false; BuildGeometryBuffers(); BuildFX(); BuildVertexLayout(); blocks.push_back(new Block(md3dDevice, md3dImmediateContext, XMFLOAT3(-0.5f, -0.5f, -1.0f), XMFLOAT3(-0.5f, +0.5f, -1.0f), XMFLOAT3(+0.5f, +0.5f, -1.0f), XMFLOAT3(+0.5f, -0.5f, -1.0f))); /* blocks[0]->AddInstance(D3DXVECTOR3(-1.5f, -1.5f, 5.0f)); blocks[0]->AddInstance(D3DXVECTOR3(-1.5f, 1.5f, 5.0f)); blocks[0]->AddInstance(D3DXVECTOR3( 1.5f, -1.5f, 5.0f)); blocks[0]->AddInstance(D3DXVECTOR3( 1.5f, 1.5f, 5.0f)); */ figures.push_back(new Line(blocks[0])); figures.push_back(new Tank(blocks[0])); figures.push_back(new RightBlock(blocks[0])); figures.push_back(new LeftBlock(blocks[0])); figures.push_back(new Square(blocks[0])); figures[1]->move(D3DXVECTOR3(4.0f, 0.0f, 0.0f)); figures[2]->move(D3DXVECTOR3(-4.0f, 0.0f, 0.0f)); figures[3]->move(D3DXVECTOR3(0.0f, -3.0f, 0.0f)); figures[4]->move(D3DXVECTOR3(+2.0f, -2.0f, 0.0f)); return true; }
bool BoxApp::Init() { if(!D3DApp::Init()) return false; GetWindowRect(mhMainWnd,&rc); int midX= (rc.right+rc.left)/2; int midY= (rc.top+rc.bottom)/2; mLastMousePos.x = midX; mLastMousePos.y = midY; SetCursorPos(midX,midY); ClipCursor(&rc); w = new World(); w->Init(md3dDevice,this); cam = new Camera(); cam->Init(&mView, w->playerShip); //SetCapture(mhMainWnd); ShowCursor(false); BuildGeometryBuffers(); BuildFX(); BuildVertexLayout(); HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice,L"Assets/skybox.dds",0,0, &mCubeMapSRV,0)); CubeMap = mFX->GetVariableByName("gCubeMap")->AsShaderResource(); CubeMap->SetResource(mCubeMapSRV); return true; }
bool BoxApp::Init() { if(!D3DApp::Init()) return false; BuildGeometryBuffers(); BuildFX(); BuildVertexLayout(); return true; }
bool HillsApp::Init() { if(!D3DApp::Init()) return false; BuildGeometryBuffers(); BuildFX(); BuildVertexLayout(); BuildRasterState(); mObjectConstantBuffer.Initialize(md3dDevice); return true; }
bool CrateApp::Init() { if(!D3DApp::Init()) return false; // Must init Effects first since InputLayouts depend on shader signatures. Effects::InitAll(md3dDevice); InputLayouts::InitAll(md3dDevice); HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/WoodCrate02.dds", 0, 0, &mDiffuseMapSRV, 0 )); BuildGeometryBuffers(); return true; }
bool Shape::Init() { if ( !D3DApplication::Init() ) return false; BuildGeometryBuffers(); LoadFX(); BuildVertexLayout(); D3D11_RASTERIZER_DESC wireframeDesc; ZeroMemory(&wireframeDesc, sizeof(D3D11_RASTERIZER_DESC)); wireframeDesc.FillMode = D3D11_FILL_WIREFRAME; wireframeDesc.CullMode = D3D11_CULL_BACK; wireframeDesc.FrontCounterClockwise = false; wireframeDesc.DepthClipEnable = true; HR(mD3DDevice->CreateRasterizerState(&wireframeDesc, &mWireframeRS)); return true; }
bool BoxApp::Init() { if(!D3DApp::Init()) return false; D3D11_BLEND_DESC colorDesc = { 0 }; colorDesc.AlphaToCoverageEnable = false; colorDesc.IndependentBlendEnable = false; colorDesc.RenderTarget[0].BlendEnable = true; colorDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_COLOR; colorDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_BLEND_FACTOR; colorDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_SUBTRACT; colorDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; colorDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; colorDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; colorDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; HR(md3dDevice->CreateBlendState(&colorDesc, &ColorBlend)); D3D11_BLEND_DESC transparentDesc2 = { 0 }; transparentDesc2.AlphaToCoverageEnable = false; transparentDesc2.IndependentBlendEnable = false; transparentDesc2.RenderTarget[0].BlendEnable = true; transparentDesc2.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; transparentDesc2.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; transparentDesc2.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; transparentDesc2.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; transparentDesc2.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; transparentDesc2.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; transparentDesc2.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; HR(md3dDevice->CreateBlendState(&transparentDesc2, &AlphaBlend)); BuildGeometryBuffers(); BuildFX(); BuildVertexLayout(); return true; }
bool Ass3::Init() { if(!D3DApp::Init()) return false; BuildGeometryBuffers(); BuildFX(); BuildVertexLayout(); //define wireframe if (wframe) { D3D11_RASTERIZER_DESC wireframeDesc; ZeroMemory(&wireframeDesc, sizeof(D3D11_RASTERIZER_DESC)); wireframeDesc.FillMode = D3D11_FILL_WIREFRAME; wireframeDesc.CullMode = D3D11_CULL_BACK; wireframeDesc.FrontCounterClockwise = false; wireframeDesc.DepthClipEnable = true; HR(md3dDevice->CreateRasterizerState(&wireframeDesc, &mWireframeRS)); } return true; }
void Ass3::DrawScene() { timer--;; if (timer <= 0) { if (GetAsyncKeyState('Q') && sliceCount > 3) { sliceCount--; timer = 200; BuildGeometryBuffers(); } else if (GetAsyncKeyState('E') && sliceCount < 500) { sliceCount++; timer = 200; BuildGeometryBuffers(); } else if (GetAsyncKeyState('W') && cylinderHeight < 2) { cylinderHeight += 0.2f; timer = 200; BuildGeometryBuffers(); } else if (GetAsyncKeyState('S') && cylinderHeight > 0.4f) { cylinderHeight -= 0.2f; timer = 200; BuildGeometryBuffers(); } else if (GetAsyncKeyState('A') && cylinderRadius > 0.4f) { cylinderRadius -= 0.2f; timer = 200; BuildGeometryBuffers(); } else if (GetAsyncKeyState('D') && cylinderRadius < 2) { cylinderRadius += 0.2f; timer = 200; BuildGeometryBuffers(); } } md3dImmediateContext->ClearRenderTargetView(mRenderTargetView, reinterpret_cast<const float*>(&Colors::LightSteelBlue)); md3dImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0); md3dImmediateContext->IASetInputLayout(mInputLayout); md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); //apply wireframe resterizer state if (wframe) { md3dImmediateContext->RSSetState(mWireframeRS); } UINT stride = sizeof(Vertex); UINT offset = 0; md3dImmediateContext->IASetVertexBuffers(0, 1, &mBoxVB, &stride, &offset); md3dImmediateContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0); // Set constants XMMATRIX world = XMLoadFloat4x4(&mWorld); XMMATRIX view = XMLoadFloat4x4(&mView); XMMATRIX proj = XMLoadFloat4x4(&mProj); XMMATRIX worldViewProj = world*view*proj; mfxWorldViewProj->SetMatrix(reinterpret_cast<float*>(&worldViewProj)); D3DX11_TECHNIQUE_DESC techDesc; mTech->GetDesc( &techDesc ); for(UINT p = 0; p < techDesc.Passes; ++p) { mTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext); // indices for the mesh. md3dImmediateContext->DrawIndexed(indexCount, 0, 0); } HR(mSwapChain->Present(0, 0)); }