diff options
| author | lbavoil <[email protected]> | 2018-03-15 11:08:34 +0100 |
|---|---|---|
| committer | lbavoil <[email protected]> | 2018-03-15 11:08:34 +0100 |
| commit | 636807e68a85a978473764d171ed0c7cc36f9be6 (patch) | |
| tree | 784a3d4fa8f48b4c085dd959678505b2af12f425 /samples/dual_layer/D3D11/src/D3D11Mesh.cpp | |
| parent | Remove test folder (diff) | |
| download | hbaoplus-636807e68a85a978473764d171ed0c7cc36f9be6.tar.xz hbaoplus-636807e68a85a978473764d171ed0c7cc36f9be6.zip | |
HBAO+ 4.0.0.23740451
Diffstat (limited to 'samples/dual_layer/D3D11/src/D3D11Mesh.cpp')
| -rw-r--r-- | samples/dual_layer/D3D11/src/D3D11Mesh.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/samples/dual_layer/D3D11/src/D3D11Mesh.cpp b/samples/dual_layer/D3D11/src/D3D11Mesh.cpp new file mode 100644 index 0000000..79e2857 --- /dev/null +++ b/samples/dual_layer/D3D11/src/D3D11Mesh.cpp @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2008-2018, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#define _SCL_SECURE_NO_WARNINGS +#include "D3D11Mesh.h" + +bool D3D11Mesh::InitializeFromMesh(ID3D11Device* device, Mesh& mesh) +{ + mNumIndices = (uint32_t)mesh.mIndices.size(); + + uint32_t vertexBufferSize = (uint32_t)mesh.mVertices.size() * sizeof(decltype(mesh.mVertices)::value_type); + uint32_t indexBufferSize = (uint32_t)mesh.mIndices.size() * sizeof(decltype(mesh.mIndices)::value_type); + + D3D11_BUFFER_DESC bufferDesc{}; + D3D11_SUBRESOURCE_DATA initialData{}; + + bufferDesc.ByteWidth = vertexBufferSize; + bufferDesc.Usage = D3D11_USAGE_DEFAULT; + bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bufferDesc.CPUAccessFlags = 0; + bufferDesc.MiscFlags = 0; + bufferDesc.StructureByteStride = 0; + + initialData.pSysMem = mesh.mVertices.data(); + initialData.SysMemPitch = 0; + initialData.SysMemSlicePitch = 0; + device->CreateBuffer(&bufferDesc, &initialData, &mVertexBuffer); + + + bufferDesc.ByteWidth = indexBufferSize; + bufferDesc.Usage = D3D11_USAGE_DEFAULT; + bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; + bufferDesc.CPUAccessFlags = 0; + bufferDesc.MiscFlags = 0; + bufferDesc.StructureByteStride = 0; + + initialData.pSysMem = mesh.mIndices.data(); + initialData.SysMemPitch = 0; + initialData.SysMemSlicePitch = 0; + device->CreateBuffer(&bufferDesc, &initialData, &mIndexBuffer); + + return true; +} |