Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | List of all members
G3D::unorm8 Class Reference

Represents numbers on [0, 1] in 8 bits as an unsigned normalized 0.8 fixed-point value using the same encoding scheme as OpenGL. More...

Public Member Functions

 unorm8 ()
 
 unorm8 (const unorm8 &other)
 
 unorm8 (float f)
 Maps f to round(f * 255). More...
 
 unorm8 (double f)
 
uint8 bits () const
 Returns the underlying bits in this representation. More...
 
 operator double () const
 
 operator float () const
 Returns a number on [0.0f, 1.0f]. More...
 
bool operator!= (const unorm8 other) const
 
unorm8 operator* (const int i) const
 
unorm8operator*= (const int i)
 
unorm8 operator+ (const unorm8 other) const
 
unorm8operator+= (const unorm8 other)
 
unorm8 operator- (const unorm8 other) const
 
unorm8operator-= (const unorm8 other)
 
unorm8 operator/ (const int i) const
 
unorm8operator/= (const int i)
 
bool operator< (const unorm8 other) const
 
unorm8 operator<< (const int i) const
 
unorm8operator<<= (const int i)
 
bool operator<= (const unorm8 other) const
 
bool operator== (const unorm8 other) const
 
bool operator> (const unorm8 other) const
 
bool operator>= (const unorm8 other) const
 
unorm8 operator>> (const int i) const
 
unorm8operator>>= (const int i)
 
uint8 reinterpretAsUInt8 () const
 Returns the underlying bits in this representation.
More...
 

Static Public Member Functions

static unorm8 fromBits (uint8 b)
 Equivalent to: More...
 
static unorm8 one ()
 
static unorm8 reinterpretFrom (uint8 b)
 Equivalent to:
More...
 
static unorm8 zero ()
 

Detailed Description

Represents numbers on [0, 1] in 8 bits as an unsigned normalized 0.8 fixed-point value using the same encoding scheme as OpenGL.

OpenGL specifications can be found here: <www.opengl.org/registry/specs/ARB/shading_language_packing.txt>

Note that arithmetic operations may over and under-flow, just like uint8 arithmetic.

Constructor & Destructor Documentation

◆ unorm8() [1/4]

G3D::unorm8::unorm8 ( )
inline

◆ unorm8() [2/4]

G3D::unorm8::unorm8 ( const unorm8 other)
inline

◆ unorm8() [3/4]

G3D::unorm8::unorm8 ( float  f)
inlineexplicit

Maps f to round(f * 255).

◆ unorm8() [4/4]

G3D::unorm8::unorm8 ( double  f)
inlineexplicit

Member Function Documentation

◆ bits()

uint8 G3D::unorm8::bits ( ) const
inline

Returns the underlying bits in this representation.

Equivalent to:

uint8 i = reinterpret_cast<const uint8&>(u);

Referenced by G3D::Color4unorm8::asUInt32(), G3D::Color3unorm8::asUInt32(), and G3D::BinaryOutput::writeUNorm8().

◆ fromBits()

static unorm8 G3D::unorm8::fromBits ( uint8  b)
inlinestatic

Equivalent to:

unorm8 u = reinterpret_cast<const unorm8&>(255);

Referenced by G3D::Color4unorm8::fromARGB(), G3D::Color3unorm8::fromARGB(), and G3D::BinaryInput::readUNorm8().

◆ one()

static unorm8 G3D::unorm8::one ( )
inlinestatic

◆ operator double()

G3D::unorm8::operator double ( ) const
inline

◆ operator float()

G3D::unorm8::operator float ( ) const
inline

Returns a number on [0.0f, 1.0f].

◆ operator!=()

bool G3D::unorm8::operator!= ( const unorm8  other) const
inline

◆ operator*()

unorm8 G3D::unorm8::operator* ( const int  i) const
inline

◆ operator*=()

unorm8& G3D::unorm8::operator*= ( const int  i)
inline

◆ operator+()

unorm8 G3D::unorm8::operator+ ( const unorm8  other) const
inline

◆ operator+=()

unorm8& G3D::unorm8::operator+= ( const unorm8  other)
inline

◆ operator-()

unorm8 G3D::unorm8::operator- ( const unorm8  other) const
inline

◆ operator-=()

unorm8& G3D::unorm8::operator-= ( const unorm8  other)
inline

◆ operator/()

unorm8 G3D::unorm8::operator/ ( const int  i) const
inline

◆ operator/=()

unorm8& G3D::unorm8::operator/= ( const int  i)
inline

◆ operator<()

bool G3D::unorm8::operator< ( const unorm8  other) const
inline

◆ operator<<()

unorm8 G3D::unorm8::operator<< ( const int  i) const
inline

◆ operator<<=()

unorm8& G3D::unorm8::operator<<= ( const int  i)
inline

◆ operator<=()

bool G3D::unorm8::operator<= ( const unorm8  other) const
inline

◆ operator==()

bool G3D::unorm8::operator== ( const unorm8  other) const
inline

◆ operator>()

bool G3D::unorm8::operator> ( const unorm8  other) const
inline

◆ operator>=()

bool G3D::unorm8::operator>= ( const unorm8  other) const
inline

◆ operator>>()

unorm8 G3D::unorm8::operator>> ( const int  i) const
inline

◆ operator>>=()

unorm8& G3D::unorm8::operator>>= ( const int  i)
inline

◆ reinterpretAsUInt8()

uint8 G3D::unorm8::reinterpretAsUInt8 ( ) const
inline

Returns the underlying bits in this representation.

Equivalent to:

uint8 i = reinterpret_cast<const uint8&>(u);

◆ reinterpretFrom()

static unorm8 G3D::unorm8::reinterpretFrom ( uint8  b)
inlinestatic

Equivalent to:

unorm8 u = reinterpret_cast<const unorm8&>(255);

◆ zero()

static unorm8 G3D::unorm8::zero ( )
inlinestatic

documentation generated on Wed Nov 24 2021 08:02:01 using doxygen 1.8.15