OpenSubdiv
Loading...
Searching...
No Matches
cpuD3D11VertexBuffer.h
Go to the documentation of this file.
1//
2// Copyright 2013 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_CPU_D3D11_VERTEX_BUFFER_H
9#define OPENSUBDIV3_OSD_CPU_D3D11_VERTEX_BUFFER_H
10
11#include "../version.h"
12#include <cstddef>
13
14struct ID3D11Buffer;
15struct ID3D11Device;
16struct ID3D11DeviceContext;
17
18namespace OpenSubdiv {
19namespace OPENSUBDIV_VERSION {
20
21namespace Osd {
22
32public:
34 static CpuD3D11VertexBuffer * Create(int numElements, int numVertices,
35 ID3D11DeviceContext *deviceContext);
36
39
42 void UpdateData(const float *src, int startVertex, int numVertices,
43 void *deviceContext = NULL);
44
46 int GetNumElements() const;
47
49 int GetNumVertices() const;
50
52 float * BindCpuBuffer();
53
55 ID3D11Buffer *BindD3D11Buffer(ID3D11DeviceContext *deviceContext);
56
58 ID3D11Buffer *BindVBO(ID3D11DeviceContext *deviceContext) {
59 return BindD3D11Buffer(deviceContext);
60 }
61
62protected:
64 CpuD3D11VertexBuffer(int numElements, int numVertices);
65
66 bool allocate(ID3D11Device *device);
67
68private:
69 int _numElements;
70 int _numVertices;
71 ID3D11Buffer *_d3d11Buffer;
72 float *_cpuBuffer;
73};
74
75} // end namespace Osd
76
77} // end namespace OPENSUBDIV_VERSION
78using namespace OPENSUBDIV_VERSION;
79
80} // end namespace OpenSubdiv
81
82#endif // OPENSUBDIV3_OSD_CPU_D3D11_VERTEX_BUFFER_H
Concrete vertex buffer class for Cpu subdivision and DirectX drawing.
static CpuD3D11VertexBuffer * Create(int numElements, int numVertices, ID3D11DeviceContext *deviceContext)
Creator. Returns NULL if error.
CpuD3D11VertexBuffer(int numElements, int numVertices)
Constructor.
int GetNumElements() const
Returns how many elements defined in this vertex buffer.
void UpdateData(const float *src, int startVertex, int numVertices, void *deviceContext=NULL)
int GetNumVertices() const
Returns how many vertices allocated in this vertex buffer.
ID3D11Buffer * BindD3D11Buffer(ID3D11DeviceContext *deviceContext)
Returns the D3D11 buffer object.
float * BindCpuBuffer()
Returns the address of CPU buffer.
ID3D11Buffer * BindVBO(ID3D11DeviceContext *deviceContext)
Returns the D3D11 buffer object (for Osd::Mesh interface)