OpenSubdiv: opensubdiv/osd/glVertexBuffer.h Source File

| OpenSubdiv

Loading...
Searching...
No Matches
glVertexBuffer.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_GL_VERTEX_BUFFER_H
9#define OPENSUBDIV3_OSD_GL_VERTEX_BUFFER_H
10
11#include "../version.h"
12
13#include <cstddef>
14
15namespace OpenSubdiv {
16namespace OPENSUBDIV_VERSION {
17
18namespace Osd {
19
26 class GLVertexBuffer {
27public:
28 using ID = unsigned int; // GLuint resource ID
29
31 static GLVertexBuffer * Create(int numElements, int numVertices,
32 void *deviceContext = NULL);
33
35 ~GLVertexBuffer();
36
39 void UpdateData(const float *src, int startVertex, int numVertices,
40 void *deviceContext = NULL);
41
43 int GetNumElements() const;
44
46 int GetNumVertices() const;
47
49 ID BindVBO(void *deviceContext = NULL);
50
51protected:
53 GLVertexBuffer(int numElements, int numVertices);
54
57 bool allocate();
58
59private:
60 int _numElements;
61 int _numVertices;
62 ID _vbo;
63};
64
65} // end namespace Osd
66
67} // end namespace OPENSUBDIV_VERSION
68using namespace OPENSUBDIV_VERSION;
69
70} // end namespace OpenSubdiv
71
72#endif // OPENSUBDIV3_OSD_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::GLVertexBuffer::~GLVertexBuffer
~GLVertexBuffer()
Destructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLVertexBuffer::GetNumElements
int GetNumElements() const
Returns how many elements defined in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLVertexBuffer::UpdateData
void UpdateData(const float *src, int startVertex, int numVertices, void *deviceContext=NULL)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLVertexBuffer::GLVertexBuffer
GLVertexBuffer(int numElements, int numVertices)
Constructor.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLVertexBuffer::GetNumVertices
int GetNumVertices() const
Returns how many vertices allocated in this vertex buffer.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLVertexBuffer::Create
static GLVertexBuffer * Create(int numElements, int numVertices, void *deviceContext=NULL)
Creator. Returns NULL if error.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLVertexBuffer::BindVBO
ID BindVBO(void *deviceContext=NULL)
Returns the GL buffer object.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLVertexBuffer::allocate
bool allocate()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLVertexBuffer::ID
unsigned int ID
Definition glVertexBuffer.h:28