I set the HLSL effect variable as follows in several places.
extern ID3D10EffectVectorVariable* pColour; pColour = pEffect->GetVariableByName("Colour")->AsVector(); pColour->SetFloatVector(temporaryLines[i].colour);
In one of the places that it is specified in the loop, each line in the temporaryLines vector has a D3DXCOLOR variable associated with it. The most unpleasant thing about this problem is that it really works in rare cases, but most of the time it does not. Are there any known issues with this code?
Here it works:
void GameObject::Draw(D3DMATRIX matView, D3DMATRIX matProjection) { device->IASetInputLayout(pVertexLayout); mesh.SetTopology();
It sometimes works here:
void BatchLineRenderer::RenderLines(D3DXMATRIX matView, D3DXMATRIX matProjection) { device->IASetInputLayout(pVertexLayout); device->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP); // select which vertex buffer and index buffer to display UINT stride = sizeof(LINE); UINT offset = 0; device->IASetVertexBuffers(0, 1, &pBuffer, &stride, &offset); device->IASetIndexBuffer(iBuffer, DXGI_FORMAT_R32_UINT, 0); allLines = temporaryLines.size(); for(int i = 0; i < allLines; i++) { pColour->SetFloatVector(temporaryLines[i].colour); // in the line loop too? // combine the matrices and render D3DXMATRIX matFinal = temporaryLines[i].scale * temporaryLines[i].rotation * temporaryLines[i].position * matView * matProjection; pTransform->SetMatrix(&matFinal._11); pRotation->SetMatrix(&temporaryLines[i].rotation._11); // set the rotation matrix in the effect pPass->Apply(0); device->DrawIndexed(2, 0, 0); } temporaryLines.clear(); }
effect file:
float4x4 Transform;
source share