Ocean
VertexArray.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_ARRAY_H
9 #define META_OCEAN_PLATFORM_GL_VERTEX_ARRAY_H
10 
11 #include "ocean/platform/gl/GL.h"
13 
14 
15 namespace Ocean
16 {
17 
18 namespace Platform
19 {
20 
21 namespace GL
22 {
23 
24 /**
25  * This class implements a vertex array object.
26  * @ingroup platformgl
27  */
28 class OCEAN_PLATFORM_GL_EXPORT VertexArray : public ContextAssociated
29 {
30  public:
31 
32  /**
33  * Creates a new vertex array object.
34  */
35  inline VertexArray();
36 
37  /**
38  * Creates a new vertex array object with associated context.
39  * @param context The associated context of the new vertex array object
40  */
41  explicit inline VertexArray(Context& context);
42 
43  /**
44  * Destructs this vertex array object.
45  */
46  virtual ~VertexArray();
47 
48  /**
49  * Binds this vertex array object (and creates it if it does not exist).
50  * @return True, if succeeded
51  */
52  bool bind();
53 
54  /**
55  * Unbinds this vertex array object (unbinds any/the current vertex object).
56  * @return True, if succeeded
57  */
58  bool unbind();
59 
60  /**
61  * Releases this vertex array object.
62  * @return True, if succeeded
63  */
64  bool release();
65 
66  /**
67  * Returns whether this object holds a valid vertex buffer.
68  * @return True, if so
69  */
70  explicit inline operator bool() const;
71 
72  /**
73  * Assign operator which does not create a new copy of an associated OpenGL object.
74  * @param object Vertex array object to assign
75  * @return Reference to this object
76  */
78 
79  protected:
80 
81  /// The id of the vertex array.
82  GLuint arrayId;
83 };
84 
87  arrayId(0u)
88 {
89  // nothing to do here
90 }
91 
93  ContextAssociated(context),
94  arrayId(0u)
95 {
96  // nothing to do here
97 }
98 
99 inline VertexArray::operator bool() const
100 {
101  return arrayId != 0u;
102 }
103 
104 }
105 
106 }
107 
108 }
109 
110 #endif // META_OCEAN_PLATFORM_GL_VERTEX_ARRAY_H
This class implements the base class for all object which have an associated context.
Definition: ContextAssociated.h:31
This class encapsulates an OpenGL context.
Definition: platform/gl/Context.h:29
This class implements a vertex array object.
Definition: VertexArray.h:29
virtual ~VertexArray()
Destructs this vertex array object.
bool unbind()
Unbinds this vertex array object (unbinds any/the current vertex object).
GLuint arrayId
The id of the vertex array.
Definition: VertexArray.h:82
VertexArray()
Creates a new vertex array object.
Definition: VertexArray.h:85
bool release()
Releases this vertex array object.
VertexArray & operator=(const VertexArray &object)
Assign operator which does not create a new copy of an associated OpenGL object.
bool bind()
Binds this vertex array object (and creates it if it does not exist).
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15