Loading...
Searching...
No Matches
Ogre::Bitwise Class Reference
Core » Math

Class for manipulating bit patterns. More...

`#include <OgreBitwise.h>`

## Static Public Member Functions

static uint16 | bswap16 (uint16 arg)
| Returns value with reversed bytes order.
static uint32 | bswap32 (uint32 arg)
| Returns value with reversed bytes order.
static uint64 | bswap64 (uint64 arg)
| Returns value with reversed bytes order.
static void | bswapBuffer (void *pData, size_t size)
| Reverses byte order of buffer.
static void | bswapChunks (void *pData, size_t size, size_t count)
| Reverses byte order of chunks in buffer, where 'size' is size of one chunk.
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.
static uint32 | firstPO2From (uint32 n)
| Returns the closest power-of-two number greater or equal to value.
static unsigned int | fixedToFixed (uint32 value, unsigned int n, unsigned int p)
| Convert N bit colour channel value to P bits.
static float | fixedToFloat (unsigned value, unsigned int bits)
| Fixed point to float.
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.
static uint16 | floatToHalf (float i)
| Convert a float32 to a float16 (NV_half_float) Courtesy of meshoptimizer.
static uint16 | floatToHalfI (uint32 ui)
| Converts float in uint32 format to a a half in uint16 format.
template<typename T>
static unsigned int | getBitShift (T mask)
| Returns the number of bits a pattern must be shifted right by to remove right-hand zeros.
static float | halfToFloat (uint16 y)
| Convert a float16 (NV_half_float) to a float32 Courtesy of meshoptimizer.
static uint32 | halfToFloatI (uint16 h)
| Converts a half in uint16 format to a float in uint32 format.
static unsigned int | intRead (const void *src, int n)
| Read a n*8 bits integer value to memory in native endian.
static void | intWrite (void *dest, const int n, const unsigned int value)
| Write a n*8 bits integer value to memory in native endian.
template<typename T>
static bool | isPO2 (T n)
| Determines whether the number is power-of-two or not.
static unsigned int | mostSignificantBitSet (unsigned int value)
| Returns the most significant bit set in a value.

## Detailed Description

Class for manipulating bit patterns.

## Member Function Documentation

## bswap16()

uint16 Ogre::Bitwise::bswap16 | ( | uint16 | arg | ) |

inline static

Returns value with reversed bytes order.

References OGRE_FORCE_INLINE.

## bswap32()

uint32 Ogre::Bitwise::bswap32 | ( | uint32 | arg | ) |

inline static

Returns value with reversed bytes order.

References OGRE_FORCE_INLINE.

Referenced by bswap64().

## bswap64()

uint64 Ogre::Bitwise::bswap64 | ( | uint64 | arg | ) |

inline static

Returns value with reversed bytes order.

References bswap32(), and OGRE_FORCE_INLINE.

## bswapBuffer()

void Ogre::Bitwise::bswapBuffer | ( | void * | pData,
|  | size_t | size )

inline static

Reverses byte order of buffer.

Use bswap16/32/64 instead if possible.

## bswapChunks()

void Ogre::Bitwise::bswapChunks | ( | void * | pData,
|  | size_t | size,
|  | size_t | count )

inline static

Reverses byte order of chunks in buffer, where 'size' is size of one chunk.

## mostSignificantBitSet()

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

inline static

Returns the most significant bit set in a value.

References OGRE_FORCE_INLINE.

## firstPO2From()

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

inline 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.

References OGRE_FORCE_INLINE.

## isPO2()

template<typename T>

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

inline static

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

Note
  0 and 1 are treat as power of two.

References OGRE_FORCE_INLINE.

## getBitShift()

template<typename T>

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

inline static

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

References OGRE_FORCE_INLINE.

Referenced by convertBitPattern().

## convertBitPattern()

template<typename SrcT, typename DestT>

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

inline static

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

This routine is useful for colour conversion.

References getBitShift().

## fixedToFixed()

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

inline 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)

## floatToFixed()

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

inline 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.

## fixedToFloat()

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

inline static

Fixed point to float.

## intWrite()

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

inline static

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

## intRead()

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

inline static

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

## floatToHalf()

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

inline static

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

References floatToHalfI().

## floatToHalfI()

uint16 Ogre::Bitwise::floatToHalfI | ( | uint32 | ui | ) |

inline static

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

Referenced by floatToHalf().

## halfToFloat()

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

inline static

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

References halfToFloatI().

## halfToFloatI()

uint32 Ogre::Bitwise::halfToFloatI | ( | uint16 | h | ) |

inline static

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

Referenced by halfToFloat().

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

- OgreBitwise.h