GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_wiredata.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  *****************************************************************************/
23 
24 #ifndef GLC_WIREDATA_H_
25 #define GLC_WIREDATA_H_
26 
27 #include <QColor>
28 #include <QGLBuffer>
29 
30 #include "../glc_global.h"
31 #include "../glc_boundingbox.h"
32 #include "../shading/glc_renderproperties.h"
33 
34 #include "../glc_config.h"
37 
39 
41 {
42  friend GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_WireData &);
43  friend GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_WireData &);
44 
46  enum VboType
47  {
48  GLC_Vertex= 30,
50  GLC_Index
51  };
52 
54 
56 
57 public:
59  GLC_WireData();
60 
62  GLC_WireData(const GLC_WireData&);
63 
65  GLC_WireData& operator=(const GLC_WireData&);
66 
68  virtual ~GLC_WireData();
70 
72 
74 
75 public:
77  static quint32 chunckID();
78 
80  GLfloatVector positionVector() const;
81 
83  GLfloatVector colorVector() const;
84 
86  QVector<GLuint> indexVector() const;
87 
89  inline bool isEmpty() const
90  {return ((m_PositionSize == 0) && m_Positions.isEmpty());}
91 
93  GLC_BoundingBox& boundingBox();
94 
96  inline int verticeGroupCount() const
97  {return m_VerticeGroupCount;}
98 
100  inline GLuint verticeGroupOffset(int index) const
101  {return m_VerticeGroupOffseti.at(index);}
102 
104  inline GLsizei verticeGroupSize(int index) const
105  {return m_VerticeGrouprSizes.at(index);}
106 
108  inline bool useIndexdColors() const
109  {return (m_ColorSize > 0) || (m_Colors.size() > 0);}
111 
113 
115 
116 public:
118  GLC_uint addVerticeGroup(const GLfloatVector&);
119 
121  inline void addColors(const GLfloatVector& colors)
122  {m_Colors+= colors;}
123 
125  void clear();
126 
128  void copyVboToClientSide();
129 
131  void releaseVboClientSide(bool update= false);
132 
134  void setVboUsage(bool usage);
135 
137 
139 
141 
142 public:
144  void finishVbo();
145 
147  void useVBO(GLC_WireData::VboType type, bool usage);
148 
150 
151  void glDraw(const GLC_RenderProperties&, GLenum mode);
152 
153 private:
154 
156  void fillVBOs();
157 
159  void buidIndex();
160 
162  void activateVboAndIbo();
163 
165  void finishOffset();
167 
169 // Private members
171 private:
173  QGLBuffer m_VerticeBuffer;
174 
177 
180 
182  QGLBuffer m_ColorBuffer;
183 
186 
188  QGLBuffer m_IndexBuffer;
189 
191  QVector<GLuint> m_IndexVector;
192 
195 
198 
201 
204 
207 
210 
212  QList<GLC_uint> m_VerticeGroupId;
213 
216 
218  bool m_UseVbo;
219 
221  static quint32 m_ChunkId;
222 };
223 
225 GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_WireData &);
226 GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_WireData &);
227 
228 #endif /* GLC_WIREDATA_H_ */

©2005-2013 Laurent Ribon