ovr_sdk

view LibOVR/Src/Kernel/OVR_Color.h @ 0:1b39a1b46319

initial 0.4.4
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 Jan 2015 06:51:16 +0200
parents
children
line source
1 /************************************************************************************
3 PublicHeader: OVR_Kernel.h
4 Filename : OVR_Color.h
5 Content : Contains color struct.
6 Created : February 7, 2013
7 Notes :
9 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
11 Licensed under the Oculus VR Rift SDK License Version 3.2 (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.
16 You may obtain a copy of the License at
18 http://www.oculusvr.com/licenses/LICENSE-3.2
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.
26 ************************************************************************************/
27 #ifndef OVR_Color_h
28 #define OVR_Color_h
30 #include "OVR_Types.h"
32 namespace OVR {
35 struct Color
36 {
37 uint8_t R,G,B,A;
39 Color()
40 {
41 #if defined(OVR_BUILD_DEBUG)
42 R = G = B = A = 0;
43 #endif
44 }
46 // Constructs color by channel. Alpha is set to 0xFF (fully visible)
47 // if not specified.
48 Color(unsigned char r,unsigned char g,unsigned char b, unsigned char a = 0xFF)
49 : R(r), G(g), B(b), A(a) { }
51 // 0xAARRGGBB - Common HTML color Hex layout
52 Color(unsigned c)
53 : R((unsigned char)(c>>16)), G((unsigned char)(c>>8)),
54 B((unsigned char)c), A((unsigned char)(c>>24)) { }
56 bool operator==(const Color& b) const
57 {
58 return R == b.R && G == b.G && B == b.B && A == b.A;
59 }
61 void GetRGBA(float *r, float *g, float *b, float* a) const
62 {
63 *r = R / 255.0f;
64 *g = G / 255.0f;
65 *b = B / 255.0f;
66 *a = A / 255.0f;
67 }
68 };
71 } // namespace OVR
73 #endif