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