All Classes Files Functions Variables Typedefs Pages
VertexSeq.hpp
1 #pragma once
2 
3 #include "VertexSeq.fpp"
4 #include "HotVertexSeq.fpp"
5 #include "HotProgram.fpp"
6 #include "GLObject.hpp"
7 #include "../config/BaseProxy.hpp"
8 
9 #include <GL/glew.h>
10 #include <cstddef>
11 #include <memory>
12 #include <iostream>
13 
14 
15 namespace lumina {
16 // =============================================================================
17 // Definition of VertexSeq
18 // =============================================================================
32 class VertexSeq : public GLObject {
33 public:
34  // default constructor
35  VertexSeq();
36 
37  // copy constructor and copy assignment operator
38  VertexSeq(const VertexSeq& copy);
39  VertexSeq &operator=(const VertexSeq &copy);
40 
41  // move constructor and move assignment operator
42  VertexSeq(VertexSeq&& m);
43  VertexSeq& operator=(VertexSeq&& m);
44 
45  // destructor
46  ~VertexSeq();
47 
60  void create(uint16_t vertexSize,
61  uint32_t vertexCount,
62  uint32_t indexCount = 0);
63 
74  template <typename... Cs, typename L>
75  void prime(L lambda);
76 
86  void prime(std::function<void(HotVertexSeq<>&)> func);
87 
89  GLuint nativeVertexHandle() const;
90 
92  GLuint nativeIndexHandle() const;
93 
95  GLuint nativeVAOHandle() const;
96 
97 
99  int size() const;
100 
102  bool isVertexLayoutActive() const;
103 
104  static void setupOpenGL();
105 
107  explicit operator bool() const;
108 
109 private:
110  GLuint m_vertexHandle;
111  GLuint m_indexHandle;
112  GLuint m_vertexArrayObject;
113  uint32_t m_vertexCount;
114  uint32_t m_indexCount;
115  uint16_t m_vertexSize;
116  bool m_layoutActive;
117 
118  static bool s_isPrimed;
119 
120  void bindAll();
121  void unbindAll();
122 
123  void bindVAO() const;
124  void unbindVAO() const;
125 
127  friend HotProgram;
128  template <typename... Cs> friend class HotVertexSeq;
129 };
130 
131 } // namespace lumina
132 
133 // include out of line definitions
134 #include "VertexSeq.tpp"
Definition: HotVertexSeq.hpp:20
GLuint nativeIndexHandle() const
Returns the native OpenGL handle of the index buffer.
Definition: VertexSeq.tpp:97
void prime(L lambda)
Primes the VertexSeq to obtain a HotVertexSeq.
Definition: VertexSeq.tpp:68
int size() const
Returns the number of vertices in the sequence.
Definition: VertexSeq.tpp:105
Hot version of VertexSeq.
Definition: HotVertexSeq.fpp:9
Hot version of Program.
Definition: HotProgram.hpp:18
Definition: GLObject.hpp:37
GLuint nativeVAOHandle() const
Returns the native OpenGL handle of the vertex array object.
Definition: VertexSeq.tpp:101
The type-unsafe variant of HotVertexSeq.
Definition: HotVertexSeq.hpp:72
void create(uint16_t vertexSize, uint32_t vertexCount, uint32_t indexCount=0)
Creates internal data structures.
Definition: VertexSeq.cpp:29
GLuint nativeVertexHandle() const
Returns the native OpenGL handle of the vertex buffer.
Definition: VertexSeq.tpp:93
bool isVertexLayoutActive() const
Determines if a vertex layout is active.
Definition: VertexSeq.tpp:109
Represents a sequence of vertices.
Definition: VertexSeq.hpp:32