Your code mostly looks correct; there are the usual small issues, such as you don't actually need to specify an FVF code in your CreateVertexBuffer call unless you'e using ProcessVertices, but they're not going to cause a crash.
One of two things has happened here.
Either v_buffer is NULL; i.e your call to CreateVertexBuffer failed. You should be checking the HRESULT from all D3D calls and responding accordingly (in this case you might display an appropriate error message and terminate the program). Running your program under the debugger you will be able to inspect the value of v_buffer and determine if this is the case.
Or 3 * sizeof (vertex) is not actually equal to sizeof (vertices); i.e when you memcpy the vertices you overrun the buffer. This is more likely to crash your program if you create your D3D device with D3DCREATE_SOFTWARE_VERTEXPROCESSING, but should be corrected in any case.
mhagainMember Since 06 Jun 2010
Offline Last Active Today, 09:03 AM
- Group Crossbones+
- Active Posts 3,341
- Profile Views 18,247
- Submitted Links 0
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
Outstanding Forum Member