d3dxGlobal.h中下列位置出错:
// Custom allocator that uses CDataBlockStore
// The trick is that we never free, so we don't have to keep as much state around
// Use PRIVATENEW in CEffectLoader
static void* __cdecl operator new(size_t s, CDataBlockStore &pAllocator)
{
D3DXASSERT(s <= 0xffffffff);
return pAllocator.Allocate((UINT)s);
}
static void __cdecl operator delete(void* p, CDataBlockStore &pAllocator)
{
}
与VS的说明是差不多的,是因为新版的VS禁止全局static重载new/delete,只要把static [inline]去掉就可以了;
但是在Effect框架里,new 和delete都是在头文件中定义,是定义不是声明,改完之后框架是能编译通过,但是使用框架的时候会出现链接错误,需要把定义改为声明,然后在Cpp文件中定义:
//**************d3dxGlobal.h*****************
// Custom allocator that uses CDataBlockStore
// The trick is that we never free, so we don't have to keep as much state around
// Use PRIVATENEW in CEffectLoader
//static
extern void* __cdecl operator new(size_t s, CDataBlockStore &pAllocator);
//static
extern void __cdecl operator delete(void* p, CDataBlockStore &pAllocator);
//**************d3dxGlobal.cpp***********************
// Custom allocator that uses CDataBlockStore
// The trick is that we never free, so we don't have to keep as much state around
// Use PRIVATENEW in CEffectLoader
//
void* __cdecl operator new(size_t s, CDataBlockStore &pAllocator)
{
D3DXASSERT(s <= 0xffffffff);
return pAllocator.Allocate((UINT)s);
}
//
void __cdecl operator delete(void* p, CDataBlockStore &pAllocator)
{
}