Jump to content
  • Advertisement
Sign in to follow this  
Le Van

create 2 index buffer

This topic is 1969 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 there, ive just read the following tutorial http://www.braynzarsoft.net/index.php?p=D3D11INDICES
A
nd i started do the exercise 1. Make 2 index buffer. 

 

	Vertex v[] =
	{
		Vertex( -0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f ),
		Vertex( -0.5f,  0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f ),
		Vertex(  0.5f,  0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f ),
		Vertex(  0.5f, -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f ),
		Vertex(  0.0f,  1.0f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f ),
	};

	DWORD indices1[] = {
		0, 1, 2,
		0, 2, 3,
	};

	DWORD indices2[] = {
		1, 2, 4
	};

	D3D11_BUFFER_DESC indexBufferDesc;
	ZeroMemory( &indexBufferDesc, sizeof(indexBufferDesc) );

	indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
	indexBufferDesc.ByteWidth = sizeof(DWORD) * 2 * 3;
	indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
	indexBufferDesc.CPUAccessFlags = 0;
	indexBufferDesc.MiscFlags = 0;

	D3D11_SUBRESOURCE_DATA iinitData;
	//D3D11_SUBRESOURCE_DATA iinitData2;


	iinitData.pSysMem = indices1;
	d3d11Device->CreateBuffer(&indexBufferDesc, &iinitData, &squareIndexBuffer1);

	indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
	indexBufferDesc.ByteWidth = sizeof(DWORD) * 1 * 3;
	indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
	indexBufferDesc.CPUAccessFlags = 0;
	indexBufferDesc.MiscFlags = 0;

	iinitData.pSysMem = indices2;
	d3d11Device->CreateBuffer(&indexBufferDesc, &iinitData, &squareIndexBuffer2);

	d3d11DevCon->IASetIndexBuffer( squareIndexBuffer1, DXGI_FORMAT_R32_UINT, 0);
	d3d11DevCon->IASetIndexBuffer( squareIndexBuffer2, DXGI_FORMAT_R32_UINT, 0);

 

And the questions are:

1.i use the same D3D11_BUFFER_DESC and D3D11_SUBRESOURCE_DATA to create 2 Index buffer ( adjust the fied of D3D11_BUFFER_DESC )
Is it possible?
2. the function d3d11DevCon->IASetIndexBuffer(). i so confuse about the third parametter, how can we know the offset? Thankyou 
 

Share this post


Link to post
Share on other sites
Advertisement

1. Yes it is.

2. the offset param defines the start of the buffer. Mostly this is zero (so the first index used is the first inside the buffer). You could however have 1 big buffer made of multiple smaller onces, that is where the offset comes into place.

Share this post


Link to post
Share on other sites

thankyou smile.png.


d3d11DevCon->IASetIndexBuffer( squareIndexBuffer1, DXGI_FORMAT_R32_UINT, 0);
    d3d11DevCon->IASetIndexBuffer( squareIndexBuffer2, DXGI_FORMAT_R32_UINT, 0);

 

the second index buffer set  to the IA stage require the offset, how can we get the size of the first buffer ?

Edited by linhmai27

Share this post


Link to post
Share on other sites

the article say "Make 2 buffers", can u post the code, i can't imagine it smile.png. If there is 1 buffer set. Thankyou so much, i have tried but its all blank screen. 

Edited by linhmai27

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!