For a school project I'm trying to draw lines on a screen, (constantly being updated), based on streaming data comming through the network. I've got the lines drawing but the problem I'm running into is that I cannot get the lines to be drawn in any color other than black. I'd like them to be drawn in green, cyan, yellow, etc based on the information received.
Can anyone tell me why I can not get the lines to be a color other than black or what I'm doing wrong? (My suspission is in the .FX file but I'm still new to DX10.) Below is some snipets of code I have, (in C++).
The Data Struct in the Header File:
struct Vertex
{
D3DXVECTOR3 Pos;
D3DCOLOR color;
};
Here is the code responsible for building the Input Layer:
// Define the input layout
D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,
D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, 0, 12,
D3D10_INPUT_PER_VERTEX_DATA, 0 }
};
UINT numElements = sizeof(layout)/sizeof(layout[0]);
// Create the input layout
D3D10_PASS_DESC PassDesc;
dxUtil->pTechnique->GetPassByIndex( 0 )->GetDesc( &PassDesc );
hr = pd3dDevice->CreateInputLayout( layout,
numElements,
PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize,
&(dxUtil->pVertexLayout) );
And finally, here is the *.FX file I'm using.
//-------------------------------------
// Test Effects File
//-------------------------------------
cbuffer cbNeverChanges
{
matrix View;
};
cbuffer cbChangeOnResize
{
matrix Projection;
};
cbuffer cbChangesEveryFrame
{
matrix World;
float4 vMeshColor;
};
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float4 Color : COLOR;
};
//-------------------------------------
// Vertex Shader
//-------------------------------------
PS_INPUT VS( VS_INPUT input )
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul( input.Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Color = input.Color;
return output;
}
//-------------------------------------
// Pixel Shader
//-------------------------------------
float4 PS( PS_INPUT input) : SV_Target
{
return input.Color;
}
//-------------------------------------
// Render
//-------------------------------------
technique10 Render
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
}
Hope this is enough, thanks in advance. I've been pulling my hair out trying to get something this simple to work, so anything would be appreciated. THanks again