CreateVertexBuffer problem

Recommended Posts

boroboy00x    122
I am getting an exception error from this statement
gD3dDevice->CreateVertexBuffer( 12*sizeof(CUSTOMVERTEX),D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED,&m_vb, NULL);

the problem is that m_vb which is defined as a LPDIRECT3DVERTEXBUFFER9 is not getting set and I do not understand why. This is the first time I have encountered this problem because I have used gD3dDevice->CreateVertexBuffer in previous projects. any suggestions as to why this occuring would help. Thanks in advance

Share on other sites
The only part of that which should throw an exception is if gD3dDevice isn't setup yet.

Share on other sites
Geoffrey    612
Do CUSTOMVERTEX and D3DFVF_CUSTOMVERTEX correspond correctly? I sometimes make changes to my vertex structure but forget to update the FVF!

Share on other sites
Evil Steve    2017
Quote:
 Original post by NamethatnobodyelsetookThe only part of that which should throw an exception is if gD3dDevice isn't setup yet.
Seconded.

What exception do you get? Access violation I assume. Check the variable watch window for things like NULL pointers when you get the exception.
If its not an exception, and you mean that the function returns failure - do you have the debug runtimes installed with the debug output set to maximum? The debug runtimes will ALWAYS give you debug output if a function fails, and it'll probably tell you that one of the parameters is incorrect and why.

Share on other sites
Supernat02    604
You stated two mutually exclusive errors. Throwing an exception will halt the code and prevent it from continuing. For you to know that m_vb was remaining NULL, that code would have had to run properly. Which one did you mean? Did you mean that the function call failed because m_vb was not being set? Or did you mean that an excetion was thrown on this line and the code didn't go further?

If it was the later, it's because gD3dDevice is NULL, like the others said. If it was m_vb set to NULL, the only thing I can think of is that it doesn't like D3DPOOL_MANAGED for some reason. Try D3DPOOL_DEFAULT and see if it clears, then research it further if so.

Good luck,
Chris