• Create Account

#Actualgnomgrol

Posted 27 July 2012 - 06:52 AM

EDIT: I just figured that you can update EVERY ID3D11Buffer with UpdateSubresource. I didn't knew that, so with that I can try only updateing the buffers instead of creating new once. I'll try this and reply if it works fine.

----- ----- -----
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.

#4gnomgrol

Posted 27 July 2012 - 06:26 AM

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.

#3gnomgrol

Posted 27 July 2012 - 06:25 AM

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 need to will it there. Maybe I am 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.

#2gnomgrol

Posted 27 July 2012 - 06:19 AM

I get it that createBuffer should only called at the beginning. Problem is, I have to call it when I want to create a new chunk, because I need to will it there. Maybe I am 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.

#1gnomgrol

Posted 27 July 2012 - 06:08 AM

I get it that createBuffer should only called at the beginning. Problem is, I have to call it when I want to create a new chunk, because I need to will it there. Maybe I am getting something wrong, at the moment that is what I'm calling every time I create a chunk.

// 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.

PARTNERS