Ocean
VertexBuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_PLATFORM_GL_VERTEX_BUFFER_H
9 #define META_OCEAN_PLATFORM_GL_VERTEX_BUFFER_H
10 
11 #include "ocean/platform/gl/GL.h"
13 
14 namespace Ocean
15 {
16 
17 namespace Platform
18 {
19 
20 namespace GL
21 {
22 
23 /**
24  * This class implements a vertex buffer.
25  * This buffer represents a GL_ARRAY_BUFFER.
26  * @ingroup platformgl
27  */
28 class OCEAN_PLATFORM_GL_EXPORT VertexBuffer : public Buffer
29 {
30  public:
31 
32  /**
33  * Creates a new vertex buffer object.
34  */
35  inline VertexBuffer();
36 
37  /**
38  * Creates a new vertex buffer object with associated context.
39  * @param context The associated context of the new vertex buffer object
40  */
41  explicit inline VertexBuffer(Context& context);
42 
43  /**
44  * Sets or changes the data of this vertex buffer object.
45  * @param data The data to set
46  * @param size The number of elements to set
47  * @return True, if succeeded
48  */
49  bool setBufferData(const double* data, const size_t size);
50 
51  /**
52  * Sets or changes the data of this vertex buffer object.
53  * @param data The data to set
54  * @param size The number of elements to set
55  * @return True, if succeeded
56  */
57  bool setBufferData(const float* data, const size_t size);
58 
59  /**
60  * Binds this vertex buffer object to a specified shader program and attribute.
61  * @param programId The id of the shader program
62  * @param attributeName The name of the shader's attribute
63  * @param elements The number of elements to bind
64  * @return True, if succeeded
65  */
66  bool bindToProgram(const GLuint programId, const std::string& attributeName, const unsigned int elements) const;
67 
68  /**
69  * Assign operator which does not create a new copy of an assocated OpenGL object.
70  * @param buffer Vertex buffer object to assign
71  * @return Reference to this object
72  */
74 };
75 
77  Buffer()
78 {
79  // nothing to do here
80 }
81 
83  Buffer(context)
84 {
85  // nothing to do here
86 }
87 
88 }
89 
90 }
91 
92 }
93 
94 #endif // META_OCEAN_PLATFORM_GL_VERTEX_BUFFER_H
This class implements the base class for all buffers.
Definition: Buffer.h:28
This class encapsulates an OpenGL context.
Definition: platform/gl/Context.h:29
This class implements a vertex buffer.
Definition: VertexBuffer.h:29
VertexBuffer()
Creates a new vertex buffer object.
Definition: VertexBuffer.h:76
bool setBufferData(const float *data, const size_t size)
Sets or changes the data of this vertex buffer object.
bool setBufferData(const double *data, const size_t size)
Sets or changes the data of this vertex buffer object.
bool bindToProgram(const GLuint programId, const std::string &attributeName, const unsigned int elements) const
Binds this vertex buffer object to a specified shader program and attribute.
VertexBuffer & operator=(const VertexBuffer &buffer)
Assign operator which does not create a new copy of an assocated OpenGL object.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15