Sign in to follow this  
dpro

DrawIndexedPrimitive fails with Access violation

Recommended Posts

Ok I removed this question and decided to ask a new one, relating to the same thing. I keep on getting a Access Violation whenever I try to use drawindexedprimitive...
p_dev->SetIndices( idxBuff );
hr = p_dev->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, totalVerts, 0, numPolys );


int m_cols = 20;
int m_rows = 20;
polySize = m_cols * m_rows * 2;
numInd = polySize * 3;
numPolys = m_cols * m_rows * 2;
totalVerts = (m_cols+1) * (m_rows+1);
vertices = new vtx[ totalVerts ];


I created a vertex buffer of totalVerts * sizeof( vtx ) size, as is usual. vtx is a struct with a D3DXVECTOR3 position vector and a color value. I created an indexbuffer with a size of numInd size, which in this case is 2400 indices total. 20 * 20 * 3(vertices per triangle) * 2(triangles per "square") But I must be setting something wrong because of the access violation, but I can't seem to see what. [Edited by - dpro on May 22, 2006 5:00:53 PM]

Share this post


Link to post
Share on other sites
I can't find anything out of place in the code you posted. Could you post some more code? Show your full vertex/index buffer setup and your full draw code and we'll see if there's anything wrong with it.

Share this post


Link to post
Share on other sites
Can't find anything wrong either.
Two shots in the dark:
- mix up of 16/32 bits in the index buffer setup?
- missing SetStreamSource, SetIndices or SetFVF calls in the rendering procedure?

Share this post


Link to post
Share on other sites
Do you have the debug runtimes installed with the output set to maximum? Any warnings or errors there?

I seem to remember having this problem when I was using software vertex processing, if you try to access a vertex using an invalid index (E.g. if any indices have an index >= totalverts).

Share this post


Link to post
Share on other sites
Thanks for the replies, I found out that I had been silly and filled my indexbuffer improperly, meaning I was heading off the end of the vertexbuffer array. Which as we all know is a no-no :) Thanks again!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this