Jump to content
  • Advertisement
Sign in to follow this  
Arkanoid

Problem with compile shader from file

This topic is 2400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 );

Share this post


Link to post
Share on other sites
Advertisement

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()));

Share this post


Link to post
Share on other sites
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....

Share this post


Link to post
Share on other sites
oops, replace WCHAR with char. BTW OutputDebugString will output that data to the Visual Studio output window not in your app

Share this post


Link to post
Share on other sites
you better use shader shader compiler (fxc) to compile that shader/to find errors in your shader

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!