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?

1
  • When debugging Direct3D, first try enabling the debug debug 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. Commented May 11, 2015 at 16:11

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.