Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "DirectXContext.h"
- struct VERTEX { D3DXVECTOR3 Pos; D3DXCOLOR Color; };
- class Mesh
- {
- public:
- template<size_t N> Mesh(DirectXContext *dxc, VERTEX(&vertices)[N])
- {
- // create the vertex buffer
- D3D11_BUFFER_DESC bd;
- ZeroMemory(&bd, sizeof(bd));
- bd.Usage = D3D11_USAGE_DYNAMIC;
- bd.ByteWidth = sizeof(VERTEX) * 3;
- bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
- bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- dxc->dev->CreateBuffer(&bd, NULL, &pVBuffer);
- D3D11_MAPPED_SUBRESOURCE ms;
- dxc->devcon->Map(pVBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms);
- memcpy(ms.pData, vertices, sizeof(vertices));
- dxc->devcon->Unmap(pVBuffer, NULL);
- }
- //Mesh(DirectXContext *dxc, VERTEX vertices[3]);
- ID3D11Buffer *pVBuffer;
- virtual ~Mesh();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement