• Advertisement
Sign in to follow this  

Invalid index data pointer

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone i am trying to render a pretty basic static mesh that has no y value in D3D9. (it will actually be a bruteforce terrain method but just for testing i dropped the y value for simplicity) here is some code init function:

struct Vertex3f
{
float x,y,z;
};
	Vertex3f *vertices;
	short *indices;

vertexcount = m_iSize * m_iSize *3;
	vertices = new Vertex3f[vertexcount];
	indicecount = (m_iSize-1)*(m_iSize-1)*6;
	indices = new short[indicecount];

    
	//Build our vertex array
		for(int z=0; z<m_iSize; z++ )
					{
						for( int x=0; x<m_iSize; x++ )
						{
						vertices[z*m_iSize+x].x = x*m_fStep;
						vertices[z*m_iSize+x].y = 0;
						vertices[z*m_iSize+x].z = z*m_fStep;
						}
						
					}
	//Build our indice array
		int i=0;
		for(int z=0; z<m_iSize-1; z++ )
					{
						for( int x=0; x<m_iSize-1; x++ )
						{
							//triangle 1
							indices = x +(m_iSize *z);
							i++;
							indices = x + (m_iSize * (z+1));
							i++;
							indices = (x+1) + (m_iSize * (z+1));
							i++;
							//triangle 2
							indices = (x+1) + (m_iSize * (z+1));
							i++;
							indices = (x+1) + (m_iSize * z);
							i++;
							indices = x +(m_iSize *z);
							i++;
							primitivecount+=2;

						}
					}


render function:
m_d3D9dev->SetFVF(D3DFVF_XYZ);
m_d3D9dev->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,0,vertexcount,primitivecount,indices,D3DFMT_INDEX16,vertices,sizeof(Vertex3f));


running this in debug mode gives me this error First-chance exception at 0x7c80c851 in testdx.exe: 0xC0000005: Access violation reading location 0x00bf1000. Direct3D9: (ERROR) :Invalid index data pointer any ideas what i am doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement