|
-
May 31st, 2012, 12:59 PM
#8
Re: Why is my triangle not displaying??
Yeah i have (N)
Code:
bool ShaderClass::ShaderInit(ID3D10Device* Device,HWND hWnd)
{
bool result = true;
result = InitializeShader(Device,hWnd,"TriangleShader.fx");
if(!result)
{
MessageBox(0,0,0,0);
return false;
}
return true;
}
bool ShaderClass::InitializeShader(ID3D10Device* Device, HWND hwnd, char* filename)
{
HRESULT result;
ID3D10Blob* errorMessage;
unsigned int numElements;
D3D10_PASS_DESC passDesc;
errorMessage = 0;
result = D3DX10CreateEffectFromFile(filename,0,0,"fx_4_0",D3D10_SHADER_ENABLE_STRICTNESS,0,Device,0,0,&m_effect,&errorMessage,0);
if(FAILED(result))
{
// If the shader failed to compile it should have writen something to the error message.
if(errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, filename);
}
// If there was nothing in the error message then it simply could not find the shader file itself.
else
{
MessageBox(hwnd, filename, "Missing Shader File", MB_OK);
}
return false;
}
m_technique = m_effect->GetTechniqueByName("ColorTechnique");
if(!m_technique)
{
return false;
}
D3D10_INPUT_ELEMENT_DESC InputLayout[] = {
{"POSITION",0,DXGI_FORMAT_R32G32B32_FLOAT,0,0,D3D10_INPUT_PER_VERTEX_DATA,0},
{"COLOR",0,DXGI_FORMAT_R32G32B32_FLOAT,0,D3D10_APPEND_ALIGNED_ELEMENT,D3D10_INPUT_PER_VERTEX_DATA,0},};
numElements = sizeof(InputLayout) / sizeof(InputLayout[0]);
m_technique->GetPassByIndex(0)->GetDesc(&passDesc);
result = Device->CreateInputLayout(InputLayout,numElements,passDesc.pIAInputSignature,passDesc.IAInputSignatureSize,&m_layout);
if(FAILED(result))
{
return false;
}
m_worldMatrixPtr = m_effect->GetVariableByName("worldMatrix")->AsMatrix();
m_viewMatrixPtr = m_effect->GetVariableByName("viewMatrix")->AsMatrix();
m_projectionMatrixPtr = m_effect->GetVariableByName("projectionMatrix")->AsMatrix();
return true;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|