----- ----- -----
I get it that createBuffer should only be called at the beginning. Problem is, I have to call it when I want to create a new chunk, because I am filling it there. Maybe I'm getting something wrong, at the moment that is what I'm calling every time I create a chunk:
I only create chunks if they are needed when I move, of corse.
// in chunk.h ID3D11Buffer* vertexBuffer; D3D11_BUFFER_DESC vertexBufferDesc; // in chunk.cpp ZeroMemory( &vertexBufferDesc, sizeof(vertexBufferDesc) ); vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT; vertexBufferDesc.ByteWidth = sizeof(VertexPosNormalTexColorColor2) * (lowwidth*lowheight); vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; vertexBufferDesc.CPUAccessFlags = 0; vertexBufferDesc.MiscFlags = 0; D3D11_SUBRESOURCE_DATA vertexBufferData; ZeroMemory( &vertexBufferData, sizeof(vertexBufferData) ); vertexBufferData.pSysMem = verticesToLock; vertexBufferData.SysMemPitch = 0; vertexBufferData.SysMemSlicePitch = 0; d3d11Device->CreateBuffer( &vertexBufferDesc, &vertexBufferData, &vertexBufferIn);
How can I get rid of this? I have to call createBuffer, because the verticesToLock-data is created in ever chunks Init() function.