   Two Kings Terrain Class Problem - I know other people have had it too, please help
  I''m using the Two Kings Game Development terrain sample and it keeps crashing my game before it even loads. It will compile just fine. The problem arises when you go to execute it =/ The URL for the tutorial is http://www.two-kings.de/tutorials/terrain.htmlI''m almost at the end of my rope here lol I know its come up before though. KingsRevenge has had this problem too. If anyone knows the solution to this problem, please help  Here is the code from my project #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ)//structurestypedef struct SVertex{floatfX,fY,fZ;} D3DVERTEX;    #ifndef cterrain_h#define cterrain_h#define TERRAIN_X128#define TERRAIN_Y128class CTerrain{public:LPDIRECT3DTEXTURE8 m_pTexture;CTerrain();~CTerrain(void);voidCreateVertexBuffer(void);voidSetEnvironment(void);voidDraw(void);bool SetTexture(const char* szTextureFilePath);private:LPDIRECT3DVERTEXBUFFER8pTerrainVertexBuffer;D3DMATERIAL8TerrainMaterial;D3DXMATRIXCamera;};CTerrain::CTerrain(){D3DXMATRIX Temp;pTerrainVertexBuffer = NULL;CreateVertexBuffer();m_pTexture = NULL;SetTexture("grass.bmp");ZeroMemory(&TerrainMaterial,sizeof(TerrainMaterial));TerrainMaterial.Diffuse.r = 1.0f;TerrainMaterial.Diffuse.g = 1.0f;TerrainMaterial.Diffuse.b = 1.0f;} //CTerrainCTerrain::~CTerrain(void){if(pTerrainVertexBuffer != NULL){pTerrainVertexBuffer->Release();pTerrainVertexBuffer = NULL;}} //~CTerrainvoid CTerrain::CreateVertexBuffer(void){static D3DVERTEX aTerrain[(TERRAIN_X - 1) * (TERRAIN_Y - 1) * 6];unsigned char aHeightMap[TERRAIN_X][TERRAIN_Y];char temp;int VertexCount = 0;VOID *pData;ifstream File;File.open("heightmap.raw",ios::binary);for(int j = 0;j < TERRAIN_Y;j++){for(int i = 0;i < TERRAIN_X;i++){File.get(temp);aHeightMap[i][j] = (unsigned char) temp;}}File.close();for(int y = 0;y < TERRAIN_Y - 1;y++) { for(int x = 0;x < TERRAIN_X - 1;x++)  {  aTerrain[VertexCount].fX = (float)x;  aTerrain[VertexCount].fY = (float)y;  aTerrain[VertexCount].fZ = (float)aHeightMap[x][y] / 10;  aTerrain[VertexCount + 1].fX = (float)x + 1;  aTerrain[VertexCount + 1].fY = (float)y;  aTerrain[VertexCount + 1].fZ = (float)aHeightMap[x + 1][y] / 10;  aTerrain[VertexCount + 2].fX = (float)x + 1;  aTerrain[VertexCount + 2].fY = (float)y + 1;  aTerrain[VertexCount + 2].fZ = (float)aHeightMap[x + 1][y + 1] / 10;  aTerrain[VertexCount + 3].fX = (float)x;  aTerrain[VertexCount + 3].fY = (float)y;  aTerrain[VertexCount + 3].fZ = (float)aHeightMap[x][y] / 10;  aTerrain[VertexCount + 4].fX = (float)x + 1;  aTerrain[VertexCount + 4].fY = (float)y + 1;  aTerrain[VertexCount + 4].fZ = (float)aHeightMap[x + 1][y + 1] / 10;  aTerrain[VertexCount + 5].fX = (float)x;  aTerrain[VertexCount + 5].fY = (float)y + 1;  aTerrain[VertexCount + 5].fZ = (float)aHeightMap[x][y + 1] / 10;  VertexCount += 6;  } }lpD3DDevice->CreateVertexBuffer(sizeof(aTerrain),D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED,&pTerrainVertexBuffer);pTerrainVertexBuffer->Lock(0,sizeof(pData),(BYTE**)&pData,0);memcpy(pData,aTerrain,sizeof(aTerrain));pTerrainVertexBuffer->Unlock();} //CreateVertexBuffervoid CTerrain::SetEnvironment(void){lpD3DDevice->SetTexture(0, m_pTexture);lpD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);lpD3DDevice->SetMaterial(&TerrainMaterial);//lpD3DDevice->SetTransform(D3DTS_VIEW,&Camera);} //SetEnvironmentvoid CTerrain::Draw(void){lpD3DDevice->SetStreamSource(0,pTerrainVertexBuffer,sizeof(D3DVERTEX));lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,16129);lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,48387,16129);} //Drawbool CTerrain::SetTexture(const char *szTextureFilePath){if(FAILED(D3DXCreateTextureFromFile(lpD3DDevice, szTextureFilePath, &m_pTexture))){return false;}return true;}#endif  I believe the problem lies in the code that creates the vertex buffer (lpD3DDevice->CreateVertexBuffer(sizeof(aTerrain),D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED,&pTerrainVertexBuffer)Thanks for any help you can give me, I have such a headache =|    Mindgamez Entertainment
  That''s a lot of code to go through.  Do you have the debug runtime installed?  Make sure the Debug Level is set fairly high (Control Panel->DirectX), then run the app in the debugger.  Some very useful info should be waiting in the output window.I don''t think I''ve ever run into a situation where the runtime didn''t at least give me a clue as to the problem.    Stay Casual,KenDrunken Hyena;  I have it set to level 3, it says nothing whatsoever. There is another thread about this exact code but it doesn''t lead to any conclusion as to how to fix it =( I was hoping that maybe now someone knew    Mindgamez Entertainment;  ::bump::    Mindgamez Entertainment;  What error(s) are you recieving?  ;  None whatsoever (source level). The error occurs only when the game executes, it gives a standard windows error dialog and ends.    Mindgamez Entertainment;quote:lpD3DDevice->CreateVertexBuffer(sizeof(aTerrain),D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED,&pTerrainVertexBuffer);pTerrainVertexBuffer->Lock(0,sizeof(pData),(BYTE**)&pData,0);memcpy(pData,aTerrain,sizeof(aTerrain));pTerrainVertexBuffer->Unlock();  Change lock call to:pTerrainVertexBuffer->Lock(0,0,(BYTE**)&pData,D3DLOCK_DISCARD); Jim Adamshome.att.net/~rpgbookAuthor, Programming Role-Playing Games with DirectX;  Hmm... It didn''t do the trick, it still errors out at the begining of the app. I think it might be some kind of conflict(?). Is there anything that might conflict witht this? I''m almost positive nothing has the same name as it...    Mindgamez Entertainment;  What does the error say?  You mention standard windows error, can you post the message.;  Here is a screenshot of the error:when I go into debug mode it shows this when the error arises (which is right upon execution):I'm really confused =|    Mindgamez Entertainment[edited by - neurokaotix on August 20, 2002 8:10:14 PM] 