OpenPolygon  1.0.0
OpenPolygon is a Rendering Engine
glvertexarrayobject.h
1 /*
2  Copyright (C) 2014 - 2016 Mutzii
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
18 #ifndef GLVERTEXARRAYOBJECT_H
19 #define GLVERTEXARRAYOBJECT_H
20 
21 #include "index.h"
22 #include "IGBuffer.h"
23 #include "GPU/glvertexbuffer.h"
24 #include "GPU/glelementbuffer.h"
25 #include "GPU/glcustomattributebuffer.h"
26 
27 namespace Engine
28 {
33  {
34  GLuint vertexCount;
35  GLuint instanceCount;
36  GLuint firstIndex;
37  GLuint baseVertex;
38  GLuint baseInstance;
39  };
40 
44  struct AttributeCmd
45  {
46  uint attribute_id; //ATTR_BUFFER_XXX
47  uint type; //GL_FLOAT , GL_UNSIGNED_INT
48  int vector_size; //VECTOR_SIZE_X
49  bool instance; //Instance Attribut
50  int size_data; // 20x floats ( 20 * sizeof(float) )
51  void * data; // data pointer
52  };
53 
54 
55  using IGBufferMap = std::map< uint , IGBuffer *>;
56 
61  {
62  public:
65 
71  void setDrawMode( GLenum draw_mode );
72 
77  void create(void);
78 
83  void Bind(void);
84 
89  void Unbind(void);
90 
91  //AttachBuffers
92 
93  void AttachBuffer( GLVertexBuffer * vbo_vertex_buffer );
94  void AttachBuffer( GLElementBuffer * vbo_element_buffer );
95  void AttachBuffer( AttributeCmd & cmd );
96  void AttachBuffer( uint attribute_id , IGBuffer * vbo_buffer );
97 
98  IGBuffer * getAttachBuffer( uint attribute_id );
99 
100  //Draw Calls
101  void DrawArrays(void);
102  void DrawElements(void);
103  void DrawElementsIndirect ( int index_size , int drawcount );
104  void DrawElementsIndirect ( int drawcount );
105  void DrawElementsInstanced( int drawcount );
106 
107 
108  private:
109 
110  uint m_vao_id;
111  GLenum m_draw_mode;
112 
113  int m_vertex_size;
114  int m_index_size;
115 
116  bool m_vertex_buffer;
117  bool m_element_buffer;
118 
119  IGBufferMap m_buffer_map;
120 
121  };
122 
123 }
124 #endif // GLVERTEXARRAYOBJECT_H
The AttributeCmd struct.
Definition: glvertexarrayobject.h:44
The DrawElementsCommand struct.
Definition: glvertexarrayobject.h:32
The IGBuffer - Interface class.
Definition: IGBuffer.h:29
void Bind(void)
Bind.
Definition: GLVertexArrayObject.cpp:48
Definition: element.h:23
void setDrawMode(GLenum draw_mode)
setDrawMode
Definition: GLVertexArrayObject.cpp:38
The GLVertexBuffer class.
Definition: glvertexbuffer.h:30
void create(void)
create
Definition: GLVertexArrayObject.cpp:43
The GLElementBuffer class.
Definition: glelementbuffer.h:29
void Unbind(void)
Unbind.
Definition: GLVertexArrayObject.cpp:53
The GLVertexArrayObject class.
Definition: glvertexarrayobject.h:60