Ogre::Bitwise Class Reference
Core » Math

Class for manipulating bit patterns. More...

`#include <OgreBitwise.h>`

## Static Public Member Functions

template<typename SrcT , typename DestT >
static DestT | convertBitPattern (SrcT srcValue, SrcT srcBitMask, DestT destBitMask)
| Takes a value with a given src bit mask, and produces another value with a desired bit mask. More...
static FORCEINLINE uint32 | firstPO2From (uint32 n)
| Returns the closest power-of-two number greater or equal to value. More...
static unsigned int | fixedToFixed (uint32 value, unsigned int n, unsigned int p)
| Convert N bit colour channel value to P bits. More...
static float | fixedToFloat (unsigned value, unsigned int bits)
| Fixed point to float. More...
static unsigned int | floatToFixed (const float value, const unsigned int bits)
| Convert floating point colour channel value between 0.0 and 1.0 (otherwise clamped) to integer of a certain number of bits. More...
static uint16 | floatToHalf (float i)
| Convert a float32 to a float16 (NV_half_float) Courtesy of OpenEXR. More...
static uint16 | floatToHalfI (uint32 i)
| Converts float in uint32 format to a a half in uint16 format. More...
template<typename T >
static FORCEINLINE unsigned int | getBitShift (T mask)
| Returns the number of bits a pattern must be shifted right by to remove right-hand zeros. More...
static float | halfToFloat (uint16 y)
| Convert a float16 (NV_half_float) to a float32 Courtesy of OpenEXR. More...
static uint32 | halfToFloatI (uint16 y)
| Converts a half in uint16 format to a float in uint32 format. More...
static unsigned int | intRead (const void *src, int n)
| Read a n*8 bits integer value to memory in native endian. More...
static void | intWrite (void *dest, const int n, const unsigned int value)
| Write a n*8 bits integer value to memory in native endian. More...
template<typename T >
static FORCEINLINE bool | isPO2 (T n)
| Determines whether the number is power-of-two or not. More...
static FORCEINLINE unsigned int | mostSignificantBitSet (unsigned int value)
| Returns the most significant bit set in a value. More...

## Detailed Description

Class for manipulating bit patterns.

Definition at line 43 of file OgreBitwise.h.

## Member Function Documentation

## convertBitPattern()

template<typename SrcT , typename DestT >

static DestT Ogre::Bitwise::convertBitPattern | ( | SrcT | srcValue,
|  | SrcT | srcBitMask,
|  | DestT | destBitMask
| ) |  |

static

Takes a value with a given src bit mask, and produces another value with a desired bit mask.

Remarks
  This routine is useful for colour conversion.

Definition at line 102 of file OgreBitwise.h.

References getBitShift().

## firstPO2From()

static FORCEINLINE uint32 Ogre::Bitwise::firstPO2From | ( | uint32 | n | ) |

static

Returns the closest power-of-two number greater or equal to value.

Note
  0 and 1 are powers of two, so firstPO2From(0)==0 and firstPO2From(1)==1.

Definition at line 60 of file OgreBitwise.h.

## fixedToFixed()

static unsigned int Ogre::Bitwise::fixedToFixed | ( | uint32 | value,
|  | unsigned int | n,
|  | unsigned int | p
| ) |  |

static

Convert N bit colour channel value to P bits.

It fills P bits with the bit pattern repeated. (this is /((1<<n)-1) in fixed point)

Definition at line 127 of file OgreBitwise.h.

## fixedToFloat()

static float Ogre::Bitwise::fixedToFloat | ( | unsigned | value,
|  | unsigned int | bits
| ) |  |

static

Fixed point to float.

Definition at line 161 of file OgreBitwise.h.

## floatToFixed()

static unsigned int Ogre::Bitwise::floatToFixed | ( | const float | value,
|  | const unsigned int | bits
| ) |  |

static

Convert floating point colour channel value between 0.0 and 1.0 (otherwise clamped) to integer of a certain number of bits.

Works for any value of bits between 0 and 31.

Definition at line 151 of file OgreBitwise.h.

## floatToHalf()

static uint16 Ogre::Bitwise::floatToHalf | ( | float | i | ) |

static

Convert a float32 to a float16 (NV_half_float) Courtesy of OpenEXR.

Definition at line 222 of file OgreBitwise.h.

References floatToHalfI().

## floatToHalfI()

static uint16 Ogre::Bitwise::floatToHalfI | ( | uint32 | i | ) |

static

Converts float in uint32 format to a a half in uint16 format.

Definition at line 230 of file OgreBitwise.h.

Referenced by floatToHalf().

## getBitShift()

template<typename T >

static FORCEINLINE unsigned int Ogre::Bitwise::getBitShift | ( | T | mask | ) |

static

Returns the number of bits a pattern must be shifted right by to remove right-hand zeros.

Definition at line 83 of file OgreBitwise.h.

Referenced by convertBitPattern().

## halfToFloat()

static float Ogre::Bitwise::halfToFloat | ( | uint16 | y | ) |

static

Convert a float16 (NV_half_float) to a float32 Courtesy of OpenEXR.

Definition at line 273 of file OgreBitwise.h.

References halfToFloatI().

## halfToFloatI()

static uint32 Ogre::Bitwise::halfToFloatI | ( | uint16 | y | ) |

static

Converts a half in uint16 format to a float in uint32 format.

Definition at line 282 of file OgreBitwise.h.

Referenced by halfToFloat().

## intRead()

static unsigned int Ogre::Bitwise::intRead | ( | const void * | src,
|  | int | n
| ) |  |

static

Read a n*8 bits integer value to memory in native endian.

Definition at line 197 of file OgreBitwise.h.

## intWrite()

static void Ogre::Bitwise::intWrite | ( | void * | dest,
|  | const int | n,
|  | const unsigned int | value
| ) |  |

static

Write a n*8 bits integer value to memory in native endian.

Definition at line 169 of file OgreBitwise.h.

## isPO2()

template<typename T >

static FORCEINLINE bool Ogre::Bitwise::isPO2 | ( | T | n | ) |

static

Determines whether the number is power-of-two or not.

Note
  0 and 1 are tread as power of two.

Definition at line 75 of file OgreBitwise.h.

## mostSignificantBitSet()

static FORCEINLINE unsigned int Ogre::Bitwise::mostSignificantBitSet | ( | unsigned int | value | ) |

static

Returns the most significant bit set in a value.

Definition at line 47 of file OgreBitwise.h.

The documentation for this class was generated from the following file:

- OgreBitwise.h

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.