Archived

This topic is now archived and is closed to further replies.

index buffers

This topic is 5334 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 all, Would I need seperate index buffers for each line of quads in my terrain i.e. for each row of quads and then have seperate calls to DrawIndexedPrimitive for each row ? Such as:
  
	m_pDevice->SetIndices(m_pIndexBuffer);

	m_pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,10,0,8);	

	m_pDevice->SetIndices(m_pIndexBufferNextRow);
	m_pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,10,0,8);	

  
Or, could I just use one big index buffer with seperate calls to DrawIndexedPrimitive using the start index parameter within the DrawIndexedPrimitive method ? Kind regards, Steve As I get older, my mind becomes more cluttered.

Share this post


Link to post
Share on other sites
After experimenting, I can do it with one index buffer which I guess is correct ?! Only problem is, creating this index buffer for the next row, here is my code for creating the indices for one row:


  
int index = 0;
int offset = 0;
m_pIndices = new WORD[m_xDim * 6];
for(int x=0; x < m_xDim; x++) // not used yet....

{
for(int z=0; z < m_zDim; z++)
{
m_pIndices[index] = z + offset;
m_pIndices[index+1] = z + 1 + offset;
m_pIndices[index+2] = z + 2 + offset;
m_pIndices[index+3] = z + 3 + offset;
m_pIndices[index+4] = z + 2 + offset;
m_pIndices[index+5] = z + 1 + offset;
index += 6;
offset += 1;
}
}


I''ve hard coded a quad for the second row and the indices look like :


  
m_pIndices[index] = 1;
m_pIndices[index+1] = 8;
m_pIndices[index+2] = 3;
m_pIndices[index+3] = 9;
m_pIndices[index+4] = 3;
m_pIndices[index+5] = 8;


Need some way of programtically getting this correct, I''ve seen various ways from other people, just wondering if I was on the right track ?

Regards,
Steve



As I get older, my mind becomes more cluttered.

Share this post


Link to post
Share on other sites