| 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
15 namespace OpenSubdiv {
16 namespace OPENSUBDIV_VERSION {
17
18 namespace Osd {
19
29 class CpuGLVertexBuffer {
30 public:
31 using ID = unsigned int; // GLuint resource ID
32
34 static CpuGLVertexBuffer * Create(int numElements, int numVertices,
35 void *deviceContext = NULL);
36
38 ~CpuGLVertexBuffer();
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
59 protected:
61 CpuGLVertexBuffer(int numElements, int numVertices);
62
64 bool allocate();
65
66 private:
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
77 using namespace OPENSUBDIV_VERSION;
78
79} // end namespace OpenSubdiv
80
81#endif // OPENSUBDIV3_OSD_CPU_GL_VERTEX_BUFFER_H
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:17
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::CpuGLVertexBuffer
CpuGLVertexBuffer(int numElements, int numVertices)
Constructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::GetNumElements
int GetNumElements() const
Returns how many elements defined in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::UpdateData
void UpdateData(const float *src, int startVertex, int numVertices, void *deviceContext=NULL)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::GetNumVertices
int GetNumVertices() const
Returns how many vertices allocated in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::Create
static CpuGLVertexBuffer * Create(int numElements, int numVertices, void *deviceContext=NULL)
Creator. Returns NULL if error.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::BindVBO
ID BindVBO(void *deviceContext=NULL)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::allocate
bool allocate()
Allocates VBO for this buffer. Returns true if success.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::BindCpuBuffer
float * BindCpuBuffer()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::~CpuGLVertexBuffer
~CpuGLVertexBuffer()
Destructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuGLVertexBuffer::ID
unsigned int ID
Definition cpuGLVertexBuffer.h:31