ovr_sdk

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/LibOVR/Src/Kernel/OVR_Color.h	Wed Jan 14 06:51:16 2015 +0200
     1.3 @@ -0,0 +1,73 @@
     1.4 +/************************************************************************************
     1.5 +
     1.6 +PublicHeader:   OVR_Kernel.h
     1.7 +Filename    :   OVR_Color.h
     1.8 +Content     :   Contains color struct.
     1.9 +Created     :   February 7, 2013
    1.10 +Notes       : 
    1.11 +
    1.12 +Copyright   :   Copyright 2014 Oculus VR, LLC All Rights reserved.
    1.13 +
    1.14 +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); 
    1.15 +you may not use the Oculus VR Rift SDK except in compliance with the License, 
    1.16 +which is provided at the time of installation or download, or which 
    1.17 +otherwise accompanies this software in either electronic or hard copy form.
    1.18 +
    1.19 +You may obtain a copy of the License at
    1.20 +
    1.21 +http://www.oculusvr.com/licenses/LICENSE-3.2 
    1.22 +
    1.23 +Unless required by applicable law or agreed to in writing, the Oculus VR SDK 
    1.24 +distributed under the License is distributed on an "AS IS" BASIS,
    1.25 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.26 +See the License for the specific language governing permissions and
    1.27 +limitations under the License.
    1.28 +
    1.29 +************************************************************************************/
    1.30 +#ifndef OVR_Color_h
    1.31 +#define OVR_Color_h
    1.32 +
    1.33 +#include "OVR_Types.h"
    1.34 +
    1.35 +namespace OVR {
    1.36 +
    1.37 +
    1.38 +struct Color
    1.39 +{
    1.40 +    uint8_t R,G,B,A;
    1.41 +
    1.42 +    Color()
    1.43 +    {
    1.44 +        #if defined(OVR_BUILD_DEBUG)
    1.45 +            R = G = B = A = 0;
    1.46 +        #endif
    1.47 +    }
    1.48 +
    1.49 +    // Constructs color by channel. Alpha is set to 0xFF (fully visible)
    1.50 +    // if not specified.
    1.51 +    Color(unsigned char r,unsigned char g,unsigned char b, unsigned char a = 0xFF)
    1.52 +        : R(r), G(g), B(b), A(a) { }
    1.53 +
    1.54 +    // 0xAARRGGBB - Common HTML color Hex layout
    1.55 +    Color(unsigned c)
    1.56 +        : R((unsigned char)(c>>16)), G((unsigned char)(c>>8)),
    1.57 +        B((unsigned char)c), A((unsigned char)(c>>24)) { }
    1.58 +
    1.59 +    bool operator==(const Color& b) const
    1.60 +    {
    1.61 +        return R == b.R && G == b.G && B == b.B && A == b.A;
    1.62 +    }
    1.63 +
    1.64 +    void  GetRGBA(float *r, float *g, float *b, float* a) const
    1.65 +    {
    1.66 +        *r = R / 255.0f;
    1.67 +        *g = G / 255.0f;
    1.68 +        *b = B / 255.0f;
    1.69 +        *a = A / 255.0f;
    1.70 +    }
    1.71 +};
    1.72 +
    1.73 +
    1.74 +} // namespace OVR
    1.75 +
    1.76 +#endif