00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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
00073 GLDisplayList pDispList, fDispList, tDispList;
00074
00075 GLSurfaceGenerator* gen;
00076
00077 unsigned lod, prevLod;
00078 bool invalidSurface;
00079
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