Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void D3DActionLoop(const Zones::ZoneFunctions * functions, std::function<HRESULT(ID3D11Device * device)> callback)
- {
- if (!functions->T6.device)
- return;
- while (true)
- {
- HRESULT err;
- auto alwaysFails = functions->T6.alwaysfails;
- err = callback(*functions->T6.device);
- if (!FAILED(err))
- return;
- LogWarn("D3D11 action failed. Error: %xu", err);
- if (!alwaysFails)
- break;
- if ((alwaysFails) && (*alwaysFails == 0))
- break;
- }
- }
- void R_LoadIndexBuffer(const Zones::ZoneFunctions * functions, ID3D11Buffer **ib, int size, const void *data)
- {
- D3DActionLoop(functions, [size, data, ib](ID3D11Device * device)
- {
- D3D11_BUFFER_DESC bufferDesc = { 0 };
- D3D11_SUBRESOURCE_DATA initData = { 0 };
- initData.pSysMem = data;
- initData.SysMemPitch = 0;
- initData.SysMemSlicePitch = 0;
- bufferDesc.Usage = D3D11_USAGE_DEFAULT;
- bufferDesc.ByteWidth = size * sizeof(uint16_t);
- bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
- bufferDesc.CPUAccessFlags = 0;
- bufferDesc.MiscFlags = 0;
- return device->CreateBuffer(&bufferDesc, &initData, ib);
- });
- }
- void R_LoadVertexBuffer(const Zones::ZoneFunctions * functions, ID3D11Buffer **ib, int sizeInBytes, const void *data)
- {
- D3DActionLoop(functions, [sizeInBytes, data, ib](ID3D11Device * device)
- {
- D3D11_BUFFER_DESC bufferDesc = { 0 };
- D3D11_SUBRESOURCE_DATA initData = { 0 };
- initData.pSysMem = data;
- initData.SysMemPitch = 0;
- initData.SysMemSlicePitch = 0;
- bufferDesc.Usage = D3D11_USAGE_DEFAULT;
- bufferDesc.ByteWidth = sizeInBytes;
- bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
- bufferDesc.CPUAccessFlags = 0;
- bufferDesc.MiscFlags = 0;
- return device->CreateBuffer(&bufferDesc, &initData, ib);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement