/* model/vertexarray.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_MODEL_VERTEXARRAY_H__ #define __INCLUDED_MODEL_VERTEXARRAY_H__ #include "math/vector3f.h" namespace model { // number of segments in a sphere circle, must be uneven const int SPHERESEGMENTS = 65; /// global vertex array /** a VertexArray acts like a stack of model vertices, it has no knowledge of what it is holding */ class VertexArray { public: /// create a new VertexArray with size in Mb VertexArray(size_t size); ~VertexArray(); void clear(); size_t add_vertex(math::Vector3f const &v, math::Vector3f const &n, float tex_x=0.0f, float tex_y=0.0f); inline float *vertex() { return vertex_vertex; } inline float *normal() { return vertex_normal; } inline float *texture() { return vertex_texture; } inline bool overflow() const { return vertex_overflow; } /// size of the vertex array in number of floats (for a single array) inline size_t size() const { return vertex_size; } /// number of allocated floats inline size_t index() const { return vertex_index; } static inline VertexArray *instance() { return vertex_instance; } private: /// model vertices float *vertex_vertex; float *vertex_normal; float *vertex_texture; size_t vertex_index; size_t vertex_size; void add_sphere(); static VertexArray *vertex_instance; bool vertex_overflow; }; } #endif // __INCLUDED_MODEL_VERTEXARRAY_H__