Draw Index Primitive keeps failing

This topic is 4078 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

OK new problem, I fixed the problem with creating the index buffer, not the problem is with DrawIndexPrimitive(), it keeps returning D3DERR_INVALIDCALL
result = (*m_d3ddev)->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,
m_batch_size, 0, m_batch_size / 2);


I'm just drawing one quad, 2 triangles and 4 vertices. m_batch_size == 4. any Ideas? [Edited by - speedie on April 22, 2007 3:59:54 PM]

Share on other sites
Are you sure your CreateIndexBuffer is succeeding? My guess would be that for whatever reason the function is failing, and is leaving m_index_buffer uninitialized. When that happens, you just go along calling a member function on an uninitialized pointer, causing an access violation.

Try checking the returned values for the functions using FAILED() or SUCCEEDED() macros, and if a call does fail, enable the debug runtimes to get a full description of why it failed.

Another safe thing to do would be to make sure the pointer is valid before accessing it, but that would only apply if the pointer was zeroed out first, so, in psuedocode:

m_index_buffer = 0;
if FAILED(CreateIB(..... &m_index_buffer))
{
// Error message and quit?
}
if (m_index_buffer)
{
// Lock and do stuff...
}
else
{
// Unexpected error...
}

Share on other sites
it returns the HRESULT = E_OUTOFMEMORY "Direct3D could not allocate sufficient memory to complete the call."

What exactly does this mean? where am i running out of memory and how?

Share on other sites
What value is m_max_batch?

Why are you attempting to lock twice as many byte as you allocated?

Share on other sites
Quote:
 Original post by NamethatnobodyelsetookWhat value is m_max_batch?Why are you attempting to lock twice as many byte as you allocated?

oops, forgot to re-edit that, i noticed that right away and i found my first of problems, I forgot to set m_max_batch so it was try to create a zero ammount of memory.

but now it crashes when i try drawing anything.

Share on other sites
Editing your post removing your previously answered question isn't really cool. Other people might find it useful if they encounter a similar problem. Editing and replacing the question with a new one causes nothing other than confusion...

As for your question about DrawIndexedPrimitive failing, you'll need to enable the Debug Runtimes to get an actual description of why it is failing. To do this, go to: Start -> Programs -> DirectX SDK -> DX Utilities -> DX Control Panel. From there, select the "Debug Runtimes" and run your application again. At this point, it should spit out debug information about all kinds of problems it finds, including why DrawIndexedPrimitive is failing. If you're using Visual Studio, the debug output will be in the Output window.

When you're done with it, don't forget to switch back, as the debug runtimes are somewhat slower than the release runtimes, and actual games might suffer in performance (or not run at all) when the debug runtimes are used.

Lastly, if you can't find the DX Control Panel in the start menu, it might be in the Windows Control Panel (it was placed there in older SDKs).

Hope this helps.

Share on other sites
I can't find anything that would let me change the runtime libraries, the only thing that exist is installing the retail or the debug sdk. I've looked everywhere, windows control pannel, the dx control pannel you mentioned doesn't exist, ive even looked in the dxsdk folders.

Share on other sites
Quote:
 Original post by speedieresult = (*m_d3ddev)->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_batch_size, 0, m_batch_size / 2); I'm just drawing one quad, 2 triangles and 4 vertices. m_batch_size == 4.

Drawing two triangles using a triangle list requires 6 vertices, not 4. I think you want a traingle strip.

Share on other sites
Quote:
 Original post by speedieI can't find anything that would let me change the runtime libraries, the only thing that exist is installing the retail or the debug sdk. I've looked everywhere, windows control pannel, the dx control pannel you mentioned doesn't exist, ive even looked in the dxsdk folders.

Fixing this is the first thing you should do, the debug runtime is an exceptionally useful tool.

So when you installed the DirectX SDK, it sounds like you got a choice of whether to install the retail or debug SDK, which did you pick? If you chose the retail SDK, then there's a chance you won't have the contol panel. If this was the case, try uninstalling the SDK and re-install it chosing the "debug" version.

The proper Microsoft DirectX SDK installer (rather than one of the unofficial smaller-download versions that appear from time to time) should always install the DirectX control panel applet if it installed the debug runtime.

One thing that can cause the debug DirectX runtime to not be installed is if the version of the runtime(s) in the SDK is OLDER than the version of the runtime that's already installed on the machine.

For example, if your machine has DirectX 9.0c installed and you install an older SDK that contains runtimes for DirectX 9.0a, then the installer won't install an older version of the runtime. You can use DXDIAG to determine which version of the runtimes are installed on your machine (just go to Run... from the Start menu and enter DXDIAG).

If it is the case that your SDK is older than your current runtime, then you'll need to download and install the latest SDK.

Share on other sites
Quote:
Original post by Scet
Quote:
 Original post by speedieresult = (*m_d3ddev)->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_batch_size, 0, m_batch_size / 2); I'm just drawing one quad, 2 triangles and 4 vertices. m_batch_size == 4.

Drawing two triangles using a triangle list requires 6 vertices, not 4. I think you want a traingle strip.

Ummm, not necessarily! DrawIndexedPrimitive()...

1   2+---+|  /|| / ||/  |+---+3   4

4 vertices: 1,2,3,4
6 indices: 1,2,3,2,4,3

• 11
• 20
• 12
• 10
• 38
• Forum Statistics

• Total Topics
631400
• Total Posts
2999862
×