0

I'm trying to create a vertex buffer and I can't figure out what I'm doing wrong.

The particle struture looks like this:

struct ParticleVertex12
{
    float x;
    float y;
    float z;
};

And here's my code for creating a buffer:

ID3D11Buffer* mVertexBuffer;

D3D11_BUFFER_DESC desc;
memset( &desc, 0, sizeof( desc ) );

desc.BindFlags    = D3D11_BIND_VERTEX_BUFFER;
desc.Usage        = D3D11_USAGE_DYNAMIC;
desc.ByteWidth    = sizeof(ParticleVertex12) * NR_OF_PARTICLES;


HRESULT hr = S_OK;
hr         = device->CreateBuffer( &desc, nullptr, &mVertexBuffer );
return hr;

NR_OF_PARTICLES == 1000 and device->CreateBuffer returns E_FAIL. Any suggestions?

SvinSimpe
  • 850
  • 1
  • 12
  • 28
  • When debugging Direct3D, first try enabling the [debug debug](http://blogs.msdn.com/b/chuckw/archive/2012/11/30/direct3d-sdk-debug-layer-tricks.aspx) and looking for debug output. This is especially true when you get a generic HRESULT like ``E_FAIL`` where the debug layer will tell you specifically what went wrong. – Chuck Walbourn May 11 '15 at 16:11

1 Answers1

2

You can't create a Dynamic Buffer without CPU Access Flags otherwise there's no way to populate it with data.

Adam Miles
  • 3,504
  • 17
  • 15