Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#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