Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

glsurface.h

00001 /***************************************************************************
00002                           glsurface.h  -  description
00003                              -------------------
00004     begin                : Sun Aug 17 2003
00005     copyright            : (C) 2003 by Jacques Gasselin de Richebourg
00006     email                : jacquesgasselin@hotmail.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU Lesser General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *
00024  *                                                                         *
00025  ***************************************************************************/
00026 
00027 #ifndef GLSURFACE_H
00028 #define GLSURFACE_H
00029 
00030 #include <vector>
00031 #include "glgeometricobject.h"
00032 #include "glvertexarray.h"
00033 #include "gldisplaylist.h"
00034 
00039 namespace GLScene
00040 {
00041    
00042    class GLSurfaceGenerator
00043    {
00044    public:
00045       virtual ~GLSurfaceGenerator() {}
00053       virtual void getVertecies(const GLfloat u, const GLuint nOfV, GLfloat* const verts3) const = 0;
00055       virtual void getNormals(const GLfloat u, const GLuint nOfN, GLfloat* const normals3) const = 0;
00056    };
00057 
00058    class GLSurface: public ReferenceCounted
00059    {
00060       //allocates a lot of system memory
00061       GLfloat* verts;
00062       GLfloat* norms;
00063       GLfloat* texcoords;
00064       GLuint* ind;
00065       GLuint slices;
00066       GLuint vertsPerSlice;
00067       unsigned nOfVerts3;
00068       unsigned nOfVerts2;
00069       unsigned indexSize;
00070 
00071       GLVertexArray vArray;
00072       //allocates very little memory
00073       GLDisplayList pDispList, fDispList, tDispList;
00074       //p = point and line, f = fill
00075       GLSurfaceGenerator* gen;
00076 
00077       unsigned lod, prevLod;
00078       bool invalidSurface;
00079       // need to regenerate vertecies etc. if TRUE
00080 
00081    public: 
00082 
00083       GLSurface();
00084       virtual ~GLSurface();
00085 
00086       inline void setGenerator(GLSurfaceGenerator* g) { gen = g; }
00087 
00088       void setLOD(unsigned l)
00089       { if( (l+1) == lod ) return; lod = (l+1); invalidate(); }   
00090       
00091       void invalidate( void ) { invalidSurface = true; pDispList.del(); fDispList.del(); tDispList.del(); }
00092       void validate( void ) { invalidSurface = false; }
00093       
00094       virtual void render(const GLRenderMode pm);
00095       void renderForSelection(GLuint& previousName);
00096 
00097       private:
00098 
00099       void generate( void );
00100       void index( void ) const;
00101 
00102       void drawVerts( void ) const;
00103       void drawVertsNorms( void ) const;
00104       void drawVertsNormsTexs( void ) const;
00105                            
00106    };
00107 
00108 };
00109    
00110 #endif

Generated on Wed Feb 4 23:11:33 2004 by doxygen 1.3.3