VolViz
A volume visualization tool
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
VertexArray.h
Go to the documentation of this file.
1 #ifndef VolViz_VertexArray_h
2 #define VolViz_VertexArray_h
3 
4 #include "GLdefs.h"
5 
6 namespace VolViz {
7 namespace Private_ {
8 namespace GL {
9 
11 struct VertexArray {
14  inline VertexArray(int) noexcept {}
15 
16  inline VertexArray() noexcept {
18  assertGL("Vertex array creation failed");
19  }
20 
22 
23  inline VertexArray(VertexArray &&rhs) noexcept : name(rhs.name) {
24  rhs.name = 0;
25  }
26 
27  inline VertexArray &operator=(VertexArray &&rhs) noexcept {
28  name = rhs.name;
29  rhs.name = 0;
30  return *this;
31  }
32 
33  inline void bind() const noexcept {
35  assertGL("Failed to bind vertex array");
36  }
37 
38  inline static void unbind() noexcept { glBindVertexArray(0); }
39 
40  inline VertexArray &enableVertexAttribArray(GLuint idx) noexcept {
41  bind();
43  assertGL("Failed to enabkle vertex attribute");
44  return *this;
45  }
46 
47  GLuint name = 0;
48 };
49 
50 } // namespace GL
51 } // namespace Private_
52 } // namespace VolViz
53 
54 #endif // VolViz_VertexArray_h
void assertGL(char const *txt) noexcept
Definition: Error.h:17
#define glBindVertexArray
Definition: glad.h:2959
unsigned int GLuint
Definition: glad.h:688
~VertexArray()
Definition: VertexArray.h:21
#define glDeleteVertexArrays
Definition: glad.h:2962
#define glEnableVertexAttribArray
Definition: glad.h:2456
GLuint const GLchar * name
Definition: glad.h:2430
VertexArray(VertexArray &&rhs) noexcept
Definition: VertexArray.h:23
VertexArray() noexcept
Definition: VertexArray.h:16
GLuint name
Definition: VertexArray.h:47
RAII wrapper for OpenGL vertex arrays.
Definition: VertexArray.h:11
static void unbind() noexcept
Definition: VertexArray.h:38
void bind() const noexcept
Definition: VertexArray.h:33
VertexArray(int) noexcept
Definition: VertexArray.h:14
VertexArray & operator=(VertexArray &&rhs) noexcept
Definition: VertexArray.h:27
VertexArray & enableVertexAttribArray(GLuint idx) noexcept
Definition: VertexArray.h:40
#define glGenVertexArrays
Definition: glad.h:2965