Пример #1
0
/**
 * @fn Render()
 *
 * @brief Renders the quad
 */
void CDXQuad::Render()
{
    // Get the output device
    ID3D10Device *pDev = DXUTGetD3D10Device();
    // Set the output topology
    pDev->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
    // Set the vertex buffer and input layout, then render
    UINT offset = 0;
    pDev->IASetVertexBuffers(0, 1, &m_pVBuff, (UINT*)&m_vertexSize, &offset);
    pDev->Draw(4, 0);
}
Пример #2
0
bool CDX10Shader::Execute(std::vector<ID3D10RenderTargetView*> *vecRT, unsigned int vertexIndexStep)
{
	ID3D10Device* pDevice = m_rendererSystem->GetDevice();
	ID3D10RenderTargetView* oldRTV = 0;
	ID3D10DepthStencilView* oldDSV = 0;

	if (vecRT!=NULL && !vecRT->empty())
		pDevice->OMGetRenderTargets(1, &oldRTV, &oldDSV);

	D3D10_TECHNIQUE_DESC techDesc;
	m_effect.GetTechnique()->GetDesc(&techDesc);
	unsigned int cPasses = techDesc.Passes;

	unsigned int stride = m_vertsize;
	unsigned int offset = 0;
	ID3D10Buffer* buffer = m_vb.GetVertexBuffer();
	pDevice->IASetVertexBuffers(0, 1, &buffer, &stride, &offset);
	if (m_vb.m_type == D3DVertexBuffer::INDEXED_BUFFER) 
	{
		pDevice->IASetIndexBuffer(m_vb.GetIndexBuffer(), DXGI_FORMAT_R32_UINT, 0);
		pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
	} else 
	{
		pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
	}

	pDevice->IASetInputLayout(m_inputLayout);
	for (unsigned int iPass = 0; iPass < cPasses; iPass++)
	{
		if (!m_effect.BeginPass(iPass)) 
		{
			LOGERR("Failed to apply and begin pass %u in technique %s", iPass, techDesc.Name);
			break;
		}

		if (vecRT != NULL && vecRT->size() > iPass)
			pDevice->OMSetRenderTargets(1, &(*vecRT)[iPass], NULL);

		if (m_vb.m_type == D3DVertexBuffer::INDEXED_BUFFER && m_primitivesCount > 0) 
			for (int i = 0; i < m_primitivesCount; i++) 
				pDevice->DrawIndexed(m_indexCount, 0, iPass*vertexIndexStep+i*((m_vbsize/m_vertsize)/m_primitivesCount));
		else
			pDevice->Draw(m_primitivesCount, iPass*vertexIndexStep);
	}

	if (oldRTV != 0) 
	{
		if (oldDSV != 0) 
		{
			pDevice->OMSetRenderTargets(1, &oldRTV, oldDSV);
			oldRTV->Release();
			oldRTV->Release();
		} else 
		{
			pDevice->OMSetRenderTargets(1, &oldRTV, NULL);
			oldRTV->Release();
		}
	}
	pDevice->RSSetViewports(1, &m_rendererSystem->GetViewPort());
	return true;
}