Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#Actuale.s.

Posted 27 January 2013 - 10:29 PM

Here is some code that I used to bind multiple buffers at once...  Granted, your situation is a bit different with the constant buffer, but the syntax should be close. 

 

TBH, I prefer to push one buffer at a time, (I set the constant buffer in one activity, then set the static vertexbuffer data, then set instance buffer data every frame or so).

 

HTH

 

 

 

/******************************************************************/
 void ModelRenderer::BindInitialBuffer()
 {

 


  unsigned int offsets[2] = {0,0};
  unsigned int strides[2];

  ID3D11Buffer* bufferPointers[2];

  strides[0] = sizeof(NS::Vertex);
  strides[1] = sizeof(Position);

  bufferPointers[0] = ModelRenderer::StaticBuffer.Get(); 
  bufferPointers[1] = ModelRenderer::InstanceBuffer.Get();

  DeviceManager::DeviceContext->IASetVertexBuffers(
   0,                                 // First Input Slot for Binding
   2,                                 // Number of Buffers
   bufferPointers,                    // Buffer Pointer(s)
   strides,                           // Stride(s)
   offsets                            // Offset(s)
   );

  DeviceManager::DeviceContext->IASetInputLayout(ModelRenderer::InitialLayout.Get());
  DeviceManager::DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

 }

 


#3e.s.

Posted 27 January 2013 - 10:28 PM

Here is some code that I used to bind multiple buffers at once...  Granted, your situation is a bit different with the constant buffer, but the syntax should be close. 

 

TBH, I prefer to push one buffer at a time, (I set the constant buffer in one activity, then set the static vertexbuffer data, then set instance buffer data every frame or so).

 

HTH

 

 

 

/******************************************************************/
 void ModelRenderer::BindInitialBuffer()
 {

 


  unsigned int offsets[2] = {0,0};
  unsigned int strides[2];

  ID3D11Buffer* bufferPointers[2];

  strides[0] = sizeof(NS::Vertex);
  strides[1] = sizeof(Position);

  bufferPointers[0] = ModelRenderer::StaticBuffer.Get(); 
  bufferPointers[1] = ModelRenderer::InstanceBuffer.Get();

  DeviceManager::DeviceContext->IASetVertexBuffers(
   0,                                 // First Input Slot for Binding
   2,                                 // Number of Buffers
   bufferPointers,                    // Buffer Pointer(s)
   strides,                           // Stride(s)
   offsets                            // Offset(s)
   );

  DeviceManager::DeviceContext->IASetInputLayout(ModelRenderer::InitialLayout.Get());
  DeviceManager::DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

 }

 


#2e.s.

Posted 27 January 2013 - 10:28 PM

Here is some code that I used to bind multiple buffers at once...  Granted, your situation is a bit different with the constant buffer, but the syntax should be close. 

 

TBH, I just spent the last few hours trying to figure out how to decouple this and push one buffer at a time, (I set the constant buffer in one activity, then set the static vertexbuffer data, then set instance buffer data every frame or so).

 

HTH

 

 

 

/******************************************************************/
 void ModelRenderer::BindInitialBuffer()
 {

 


  unsigned int offsets[2] = {0,0};
  unsigned int strides[2];

  ID3D11Buffer* bufferPointers[2];

  strides[0] = sizeof(NS::Vertex);
  strides[1] = sizeof(Position);

  bufferPointers[0] = ModelRenderer::StaticBuffer.Get(); 
  bufferPointers[1] = ModelRenderer::InstanceBuffer.Get();

  DeviceManager::DeviceContext->IASetVertexBuffers(
   0,                                 // First Input Slot for Binding
   2,                                 // Number of Buffers
   bufferPointers,                    // Buffer Pointer(s)
   strides,                           // Stride(s)
   offsets                            // Offset(s)
   );

  DeviceManager::DeviceContext->IASetInputLayout(ModelRenderer::InitialLayout.Get());
  DeviceManager::DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

 }

 


#1e.s.

Posted 27 January 2013 - 10:26 PM

Here is some code that I used to bind multiple buffers at once...  Granted, your situation is a bit different with the constant buffer, but the syntax should be close.

 

HTH

 

 

 

/******************************************************************/
 void ModelRenderer::BindInitialBuffer()
 {

 


  unsigned int offsets[2] = {0,0};
  unsigned int strides[2];

  ID3D11Buffer* bufferPointers[2];

  strides[0] = sizeof(NS::Vertex);
  strides[1] = sizeof(Position);

  bufferPointers[0] = ModelRenderer::StaticBuffer.Get(); 
  bufferPointers[1] = ModelRenderer::InstanceBuffer.Get();

  DeviceManager::DeviceContext->IASetVertexBuffers(
   0,                                 // First Input Slot for Binding
   2,                                 // Number of Buffers
   bufferPointers,                    // Buffer Pointer(s)
   strides,                           // Stride(s)
   offsets                            // Offset(s)
   );

  DeviceManager::DeviceContext->IASetInputLayout(ModelRenderer::InitialLayout.Get());
  DeviceManager::DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

 }

 


PARTNERS