Advertisement

Problem with compile shader from file

Started by March 12, 2012 03:21 PM
37 comments, last by Asesh 12 years, 7 months ago
Hi,

i wanna to add to my project shaders, but always have a problem here:

hr =D3DXCompileShaderFromFile( L"vertex.vsh", NULL, NULL,
"main", D3DXGetVertexShaderProfile(g_pd3dDevice),dwFlags, &Code, &BufferErrors,
&ConstantTable )


i cannot understand why? here is the part of my shader code:

LPDIRECT3DVERTEXDECLARATION9 VertexDeclaration = NULL;
g_pd3dDevice->CreateVertexDeclaration( declaration, &VertexDeclaration );

g_pd3dDevice->SetVertexDeclaration( VertexDeclaration );
HRESULT hr;
DWORD dwFlags = 0;
dwFlags |= D3DXSHADER_SKIPOPTIMIZATION;
hr =D3DXCompileShaderFromFile( L"vertex.vsh", NULL, NULL,
"main", D3DXGetVertexShaderProfile(g_pd3dDevice),dwFlags, &Code, &BufferErrors,
&ConstantTable );
if(FAILED(hr))
{
MessageBox( NULL, LPCWSTR(BufferErrors), L"Meshes.exe", MB_OK );
}

g_pd3dDevice->CreateVertexShader( (DWORD*)Code->GetBufferPointer(),&VertexShader );

did you mean [color=#000000][size=2]D3DXCompileShaderFromFile fails? you can see what went wrong by calling: ::OutputDebugString(reinterpret_cast<WCHAR *>([color=#660066][size=2]BufferErrors->GetBufferPointer()));

Advertisement
if(FAILED(hr))
{
::OutputDebugString(reinterpret_cast<WCHAR *>(BufferErrors->GetBufferPointer()));
}
like that?...no it didn't show anything...

or like this:
if(FAILED(hr))
{
//::OutputDebugString(reinterpret_cast<WCHAR *>(BufferErrors->GetBufferPointer()));
MessageBox( NULL,reinterpret_cast<WCHAR *>(BufferErrors->GetBufferPointer()), L"Meshes.exe", MB_OK );
}
then it shows me many ?hinese characters...i cannot understand ?hinese....
I don't think BufferErrors is WCHAR. I'm pretty sure it's ordinary char.
oops, replace WCHAR with char. BTW OutputDebugString will output that data to the Visual Studio output window not in your app
you better use shader shader compiler (fxc) to compile that shader/to find errors in your shader
Advertisement
oh...sorry can you please say more correctly what function i need to use? And how can i using it understand what error i have?
Post the error message.
964b3f33308d.jpg
i cannot read it)...i don't know how to see message in English.
change the project from unicode to multibyte..
:)

This topic is closed to new replies.

Advertisement