可以在E:\Program Files\Nebula2 SDK\build\vstudio8目录找到编译的项目。
其中:Nebula2.sln是源代码
tutorials.sln是那些小例子
打开tutorials.sln(我用的是VS2008),找到你要运行的那个项目(可以在SDK找对应的例子),设置一下包含路径和库(lib)路径,就可以编译了,通常编译过程会很顺利,但是我这里运行的时候,出现了 :
nD3D9Shader:failed to load fx file 'h:/games/Nebula2SDK/data/shaders/fixed/shape.fx' with:
memory(34,9):ID3DXEffectCompiler:Error in type checking
memory(55,9):ID3DXEffectCompiler:Error in type checking
memory(67,9):ID3DXEffectCompiler:Error in type checking
ID3DXEffectCompiler:There was an error initializing the compiler
在http://nebuladevice.cubik.org/forum/index.php?topic=41.msg401#msg401可以找到解决办法,其中有效的一条是在nd3d9shader_main.cc
中设置编译标识为
D3DXSHADER_USE_LEGACY_D3DX9_31_DLL
找到方法bool nD3D9Shader::LoadResource()
/**
Load D3DX effects file.
*/
bool
nD3D9Shader::LoadResource()
{
n_assert(!this->IsLoaded());
n_assert(0 == this->effect);
HRESULT hr;
IDirect3DDevice9* d3d9Dev = this->refGfxServer->d3d9Device;
n_assert(d3d9Dev);
// mangle path name
nString filename = this->GetFilename();
nString mangledPath = nFileServer2::Instance()->ManglePath(filename.Get());
//load fx file
nFile* file = nFileServer2::Instance()->NewFileObject();
// open the file
if (!file->Open(mangledPath.Get(), "r"))
{
n_error("nD3D9Shader: could not load shader file '%s'!", mangledPath.Get());
return false;
}
// get size of file
int fileSize = file->GetSize();
// allocate data for file and read it
void* buffer = n_malloc(fileSize);
n_assert(buffer);
file->Read(buffer, fileSize);
file->Close();
file->Release();
ID3DXBuffer* errorBuffer = 0;
#if N_D3D9_DEBUG
DWORD compileFlags = D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION;
#else
DWORD compileFlags = D3DXSHADER_USE_LEGACY_D3DX9_31_DLL;
#endif
// create include file handler
nString shaderPath(mangledPath.Get());
nD3D9ShaderInclude includeHandler(shaderPath.ExtractDirName());
// get global effect pool from gfx server
ID3DXEffectPool* effectPool = this->refGfxServer->GetEffectPool();
n_assert(effectPool);
// create effect
hr = D3DXCreateEffect(
d3d9Dev, // pDevice
buffer, // pFileData
fileSize, // DataSize
NULL, // pDefines
&includeHandler, // pInclude
compileFlags, // Flags
effectPool, // pPool
&(this->effect), // ppEffect
&errorBuffer); // ppCompilationErrors
n_free(buffer);
if (FAILED(hr))
{
n_error("nD3D9Shader: failed to load fx file '%s' with:\n\n%s\n",
mangledPath.Get(),
errorBuffer ? errorBuffer->GetBufferPointer() : "No D3DX error message.");
if (errorBuffer)
{
errorBuffer->Release();
}
return false;
}
n_assert(this->effect);
// success
this->hasBeenValidated = false;
this->didNotValidate = false;
this->SetState(Valid);
// validate the effect
this->ValidateEffect();
return true;
}
注意按照红色的地方进行修改即可,然后就回看到运行结果:
posted on 2008-07-19 21:27
littlegai 阅读(556)
评论(0) 编辑 收藏 引用 所属分类:
我的读书笔记