nuclear@3: /************************************************************************************ nuclear@3: nuclear@3: PublicHeader: OVR.h nuclear@3: Filename : OVR_Color.h nuclear@3: Content : Contains color struct. nuclear@3: Created : February 7, 2013 nuclear@3: Notes : nuclear@3: nuclear@3: Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved. nuclear@3: nuclear@3: Use of this software is subject to the terms of the Oculus license nuclear@3: agreement provided at the time of installation or download, or which nuclear@3: otherwise accompanies this software in either electronic or hard copy form. nuclear@3: nuclear@3: ************************************************************************************/ nuclear@3: #ifndef OVR_Color_h nuclear@3: #define OVR_Color_h nuclear@3: nuclear@3: #include "OVR_Types.h" nuclear@3: nuclear@3: namespace OVR { nuclear@3: nuclear@3: struct Color nuclear@3: { nuclear@3: UByte R,G,B,A; nuclear@3: nuclear@3: Color() {} nuclear@3: nuclear@3: // Constructs color by channel. Alpha is set to 0xFF (fully visible) nuclear@3: // if not specified. nuclear@3: Color(unsigned char r,unsigned char g,unsigned char b, unsigned char a = 0xFF) nuclear@3: : R(r), G(g), B(b), A(a) { } nuclear@3: nuclear@3: // 0xAARRGGBB - Common HTML color Hex layout nuclear@3: Color(unsigned c) nuclear@3: : R((unsigned char)(c>>16)), G((unsigned char)(c>>8)), nuclear@3: B((unsigned char)c), A((unsigned char)(c>>24)) { } nuclear@3: nuclear@3: bool operator==(const Color& b) const nuclear@3: { nuclear@3: return R == b.R && G == b.G && B == b.B && A == b.A; nuclear@3: } nuclear@3: nuclear@3: void GetRGBA(float *r, float *g, float *b, float* a) const nuclear@3: { nuclear@3: *r = R / 255.0f; nuclear@3: *g = G / 255.0f; nuclear@3: *b = B / 255.0f; nuclear@3: *a = A / 255.0f; nuclear@3: } nuclear@3: }; nuclear@3: nuclear@3: } nuclear@3: nuclear@3: #endif