Exemple #1
0
    void Effect::SetParam(const string& name, const void* data, U32 offset, U32 count) {
        auto it = structVars.find(name);
        _ASSERT(it != structVars.end());

        ID3DX11EffectVariable* var = it->second;
        DXCall(var->SetRawValue(data, offset, count));
    }
Exemple #2
0
	void D3D11EffectMaterial::SetCBByName(const char* szName, void* buffer, int size)
	{
		ID3DX11EffectVariable* pVal = m_pEffect->GetVariableByName(szName);
		if(pVal)
		{
			pVal->SetRawValue(buffer, 0, size);
			//ID3D11Buffer* pD3DBuffer = nullptr;
			//pVal->AsConstantBuffer()->GetConstantBuffer(&pD3DBuffer);
			//pVal->AsConstantBuffer()->SetConstantBuffer(((D3D11Buffer*)pCB.get())->GetD3D11BufferInterface());

			//D3D11_MAPPED_SUBRESOURCE desc;
			//m_pContext->Map(pD3DBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &desc);

			//memcpy(desc.pData, buffer, size);

			//m_pContext->Unmap(pD3DBuffer, 0);
		}


	}
Exemple #3
0
void LightDemo::DrawScene()
{
    m_dxImmediateContext->ClearRenderTargetView(m_renderTargetView.Get(), reinterpret_cast<const float*>(&oc::Colors::LightSteelBlue));
    m_dxImmediateContext->ClearDepthStencilView(m_depthStencilView.Get(), D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0);

	m_dxImmediateContext->IASetInputLayout(m_inputLayout.Get());
    m_dxImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	uint32 stride = sizeof(Vertex);
    uint32 offset = 0;

	// Set constants
	XMMATRIX view  = XMLoadFloat4x4(&m_view);
	XMMATRIX proj  = XMLoadFloat4x4(&m_proj);
	XMMATRIX viewProj  = view*proj;

    // Set per frame constants.
	m_fxDirLight->SetRawValue(&m_dirLight, 0, sizeof(m_dirLight));
	m_fxPointLight->SetRawValue(&m_pointLight, 0, sizeof(m_pointLight));
	m_fxSpotLight->SetRawValue(&m_spotLight, 0, sizeof(m_spotLight));
	m_fxEyePosW->SetRawValue(&m_camPosition, 0, sizeof(m_camPosition));
 
    D3DX11_TECHNIQUE_DESC techDesc;
    m_tech->GetDesc(&techDesc);
    for(uint32 p = 0; p < techDesc.Passes; ++p)
    {
        //Draw the land
        m_dxImmediateContext->IASetVertexBuffers(0, 1, m_landVB.GetAddressOf(), &stride, &offset);
        m_dxImmediateContext->IASetIndexBuffer(m_landIB.Get(), DXGI_FORMAT_R32_UINT, 0);

        //Set per object constants
        XMMATRIX world = XMLoadFloat4x4(&m_landWorld);
        XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world);
        XMMATRIX worldViewProj = world*viewProj;

		m_fxWorld->SetMatrix(reinterpret_cast<float*>(&world));
		m_fxWorldInvTranspose->SetMatrix(reinterpret_cast<float*>(&worldInvTranspose));
		m_fxWorldViewProj->SetMatrix(reinterpret_cast<float*>(&worldViewProj));
        m_fxMaterial->SetRawValue(&m_landMat, 0, sizeof(m_landMat));

        m_tech->GetPassByIndex(p)->Apply(0, m_dxImmediateContext.Get());
        m_dxImmediateContext->DrawIndexed(m_landIndexCount, 0, 0);

        //Draw the wave
        m_dxImmediateContext->IASetVertexBuffers(0, 1, m_wavesVB.GetAddressOf(), &stride, &offset);
        m_dxImmediateContext->IASetIndexBuffer(m_wavesIB.Get(), DXGI_FORMAT_R32_UINT, 0);

        world = XMLoadFloat4x4(&m_wavesWorld);
        worldInvTranspose = MathHelper::InverseTranspose(world);
        worldViewProj = world*viewProj;

		m_fxWorld->SetMatrix(reinterpret_cast<float*>(&world));
		m_fxWorldInvTranspose->SetMatrix(reinterpret_cast<float*>(&worldInvTranspose));
		m_fxWorldViewProj->SetMatrix(reinterpret_cast<float*>(&worldViewProj));
        m_fxMaterial->SetRawValue(&m_wavesMat, 0, sizeof(m_wavesMat));

        m_tech->GetPassByIndex(p)->Apply(0, m_dxImmediateContext.Get());
        m_dxImmediateContext->DrawIndexed(3*m_waves.TriangleCount(), 0, 0);
    }

	HR(m_swapChain->Present(0, 0));
}