Your problem lies in this
#define D3DFVF_CUSTOMVERTEX(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )This is not a properly defined FVF.
SetFVF takes a DWORD as it's parameter not a define.//From the DX SDK documentation HRESULT SetFVF( [in] DWORD FVF );And if you would look at the examples they use in the documentation you see that they all use "const DWORD" variables to define the custom vertex format.
The better way of doing this is to use a vertexdeclaration, which will allow you to use shaders properly as well and will make the switch from DX9 to higher much easier to achieve as the fixed function pipeline is dead.
I changed it to const DWORD D3DFVF_CUSTOMVERTEX = (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1);
but it still gives the same error.I actualy used #define before,because that's how I saw it in msdn.( http://msdn.microsof...9(v=vs.85).aspx )My CUSTOMVERTEX pretty much matches the FVF,doesn't it?
struct CUSTOMVERTEX
{
D3DXVECTOR3 p; //D3DFVF_XYZ
D3DXVECTOR3 n; //D3DFVF_NORMAL
float tu,tv; //D3DFVF_TEX1
};What happens if you put assert(
_CrtCheckMemory( )
); right before the SetFVF() call?
I attached an image of the result.
The second square of code(where the error occurs in the green code) is in mlock.c
[attachment=8553:error.png]
I also used windows symbols to get a more detailed stack heap,but I can't really figure out why setting a new vertex declaration corrupts the heap.
[attachment=8558:Call Stack.png]