Jump to content
  • Advertisement
Sign in to follow this  
pranaykamat

wired Access violation!!

This topic is 4954 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, Am trying to optimise my the mesh vertices. the problem is i get a access violation when i try to get the vertex buffer after setting the index buffer! Am very sure of the values am setting for the vertex and index buffer and dont think its got anythign to do with that. the wierd thing is if i comment the block of code which sets the index buffer its works perfectly fine!! i think its corupting my vertex buffer becuse the second call to GetVertexBuffer gives access violation.
ID3DXMesh* pMesh = 0;
hr = D3DXCreateMeshFVF(
                961,	// numFaces
		MAP_SIZE,
		D3DXMESH_MANAGED,
		Vertex::FVF,
		Device,
		&pMesh);

int boxNo=0;
int ii=0;
int i=0;

Vertex* v = 0;
pMesh->LockVertexBuffer(0, (void**)&v);
for(i=0;i<height-1;i++){
   for(int j=0;j<width-1;j++){
        ii = (i*width)+j;
	v[boxNo]   = pVertex[ii];
	v[boxNo+1] = pVertex[ii+1];
	v[boxNo+2] = pVertex[(ii+1)*width];
	v[boxNo+3] = pVertex[ii*width];
	boxNo += 4;
   }
}
pMesh->UnlockVertexBuffer();
pMesh->GetVertexBuffer(&pVB);  // Debuging

int* vStruct = 0;
pMesh->LockIndexBuffer(D3DLOCK_DISCARD, (void**)&vStruct);
int idx=0;
int vIndex=0;
for(i=0;i<height-1;i++) {
  for(int j=0;j<width-1;j++)
  {
     vIndex = (i*width)+j;
     vStruct[idx] = vIndex; 
     vStruct[idx+1] = vIndex+1; 
     vStruct[idx+2] = (vIndex*STEP_SIZE)+1;
     vStruct[idx+3] = vIndex; 
     vStruct[idx+4] = (vIndex*width)+1; 
     vStruct[idx+5] = vIndex*width;
     idx+=6;
  }
}
pMesh->UnlockIndexBuffer()		
pMesh->GetVertexBuffer(&pVB);     // Debuging


Share this post


Link to post
Share on other sites
Advertisement
hi, thanks for that info.. but it dint help :-( did more debugin toady found that..

the code below works !!! note that am still using "idx+=6" so its still takin the same amount of memory..

[source c++]
int idx=0;
DWORD vIndex=0;
for(i=0;i<height-1;i++)
for(int j=0;j<width-1;j++)
{
// fill in the face index data
vIndex = (i*width)+j;
vStruct[idx] = 0;//(DWORD)vIndex;
vStruct[idx+1] = 0;//(DWORD)vIndex+1;
//vStruct[idx+2] = 0;//(DWORD)(vIndex*STEP_SIZE)+1;
//vStruct[idx+3] = 0;//(DWORD)vIndex;
//vStruct[idx+4] = 0;//(DWORD)(vIndex*STEP_SIZE)+1;
//vStruct[idx+5] = 0;//(DWORD)vIndex*STEP_SIZE;
//vStruct[idx]=j;
idx+=6;
}



Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!