24 #ifndef __GLIPLIB_GEOMETRY__
25 #define __GLIPLIB_GEOMETRY__
42 using namespace CoreGL;
44 namespace CorePipeline
71 std::vector<GLfloat> vertices,
74 std::vector<GLuint> elements;
78 GeometryModel(GeometryType _type,
int _dim, GLenum _primitiveGL,
bool _hasNormals,
bool _hasTexCoords);
80 void reserveVertices(
size_t nVertices);
81 void increaseVerticesReservation(
size_t nNewVertices);
82 void reserveElements(
size_t nVertices);
83 void increaseElementsReservation(
size_t nNewVertices);
84 void addVertices2DInterleaved(
const size_t N,
const GLfloat* interleavedXY,
const GLfloat* interleavedNormalsXY=NULL,
const GLfloat* interleavedUV=NULL);
85 void addVertices2D(
const size_t N,
const GLfloat* x,
const GLfloat* y,
const GLfloat* nx=NULL,
const GLfloat* ny=NULL,
const GLfloat* u=NULL,
const GLfloat* v=NULL);
86 GLuint addVertex2D(
const GLfloat& x,
const GLfloat& y,
const GLfloat& nx=0.0f,
const GLfloat& ny=0.0f,
const GLfloat& u=0.0f,
const GLfloat& v=0.0f);
87 void addVertices3DInterleaved(
const size_t N,
const GLfloat* interleavedXYZ,
const GLfloat* interleavedNormalsXYZ=NULL,
const GLfloat* interleavedUV=NULL);
88 void addVertices3D(
const size_t N,
const GLfloat* x,
const GLfloat* y,
const GLfloat* z,
const GLfloat* nx=NULL,
const GLfloat* ny=NULL,
const GLfloat* nz=NULL,
const GLfloat* u=NULL,
const GLfloat* v=NULL);
89 GLuint addVertex3D(
const GLfloat& x,
const GLfloat& y,
const GLfloat& z,
const GLfloat& nx=0.0f,
const GLfloat& ny=0.0f,
const GLfloat& nz=0.0f,
const GLfloat& u=0.0f,
const GLfloat& v=0.0f);
90 void addElementsInterleaved(
const size_t N, GLuint* interleavedIndices);
91 void addElements(
const size_t N, GLuint* a, GLuint* b=NULL, GLuint* c=NULL, GLuint* d=NULL);
92 GLuint addElement(GLuint a);
93 GLuint addElement(GLuint a, GLuint b);
94 GLuint addElement(GLuint a, GLuint b, GLuint c);
95 GLuint addElement(GLuint a, GLuint b, GLuint c, GLuint d);
96 GLuint addElement(
const std::vector<GLuint>& indices);
100 GLfloat& nx(GLuint i);
101 GLfloat& ny(GLuint i);
102 GLfloat& nz(GLuint i);
103 GLfloat& u(GLuint i);
104 GLfloat& v(GLuint i);
109 void generateNormals(
void);
115 const bool hasNormals,
130 unsigned int getNumVertices(
void)
const;
131 unsigned int getNumElements(
void)
const;
132 const GLenum& getGLPrimitive(
void)
const;
133 const GLfloat& x(GLuint i)
const;
134 const GLfloat& y(GLuint i)
const;
135 const GLfloat& z(GLuint i)
const;
136 const GLfloat& nx(GLuint i)
const;
137 const GLfloat& ny(GLuint i)
const;
138 const GLfloat& nz(GLuint i)
const;
139 const GLfloat& u(GLuint i)
const;
140 const GLfloat& v(GLuint i)
const;
141 const GLuint& a(GLuint i)
const;
142 const GLuint& b(GLuint i)
const;
143 const GLuint& c(GLuint i)
const;
144 const GLuint& d(GLuint i)
const;
145 bool testIndices(
void)
const;
148 HdlVBO* getVBO(GLenum freq)
const;
150 static int getNumVerticesInPrimitive(
const GLenum& _primitiveGL);
151 static int getPrimitiveStride(
const GLenum& _primitiveGL);
162 static int nextIndex;
163 static std::map<int, HdlVBO*> vbos;
164 static std::map<int, GeometryModel*> models;
165 static std::map<int, int> counters;
176 const HdlVBO& vbo(
void)
const;
181 namespace GeometryPrimitives
214 const bool normalized;
230 const bool normalized;
232 PointsGrid3D(
int w,
int h,
int d,
bool _normalized=
false);
243 CustomModel(
int _dim, GLenum _primitiveGL,
bool _hasNormals,
bool _hasTexCoords);
245 void reserveVertices(
size_t nVertices);
246 void increaseVerticesReservation(
size_t nNewVertices);
247 void reserveElements(
size_t nVertices);
248 void increaseElementsReservation(
size_t nNewVertices);
249 void newVertices2DInterleaved(
const size_t N,
const GLfloat* interleavedXY,
const GLfloat* interleavedNormalsXY=NULL,
const GLfloat* interleavedUV=NULL);
250 void newVertices2D(
const size_t N,
const GLfloat* x,
const GLfloat* y,
const GLfloat* nx=NULL,
const GLfloat* ny=NULL,
const GLfloat* u=NULL,
const GLfloat* v=NULL);
251 GLuint newVertex2D(
const GLfloat& x,
const GLfloat& y,
const GLfloat& nx=0.0f,
const GLfloat& ny=0.0f,
const GLfloat& u=0.0f,
const GLfloat& v=0.0f);
252 void newVertices3DInterleaved(
const size_t N,
const GLfloat* interleavedXYZ,
const GLfloat* interleavedNormalsXYZ=NULL,
const GLfloat* interleavedUV=NULL);
253 void newVertices3D(
const size_t N,
const GLfloat* x,
const GLfloat* y,
const GLfloat* z,
const GLfloat* nx=NULL,
const GLfloat* ny=NULL,
const GLfloat* nz=NULL,
const GLfloat* u=NULL,
const GLfloat* v=NULL);
254 GLuint newVertex3D(
const GLfloat& x,
const GLfloat& y,
const GLfloat& z,
const GLfloat& nx=0.0f,
const GLfloat& ny=0.0f,
const GLfloat& nz=0.0f,
const GLfloat& u=0.0f,
const GLfloat& v=0.0f);
255 void newElementsInterleaved(
const size_t N, GLuint* interleavedIndices);
256 void newElements(
const size_t N, GLuint* a, GLuint* b=NULL, GLuint* c=NULL, GLuint* d=NULL);
257 GLuint newElement(GLuint a);
258 GLuint newElement(GLuint a, GLuint b);
259 GLuint newElement(GLuint a, GLuint b, GLuint c);
260 GLuint newElement(GLuint a, GLuint b, GLuint c, GLuint d);
261 GLuint newElement(
const std::vector<GLuint>& indices);
262 void generateNormals(
void);
Instance of the GeometryModel. Stored on GPU (VBO).
Definition: Geometry.hpp:158
GeometryType
Description of the type of geometry (automatic).
Definition: Geometry.hpp:54
Object handle for OpenGL Vertex Buffer Objects.
Definition: HdlVBO.hpp:41
3D grid of dots.
Definition: Geometry.hpp:65
Definition: Component.hpp:32
Reversed quad, covering the area between (-1,-1) and (1,1).
Definition: Geometry.hpp:61
Geometry : the standard quad, covering the area between (-1,-1) and (1,1).
Definition: Geometry.hpp:187
Geometry : a 3D grid of points.
Definition: Geometry.hpp:224
Geometry : a 2D grid of points.
Definition: Geometry.hpp:209
const GLenum primitiveGL
ID of the primitive for GL.
Definition: Geometry.hpp:125
2D grid of dots.
Definition: Geometry.hpp:63
Geometry : build a model.
Definition: Geometry.hpp:240
const bool hasTexCoords
Dimension of the geometry (either 2 or 3).
Definition: Geometry.hpp:115
OpenGL Pixel Buffer Object Handle.
Custom model.
Definition: Geometry.hpp:57
const GeometryType type
Geometry Type.
Definition: Geometry.hpp:113
Geometry stored on the host.
Definition: Geometry.hpp:50
Standard quad, covering the area between (-1,-1) and (1,1).
Definition: Geometry.hpp:59
OpenGL includes and tools.
const int numVerticesPerElement
Number of vertices per elements of the geometry.
Definition: Geometry.hpp:119
Geometry : the reversed quad, covering the area between (-1,-1) and (1,1).
Definition: Geometry.hpp:198