rev |
line source |
nuclear@0
|
1 /************************************************************************************
|
nuclear@0
|
2
|
nuclear@0
|
3 PublicHeader: OVR_Kernel.h
|
nuclear@0
|
4 Filename : OVR_Color.h
|
nuclear@0
|
5 Content : Contains color struct.
|
nuclear@0
|
6 Created : February 7, 2013
|
nuclear@0
|
7 Notes :
|
nuclear@0
|
8
|
nuclear@0
|
9 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
|
nuclear@0
|
10
|
nuclear@0
|
11 Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
|
nuclear@0
|
12 you may not use the Oculus VR Rift SDK except in compliance with the License,
|
nuclear@0
|
13 which is provided at the time of installation or download, or which
|
nuclear@0
|
14 otherwise accompanies this software in either electronic or hard copy form.
|
nuclear@0
|
15
|
nuclear@0
|
16 You may obtain a copy of the License at
|
nuclear@0
|
17
|
nuclear@0
|
18 http://www.oculusvr.com/licenses/LICENSE-3.2
|
nuclear@0
|
19
|
nuclear@0
|
20 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
|
nuclear@0
|
21 distributed under the License is distributed on an "AS IS" BASIS,
|
nuclear@0
|
22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
nuclear@0
|
23 See the License for the specific language governing permissions and
|
nuclear@0
|
24 limitations under the License.
|
nuclear@0
|
25
|
nuclear@0
|
26 ************************************************************************************/
|
nuclear@0
|
27 #ifndef OVR_Color_h
|
nuclear@0
|
28 #define OVR_Color_h
|
nuclear@0
|
29
|
nuclear@0
|
30 #include "OVR_Types.h"
|
nuclear@0
|
31
|
nuclear@0
|
32 namespace OVR {
|
nuclear@0
|
33
|
nuclear@0
|
34
|
nuclear@0
|
35 struct Color
|
nuclear@0
|
36 {
|
nuclear@0
|
37 uint8_t R,G,B,A;
|
nuclear@0
|
38
|
nuclear@0
|
39 Color()
|
nuclear@0
|
40 {
|
nuclear@0
|
41 #if defined(OVR_BUILD_DEBUG)
|
nuclear@0
|
42 R = G = B = A = 0;
|
nuclear@0
|
43 #endif
|
nuclear@0
|
44 }
|
nuclear@0
|
45
|
nuclear@0
|
46 // Constructs color by channel. Alpha is set to 0xFF (fully visible)
|
nuclear@0
|
47 // if not specified.
|
nuclear@0
|
48 Color(unsigned char r,unsigned char g,unsigned char b, unsigned char a = 0xFF)
|
nuclear@0
|
49 : R(r), G(g), B(b), A(a) { }
|
nuclear@0
|
50
|
nuclear@0
|
51 // 0xAARRGGBB - Common HTML color Hex layout
|
nuclear@0
|
52 Color(unsigned c)
|
nuclear@0
|
53 : R((unsigned char)(c>>16)), G((unsigned char)(c>>8)),
|
nuclear@0
|
54 B((unsigned char)c), A((unsigned char)(c>>24)) { }
|
nuclear@0
|
55
|
nuclear@0
|
56 bool operator==(const Color& b) const
|
nuclear@0
|
57 {
|
nuclear@0
|
58 return R == b.R && G == b.G && B == b.B && A == b.A;
|
nuclear@0
|
59 }
|
nuclear@0
|
60
|
nuclear@0
|
61 void GetRGBA(float *r, float *g, float *b, float* a) const
|
nuclear@0
|
62 {
|
nuclear@0
|
63 *r = R / 255.0f;
|
nuclear@0
|
64 *g = G / 255.0f;
|
nuclear@0
|
65 *b = B / 255.0f;
|
nuclear@0
|
66 *a = A / 255.0f;
|
nuclear@0
|
67 }
|
nuclear@0
|
68 };
|
nuclear@0
|
69
|
nuclear@0
|
70
|
nuclear@0
|
71 } // namespace OVR
|
nuclear@0
|
72
|
nuclear@0
|
73 #endif
|