glc_wiredata.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024 #ifndef GLC_WIREDATA_H_
00025 #define GLC_WIREDATA_H_
00026
00027 #include <QColor>
00028 #include <QGLBuffer>
00029
00030 #include "../glc_global.h"
00031 #include "../glc_boundingbox.h"
00032 #include "../shading/glc_renderproperties.h"
00033
00034 #include "../glc_config.h"
00037
00039
00040 class GLC_LIB_EXPORT GLC_WireData
00041 {
00042 friend GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_WireData &);
00043 friend GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_WireData &);
00044
00046 enum VboType
00047 {
00048 GLC_Vertex= 30,
00049 GLC_Color,
00050 GLC_Index
00051 };
00052
00054
00056
00057 public:
00059 GLC_WireData();
00060
00062 GLC_WireData(const GLC_WireData&);
00063
00065 GLC_WireData& operator=(const GLC_WireData&);
00066
00068 virtual ~GLC_WireData();
00070
00072
00074
00075 public:
00077 static quint32 chunckID();
00078
00080 GLfloatVector positionVector() const;
00081
00083 GLfloatVector colorVector() const;
00084
00086 QVector<GLuint> indexVector() const;
00087
00089 inline bool isEmpty() const
00090 {return ((m_PositionSize == 0) && m_Positions.isEmpty());}
00091
00093 GLC_BoundingBox& boundingBox();
00094
00096 inline int verticeGroupCount() const
00097 {return m_VerticeGroupCount;}
00098
00100 inline GLuint verticeGroupOffset(int index) const
00101 {return m_VerticeGroupOffseti.at(index);}
00102
00104 inline GLsizei verticeGroupSize(int index) const
00105 {return m_VerticeGrouprSizes.at(index);}
00106
00108 inline bool useIndexdColors() const
00109 {return (m_ColorSize > 0) || (m_Colors.size() > 0);}
00111
00113
00115
00116 public:
00118 GLC_uint addVerticeGroup(const GLfloatVector&);
00119
00121 inline void addColors(const GLfloatVector& colors)
00122 {m_Colors+= colors;}
00123
00125 void clear();
00126
00128 void copyVboToClientSide();
00129
00131 void releaseVboClientSide(bool update= false);
00132
00134 void setVboUsage(bool usage);
00135
00137
00139
00141
00142 public:
00144 void finishVbo();
00145
00147 void useVBO(GLC_WireData::VboType type, bool usage);
00148
00150
00151 void glDraw(const GLC_RenderProperties&, GLenum mode);
00152
00153 private:
00154
00156 void fillVBOs();
00157
00159 void buidIndex();
00160
00162 void activateVboAndIbo();
00163
00165 void finishOffset();
00167
00169
00171 private:
00173 QGLBuffer m_VerticeBuffer;
00174
00176 GLC_uint m_NextPrimitiveLocalId;
00177
00179 GLfloatVector m_Positions;
00180
00182 QGLBuffer m_ColorBuffer;
00183
00185 GLfloatVector m_Colors;
00186
00188 QGLBuffer m_IndexBuffer;
00189
00191 QVector<GLuint> m_IndexVector;
00192
00194 int m_PositionSize;
00195
00197 int m_ColorSize;
00198
00200 GLC_BoundingBox* m_pBoundingBox;
00201
00203 IndexSizes m_VerticeGrouprSizes;
00204
00206 OffsetVectori m_VerticeGroupOffseti;
00207
00209 OffsetVector m_VerticeGroupOffset;
00210
00212 QList<GLC_uint> m_VerticeGroupId;
00213
00215 int m_VerticeGroupCount;
00216
00218 bool m_UseVbo;
00219
00221 static quint32 m_ChunkId;
00222 };
00223
00225 GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_WireData &);
00226 GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_WireData &);
00227
00228 #endif