OpenSubdiv
Loading...
Searching...
No Matches
cpuGLVertexBuffer.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_GL_VERTEX_BUFFER_H
9#define OPENSUBDIV3_OSD_CPU_GL_VERTEX_BUFFER_H
10
11#include "../version.h"
12
13#include <cstddef>
14
15namespace OpenSubdiv {
16namespace OPENSUBDIV_VERSION {
17
18namespace Osd {
19
30public:
31 using ID = unsigned int; // GLuint resource ID
32
34 static CpuGLVertexBuffer * Create(int numElements, int numVertices,
35 void *deviceContext = NULL);
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
53 float * BindCpuBuffer();
54
57 ID BindVBO(void *deviceContext = NULL);
58
59protected:
61 CpuGLVertexBuffer(int numElements, int numVertices);
62
64 bool allocate();
65
66private:
67 int _numElements;
68 int _numVertices;
69 ID _vbo;
70 float *_cpuBuffer;
71 bool _dataDirty;
72};
73
74} // end namespace Osd
75
76} // end namespace OPENSUBDIV_VERSION
77using namespace OPENSUBDIV_VERSION;
78
79} // end namespace OpenSubdiv
80
81#endif // OPENSUBDIV3_OSD_CPU_GL_VERTEX_BUFFER_H
Concrete vertex buffer class for cpu subdivision and OpenGL drawing.
CpuGLVertexBuffer(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.
static CpuGLVertexBuffer * Create(int numElements, int numVertices, void *deviceContext=NULL)
Creator. Returns NULL if error.
bool allocate()
Allocates VBO for this buffer. Returns true if success.