Archived

This topic is now archived and is closed to further replies.

Slave

Error when creating a vertex buffer

Recommended Posts

When i try to create a vertex buffer then i get an error. My code is like this. if(FAILED(m_pD3DDevice->CreateVertexBuffer( nrOfVertices*(sizeof(MY_CUSTOM_VERTEX)), D3DUSAGE_WRITEONLY, MY_CUSTOM_VERTEX_FVF, D3DPOOL_DEFAULT, &vertexB, NULL))) return FALSE; After i Ctrl Alt Del the program, i get: Unhandled exception at 0x00455f45 in tb_dx9_02.exe: 0xC0000005: Access violation reading location 0x00000000. And i can see that the program ended at the NULL in the create function. Pleas help, I have no idea whats wrong.

Share this post


Link to post
Share on other sites
1) Use the debug Direct3D runtime and see if you get any interesting output to the debug window. It could be that an earlier call failed.


2) When the debugger stops on the line of code that you''ve posted, move the mouse pointer over the "m_pD3DDevice" part, a tooltip should appear to tell you the value of that pointer. The value should also be in the "auto" variables watch window.

If the value of that pointer is 0, then that''s the problem. At the point in time when that line is executed, the pointer is NULL. The common reasons for that would be:

a. An earlier call such as CreateDevice() has failed. The debug runtime will tell you why.

b. There''s an error in your program logic that means the the CreateVertexBuffer() line gets executed before the D3D device is created or after it''s been destroyed.

c. Something in your code overwrote the part of memory being used to store the device pointer.

d. The device pointer wasn''t passed to the class that code is in.


3) Try looking down the callstack to see what code called that line.


quote:
After i Ctrl Alt Del the program, i get:


Can you expand on what you mean by that.

If the CreateVertexBuffer (or other) call fails, the DEBUG RUNTIME **WILL** tell you why.

If the access violation only occurs when you try to terminate the program, then I suspect there''s a problem with your flow control logic. Constructor being called when you didn''t expect, creation code started by a windows message that you also happen to get at application shutdown time.


--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
I will try some of the stuff you wrote. Thanks.

Well, I need to use Ctrl Alt Del, to get any control over my computer, it''s frosen.

When you say that I should :

Use the debug Direct3D runtime and see if you get any interesting output to the debug window.

How do I do that. I got the DirectX debug version installed. How do I get that window open when my program''s crash ???

Share this post


Link to post
Share on other sites