Windows has triggered a breakpoint in D3D.exe.
This may be due to a corruption of the heap, which indicates a bug in D3D.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while D3D.exe has focus.
The output window may have more diagnostic information.
it says the error is right here at the bold line:
void Terrain::Render()
{
m_d3dDevice->SetMaterial( &m_material );
m_d3dDevice->SetTexture(0,NULL);
m_d3dDevice->SetStreamSource( 0, m_vb,0, sizeof(CUSTOMVERTEX) );
[u][i][b] m_d3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );[/b][/i][/u]
m_d3dDevice->SetIndices( m_ib );
m_d3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,0,0,CHUNK_VERTICES,0,CHUNK_PRIMITIVES);
}I've been banging my head and I can't seem to understand what the problem could be.Here are the other methods,but as far as I know they work without errors:
void Terrain::CreateMaterial(float r,float g,float b,float a)
{
ZeroMemory( &m_material, sizeof(D3DMATERIAL9) );
m_material.Diffuse.r = m_material.Ambient.r = r;
m_material.Diffuse.g = m_material.Ambient.g = g;
m_material.Diffuse.b = m_material.Ambient.b = b;
m_material.Diffuse.a = m_material.Ambient.a = a;
}
void Terrain::Update()
{
int count=0;
int vIndex=0;
HRESULT hr=m_d3dDevice->CreateVertexBuffer( CHUNK_VERTICES*sizeof(CUSTOMVERTEX),D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED, &m_vb, NULL );
hr=m_d3dDevice->CreateIndexBuffer(sizeof(short)*CHUNK_PRIMITIVES*3,D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_ib, NULL);
hr=m_vb->Lock( 0, 0, (void**)&pVertices, 0 );
hr=m_ib->Lock( 0, 0, (void**)&indices, 0 );
for(int i=0;i<CHUNK_HEIGHT+1;i++)
{
for(int n=0;n<CHUNK_WIDTH+1;n++)
{
pVertices->p.x = n;
pVertices->p.y = i;
pVertices->p.z = 0;
pVertices->n.x = n;
pVertices->n.y = i;
pVertices->n.z = 0;
pVertices->tu = 0;
pVertices->tv = 0;
indices[count++]=vIndex;
indices[count++]=vIndex+n;
indices[count++]=vIndex+n+1;
indices[count++]=vIndex;
indices[count++]=vIndex+n+1;
indices[count++]=vIndex+1;
vIndex++;
}
vIndex++;
}
m_vb->Unlock();
m_ib->Unlock();
}and as for the custom vertex:
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )
#define CHUNK_HEIGHT 64
#define CHUNK_WIDTH 64
#define CHUNK_VERTICES 4225
#define CHUNK_PRIMITIVES 8192
struct CUSTOMVERTEX
{
D3DXVECTOR3 p;
D3DXVECTOR3 n;
float tu,tv;
}; at the top of my code,and I don't think any of them are faulty either






