NGL  6.5
The NCCA Graphics Library
AbstractVAO.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 Jon Macey
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 #ifndef ABSTRACTVAO_H_
18 #define ABSTRACTVAO_H_
19 
20 #include "Types.h"
21 
22 namespace ngl
23 {
24 //----------------------------------------------------------------------------------------------------------------------
32 //----------------------------------------------------------------------------------------------------------------------
33 
35 {
36  public :
37  class VertexData
38  {
39  public :
40  VertexData(size_t _size,const GLfloat &_data, GLenum _mode=GL_STATIC_DRAW ) :
41  m_size(_size), m_data(_data), m_mode(_mode){}
42 
43  size_t m_size;
44  const GLfloat &m_data;
46  };
47 
48  //----------------------------------------------------------------------------------------------------------------------
50  //----------------------------------------------------------------------------------------------------------------------
51  virtual ~AbstractVAO()=default;
52  //----------------------------------------------------------------------------------------------------------------------
54  //----------------------------------------------------------------------------------------------------------------------
55  void bind();
56  //----------------------------------------------------------------------------------------------------------------------
58  //----------------------------------------------------------------------------------------------------------------------
59  void unbind();
60  //----------------------------------------------------------------------------------------------------------------------
63  //----------------------------------------------------------------------------------------------------------------------
64  virtual void draw()const =0;
65  //----------------------------------------------------------------------------------------------------------------------
68  //----------------------------------------------------------------------------------------------------------------------
69  virtual void setData(const VertexData &_data)=0;
70  //----------------------------------------------------------------------------------------------------------------------
73  //----------------------------------------------------------------------------------------------------------------------
74  virtual void removeVAO()=0;
75  //----------------------------------------------------------------------------------------------------------------------
85  //----------------------------------------------------------------------------------------------------------------------
86  void setVertexAttributePointer(GLuint _id, GLint _size, GLenum _type, GLsizei _stride, unsigned int _dataOffset, bool _normalise=false );
87  //----------------------------------------------------------------------------------------------------------------------
90  //----------------------------------------------------------------------------------------------------------------------
91  void setNumIndices(size_t _s){m_indicesCount=_s;}
92  //----------------------------------------------------------------------------------------------------------------------
96  //----------------------------------------------------------------------------------------------------------------------
97  virtual GLuint getBufferID(unsigned int _id=0)=0;
98  //----------------------------------------------------------------------------------------------------------------------
100  //----------------------------------------------------------------------------------------------------------------------
101  GLenum getMode() const;
102  //----------------------------------------------------------------------------------------------------------------------
105  //----------------------------------------------------------------------------------------------------------------------
106  void setMode(const GLenum &_mode);
107 
108  protected :
109  //----------------------------------------------------------------------------------------------------------------------
112  //----------------------------------------------------------------------------------------------------------------------
114  //----------------------------------------------------------------------------------------------------------------------
116  //----------------------------------------------------------------------------------------------------------------------
118  //----------------------------------------------------------------------------------------------------------------------
120  //----------------------------------------------------------------------------------------------------------------------
121  GLuint m_id=0;
122  //----------------------------------------------------------------------------------------------------------------------
124  //----------------------------------------------------------------------------------------------------------------------
125  bool m_bound=false;
126  //----------------------------------------------------------------------------------------------------------------------
128  //----------------------------------------------------------------------------------------------------------------------
129  bool m_allocated=false;
130  //----------------------------------------------------------------------------------------------------------------------
132  //----------------------------------------------------------------------------------------------------------------------
133  size_t m_indicesCount=0;
134 };
135 
136 
137 } // end namespace
138 
139 #endif
unsigned int GLuint
Definition: glew.h:280
main definition of types and namespace
#define GL_STATIC_DRAW
Definition: glew.h:1671
#define NGL_DLLEXPORT
Definition: Types.h:65
#define GL_TRIANGLES
Definition: glew.h:330
unsigned int GLenum
Definition: glew.h:278
implementation files for RibExport class
Definition: AABB.cpp:22
float GLfloat
Definition: glew.h:289
base class for all VAO from the VAOFactory this defines the base class type with simple draw / bind b...
Definition: AbstractVAO.h:34
void setNumIndices(size_t _s)
the number of indices to draw in the array. It may be that the draw routine can overide this at anoth...
Definition: AbstractVAO.h:91
VertexData(size_t _size, const GLfloat &_data, GLenum _mode=GL_STATIC_DRAW)
Definition: AbstractVAO.h:40
int GLint
Definition: glew.h:281
int GLsizei
Definition: glew.h:282