• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***************************************************************************
2  *
3  * Copyright 2010,2011 BMW Car IT GmbH
4  * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ****************************************************************************/
20 #ifndef _VEC_H
21 #define _VEC_H
22 
23 #include <GLES2/gl2.h>
24 
25 template <class T>
26 class vec2
27 {
28 public:
vec2()29     vec2()
30     {
31     }
32 
vec2(T _x,T _y)33     vec2(T _x, T _y)
34     : x(_x)
35     , y(_y)
36     {
37     }
38 
39     struct
40     {
41         T x;
42         T y;
43     };
44 };
45 
46 template <class T>
47 class vec3
48 {
49 public:
vec3()50     vec3()
51     {
52     }
53 
vec3(T _x,T _y,T _z)54     vec3(T _x, T _y, T _z)
55     : x(_x)
56     , y(_y)
57     , z(_z)
58     {
59     }
60 
61     union
62     {
63         struct
64         {
65             T x;
66             T y;
67             T z;
68         };
69         struct
70         {
71             T r;
72             T g;
73             T b;
74         };
75     };
76 };
77 
78 template <class T>
79 class vec4
80 {
81 public:
vec4()82     vec4()
83     {
84     }
85 
vec4(T _x,T _y,T _z,T _w)86     vec4(T _x, T _y, T _z, T _w)
87     : x(_x)
88     , y(_y)
89     , z(_z)
90     , w(_w)
91     {
92     }
93 
94     union
95     {
96         struct
97         {
98             T x;
99             T y;
100             T z;
101             T w;
102         };
103         struct
104         {
105             T r;
106             T g;
107             T b;
108             T a;
109         };
110     };
111 };
112 
113 typedef vec2<GLfloat> vec2f;
114 typedef vec2<GLint>   vec2i;
115 typedef vec2<GLushort>  vec2u;
116 
117 typedef vec3<GLfloat> vec3f;
118 typedef vec3<GLint>   vec3i;
119 typedef vec3<GLushort>  vec3u;
120 
121 typedef vec4<GLfloat> vec4f;
122 typedef vec4<GLint>   vec4i;
123 typedef vec4<GLushort>  vec4u;
124 
125 #endif /* _VEC_H */
126