Skip to main content
gamedev.net
🔒 Locked

DirectX10 Sample Tutorial 2

Started by CharismaTubagusSetyobudhi Aug 26, 2011 at 2:03 PM 5 replies 2.9k views
Original Post
CharismaTubagusSetyobudhi
CharismaTubagusSetyobudhi
Hi,

I just switched my development environment to Windows XP 32 bit using Visual C++ 2008 Express and Visual Studio 2010 Professional. When I want to test DX10 Sample tutorial 2, it says it cannot load Tutorial02.fx.
But, when I used Windows 7 with visual studio 2008 / 2010, it can load the effect file. I haven't changed the code from the default sample code.



hr = D3DX10CreateEffectFromFile( L"Tutorial02.fx", NULL, NULL, "fx_4_0", dwShaderFlags, 0,
g_pd3dDevice, NULL, NULL, &g_pEffect, NULL, NULL );
if( FAILED( hr ) )
{
MessageBox( NULL, L"The FX file cannot be located. Please run this executable from the directory that contains the FX file.", L"Error", MB_OK );
return hr;
}




I am using DXSDK June 2011 and DXSDK August 2007. Both have the same issue. Any help is very much appreciated.

Thanksrolleyes.gif
smasherprog
smasherprog

Hi,

I just switched my development environment to Windows XP 32 bit using Visual C++ 2008 Express and Visual Studio 2010 Professional. When I want to test DX10 Sample tutorial 2, it says it cannot load Tutorial02.fx.
But, when I used Windows 7 with visual studio 2008 / 2010, it can load the effect file. I haven't changed the code from the default sample code.



hr = D3DX10CreateEffectFromFile( L"Tutorial02.fx", NULL, NULL, "fx_4_0", dwShaderFlags, 0,
g_pd3dDevice, NULL, NULL, &g_pEffect, NULL, NULL );
if( FAILED( hr ) )
{
MessageBox( NULL, L"The FX file cannot be located. Please run this executable from the directory that contains the FX file.", L"Error", MB_OK );
return hr;
}




I am using DXSDK June 2011 and DXSDK August 2007. Both have the same issue. Any help is very much appreciated.

Thanksrolleyes.gif

Try doing a manual open before hand like this

ifstream file(fname.c_str());
if(!file){
std::string test ="Cannot Find File " + fname;
MessageBoxA(0, test.c_str(), "Error Opening File", 0);
}
file.close();

Also, just because
if( FAILED( hr ) ) is true, does not mean the file could not be found there are other errors as well that could have occurred,

Try using some form of a macro to wrap around all calls that return an HRESULT to examine the exact error. Here is what I use



#if defined(OUTPUT_DEBUG)
#pragma comment(lib, "dxerr") // needed for DXGetErrorStringA
#ifndef HR
#define HR(x){ \
HRESULT hr = (x); \
if(FAILED(hr)){ \
std::cout<<"An error occured on line"<<(DWORD)__LINE__<<" in the file "<<__FILE__<<std::endl; \
std::cout<<DXGetErrorStringA(hr)<<std::endl<<DXGetErrorDescriptionA(hr)<<std::endl; \
} \
}
#endif
#else
#ifndef HR
#define HR(x) (x)
#endif
#endif
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
CharismaTubagusSetyobudhi
CharismaTubagusSetyobudhi
Actually why do i need to create macro, i just need to put these lines inside FAILED(hr), right?


std::cout<<"An error occured on line"<<(DWORD)__LINE__<<" in the file "<<__FILE__<<std::endl; \
std::cout<<DXGetErrorStringA(hr)<<std::endl<<DXGetErrorDescriptionA(hr)<<std::endl; \


Anyway, the file exists but, I got the following errors:
DXGetErrorDescriptionA returned 0x005066ac "An undetermined error occurred"
DXGetErrorStringA returned 0x004fdb0c "E_FAIL"

My suspect is that DirectX10 is not really supported in Windows XP. But, I have already installed DX10 patches for XP though.
smasherprog
smasherprog
Well, not really. The point of the macro is to be able to use it everywhere. HRESULTs are returned in alot of functions calls in direct x. So, the macro can be wrapped around all calls that return an HRESULT and you get cleaner code then.
You are right about directx 10 not being supported in windows XP -- it isn't.

You have to stick with directx 9 unfortunately.

Which is cleaner to you?


hr = D3DX10CreateEffectFromFile( L"Tutorial02.fx", NULL, NULL, "fx_4_0", dwShaderFlags, 0,
g_pd3dDevice, NULL, NULL, &g_pEffect, NULL, NULL );
if( FAILED( hr ) )
{
MessageBox( NULL, L"The FX file cannot be located. Please run this executable from the directory that contains the FX file.", L"Error", MB_OK );
return hr;
}

or
HR(D3DX10CreateEffectFromFile( L"Tutorial02.fx", NULL, NULL, "fx_4_0", dwShaderFlags, 0,
g_pd3dDevice, NULL, NULL, &g_pEffect, NULL, NULL ));


Another benefit is that you can make it so the macro only does its checks in debug mode. Then in release mode, the macro does nothing, which will improve your application speed.
In the macro I posted if
OUTPUT_DEBUG

is not defined, the macro actually does nothing at all.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
yckx
yckx
AFAIK DirectX 10 is not supported on XP—you need Vista or Win7. I've seen references to methods used to get DX10 working on XP, but I was under the impression that they were all hacks not endorsed by Microsoft.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.