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 "../glc_ext.h"
00030 
00031 #include "../glc_config.h"
00032 
00035 
00036 
00037 class GLC_LIB_EXPORT GLC_Lod
00038 {
00039         friend GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_Lod &);
00040         friend GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_Lod &);
00041 
00042 public:
00044 
00046 
00047 public:
00049         GLC_Lod();
00050 
00052         GLC_Lod(double accuracy);
00053 
00055         GLC_Lod(const GLC_Lod&);
00056 
00058         GLC_Lod& operator=(const GLC_Lod&);
00059 
00061         virtual ~GLC_Lod();
00063 
00065 
00067 
00068 public:
00070         static quint32 chunckID();
00071 
00073         inline double accuracy() const
00074         {return m_Accuracy;}
00075 
00077 
00082         QVector<GLuint> indexVector() const;
00083 
00085 
00090         inline QVector<GLuint>* indexVectorHandle()
00091         { return &m_IndexVector;}
00092 
00094         inline int indexVectorSize() const
00095         {return m_IndexVector.size();}
00096 
00098         inline unsigned int trianglesCount() const
00099         {return m_TrianglesCount;}
00100 
00102 
00104 
00106 
00107 public:
00109         void copyIboToClientSide();
00110 
00112         void releaseIboClientSide(bool update= false);
00113 
00115         inline void finishVbo()
00116         {
00117                 m_IndexSize= m_IndexVector.size();
00118                 m_IndexVector.clear();
00119         }
00121         inline void setAccuracy(const double& accuracy)
00122         {m_Accuracy= accuracy;}
00123 
00125         inline void trianglesAdded(unsigned int count)
00126         {
00127                 m_TrianglesCount+= count;
00128         }
00129 
00130 
00132 
00134 
00136 
00137 public:
00139         inline void createIBO()
00140         {
00141                 if (0 == m_IboId && !m_IndexVector.isEmpty())
00142                 {
00143                         glGenBuffers(1, &m_IboId);
00144                 }
00145         }
00146 
00148         inline void useIBO() const
00149         {glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IboId);}
00150 
00152 
00154 // Private members
00156 private:
00157 
00159         double m_Accuracy;
00160 
00162         GLuint m_IboId;
00163 
00165         QVector<GLuint> m_IndexVector;
00166 
00168         int m_IndexSize;
00169 
00171         unsigned int m_TrianglesCount;
00172 
00174         static quint32 m_ChunkId;
00175 
00176 };
00177 
00179 GLC_LIB_EXPORT QDataStream &operator<<(QDataStream &, const GLC_Lod &);
00180 GLC_LIB_EXPORT QDataStream &operator>>(QDataStream &, GLC_Lod &);
00181 
00182 #endif /* GLC_LOD_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon