Jump to content
  • Advertisement
Sign in to follow this  

wired Access violation!!

This topic is 5046 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

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

Vertex* v = 0;
pMesh->LockVertexBuffer(0, (void**)&v);
   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->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;
pMesh->GetVertexBuffer(&pVB);     // Debuging

Share this post

Link to post
Share on other sites
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(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;

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!