]> git.tdb.fi Git - libs/gl.git/blob - source/vector.h
Add conversion from Vector4 to Vector3
[libs/gl.git] / source / vector.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_VECTOR_H_
9 #define MSP_GL_VECTOR_H_
10
11 namespace Msp {
12 namespace GL {
13
14 struct Vector4;
15
16 struct Vector3
17 {
18         float x, y, z;
19
20         Vector3(): x(0), y(0), z(0) { }
21         Vector3(float x_, float y_, float z_): x(x_), y(y_), z(z_) { }
22         Vector3(const Vector4 &);
23 };
24
25 struct Vector4
26 {
27         float x, y, z, w;
28
29         Vector4(): x(0), y(0), z(0), w(1) { }
30         Vector4(float x_, float y_, float z_): x(x_), y(y_), z(z_), w(1) { }
31         Vector4(float x_, float y_, float z_, float w_): x(x_), y(y_), z(z_), w(w_) { }
32         Vector4(const Vector3 &v): x(v.x), y(v.y), z(v.z), w(1) { }
33 };
34
35 inline Vector3::Vector3(const Vector4 &v):
36         x(v.x/v.w), y(v.y/v.w), z(v.z/v.w)
37 { }
38
39 } // namespace GL
40 } // namespace Msp
41
42 #endif