glc_lod.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 *****************************************************************************/
00022 
00024 
00025 #ifndef GLC_LOD_H_
00026 #define GLC_LOD_H_
00027 
00028 #include <QVector>
00029 #include <QGLBuffer>
00030 
00031 #include "../glc_ext.h"
00032 
00033 #include "../glc_config.h"
00034 
00037 
00038 
00039 class GLC_LIB_EXPORT GLC_Lod
00040 {
00041         friend GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_Lod &);
00042         friend GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_Lod &);
00043 
00044 public:
00046 
00048 
00049 public:
00051         GLC_Lod();
00052 
00054         GLC_Lod(double accuracy);
00055 
00057         GLC_Lod(const GLC_Lod&);
00058 
00060         GLC_Lod& operator=(const GLC_Lod&);
00061 
00063         virtual ~GLC_Lod();
00065 
00067 
00069 
00070 public:
00072         static quint32 chunckID();
00073 
00075         inline double accuracy() const
00076         {return m_Accuracy;}
00077 
00079 
00084         QVector<GLuint> indexVector() const;
00085 
00087 
00092         inline QVector<GLuint>* indexVectorHandle()
00093         {return &m_IndexVector;}
00094 
00096         inline int indexVectorSize() const
00097         {return m_IndexVector.size();}
00098 
00100         inline unsigned int trianglesCount() const
00101         {return m_TrianglesCount;}
00102 
00104 
00106 
00108 
00109 public:
00111         void copyIboToClientSide();
00112 
00114         void releaseIboClientSide(bool update= false);
00115 
00117         inline void setAccuracy(const double& accuracy)
00118         {m_Accuracy= accuracy;}
00119 
00121         inline void trianglesAdded(unsigned int count)
00122         {
00123                 m_TrianglesCount+= count;
00124         }
00125 
00127         void setIboUsage(bool usage);
00128 
00129 
00131 
00133 
00135 
00136 public:
00138         inline void createIBO()
00139         {
00140                 if (!m_IndexBuffer.isCreated() && !m_IndexVector.isEmpty())
00141                 {
00142                         m_IndexBuffer.create();
00143                 }
00144         }
00145 
00147         void useIBO() const;
00148 
00150         inline void fillIbo()
00151         {releaseIboClientSide(true);}
00152 
00154 
00156 // Private members
00158 private:
00159 
00161         double m_Accuracy;
00162 
00164         QGLBuffer m_IndexBuffer;
00165 
00167         QVector<GLuint> m_IndexVector;
00168 
00170         int m_IndexSize;
00171 
00173         unsigned int m_TrianglesCount;
00174 
00176         static quint32 m_ChunkId;
00177 
00178 };
00179 
00181 GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_Lod &);
00182 GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_Lod &);
00183 
00184 #endif /* GLC_LOD_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon