Sign in to follow this  

draw a terrain(I'm totally confused)

This topic is 2547 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 guys.

I want to draw a terrain grid.Code here:

HR(D3DXCreateMesh(m_dwFaceNum,m_dwVertexNum,D3DXMESH_SYSTEMMEM|D3DXMESH_32BIT,terrainElement,m_pd3dD,&m_pMesh));
std::vector<D3DXVECTOR3> pos;
std::vector<DWORD> index;
SFDrawGrid(pos,index,m_iTerrainWH,m_iTerrainWH,(float)m_iBlockWH);
OPNVERTEX *tempV = NULL;
HR(m_pMesh->LockVertexBuffer(0,(void**)&tempV));
for(UINT i = 0 ;i<m_dwVertexNum;++i)
{
tempV[i].position = pos[i];
tempV[i].position.y = m_fHeightMap[i];
}
HR(m_pMesh->UnlockVertexBuffer());

when i = 33107 ,there is a error:

First-chance exception at 0x00a66ead in ObserveDemo.exe: 0xC0000005: Access violation writing location 0x045d2008.
Unhandled exception at 0x00a66ead in ObserveDemo.exe: 0xC0000005: Access violation writing location 0x045d2008.

I am totally confused why the error occur.

forgive my poor english.
any help is appreciated

Share this post


Link to post
Share on other sites
Try running your application in debug mode. How to do that depends on your IDE:

In Visual Studio, it's choosing Debug from a dropbox in your main toolbar.
In Code::Blocks, press F8.
If you use Dev-c++, remove it immediately.

Hope that helps.

Share this post


Link to post
Share on other sites
I think I find what's wrong with my code.

D3DVERTEXELEMENT9 terrainElement[] =
{
{0,0,D3DDECLTYPE_FLOAT3,D3DDECLMETHOD_DEFAULT,D3DDECLUSAGE_POSITION,0},
{0,12,D3DDECLTYPE_FLOAT3,D3DDECLMETHOD_DEFAULT,D3DDECLUSAGE_NORMAL,0},

D3DDECL_END()
};

where must be 12 ,I was used 0.

thanks you all.

Share this post


Link to post
Share on other sites

This topic is 2547 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.

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