Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 61456598aee63b8ddf902d06357f6ff915075405 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
   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/color.h"
#include "math/vector3f.h"

namespace model {

const int SPHERESEGMENTS=33;

/// global vertex array
class VertexArray
{
public:
	/// create a new VertexArray with size in Mb
	VertexArray(size_t size);
	~VertexArray();

	void clear();

	void add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color);

	
	inline float *vertex() { return vertex_vertex; }
	inline float *color() { return vertex_color; }
	inline float *normal() { return vertex_normal; }
	inline float *texture() { return vertex_texture; }

	inline size_t size() const { return vertex_size; }
	inline size_t index() const { return vertex_index; }

	static inline VertexArray *instance() { return vertex_instance; }

private:
	/// model vertices
	float *vertex_vertex;
	float *vertex_color;
	float *vertex_normal;
	float *vertex_texture;

	size_t vertex_index;
	size_t vertex_size;
	
	void add_sphere();

	static VertexArray *vertex_instance;
};

}

#endif // __INCLUDED_MODEL_VERTEXARRAY_H__