OGRE-Next  3.0.0
Object-Oriented Graphics Rendering Engine
Ogre::Bitwise Class Reference

Class for manipulating bit patterns. More...

#include <OgreBitwise.h>

Static Public Member Functions

static FORCEINLINE uint16 bswap16 (uint16 arg)
 Returns value with reversed bytes order. More...
 
static FORCEINLINE uint32 bswap32 (uint32 arg)
 Returns value with reversed bytes order. More...
 
static FORCEINLINE uint64 bswap64 (uint64 arg)
 Returns value with reversed bytes order. More...
 
static void bswapBuffer (void *pData, size_t size)
 Reverses byte order of buffer. More...
 
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. More...
 
static uint32 clz32 (uint32 value)
 
static uint32 clz64 (uint64 value)
 
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 uint32 ctz32 (uint32 value)
 
static uint32 ctz64 (uint64 value)
 
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...
 
static int16 floatToSnorm16 (float v)
 
static int8 floatToSnorm8 (float v)
 
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...
 
static float snorm16ToFloat (int16 v)
 
static float snorm8ToFloat (int8 v)
 

Detailed Description

Class for manipulating bit patterns.

Member Function Documentation

◆ bswap16()

static FORCEINLINE uint16 Ogre::Bitwise::bswap16 ( uint16  arg)
inlinestatic

Returns value with reversed bytes order.

◆ bswap32()

static FORCEINLINE uint32 Ogre::Bitwise::bswap32 ( uint32  arg)
inlinestatic

Returns value with reversed bytes order.

Referenced by bswap64().

◆ bswap64()

static FORCEINLINE uint64 Ogre::Bitwise::bswap64 ( uint64  arg)
inlinestatic

Returns value with reversed bytes order.

References bswap32().

◆ bswapBuffer()

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

Reverses byte order of buffer.

Use bswap16/32/64 instead if possible.

◆ bswapChunks()

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

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

◆ clz32()

static uint32 Ogre::Bitwise::clz32 ( uint32  value)
inlinestatic

◆ clz64()

static uint32 Ogre::Bitwise::clz64 ( uint64  value)
inlinestatic

◆ convertBitPattern()

template<typename SrcT , typename DestT >
static DestT Ogre::Bitwise::convertBitPattern ( SrcT  srcValue,
SrcT  srcBitMask,
DestT  destBitMask 
)
inlinestatic

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.

References getBitShift().

◆ ctz32()

static uint32 Ogre::Bitwise::ctz32 ( uint32  value)
inlinestatic

◆ ctz64()

static uint32 Ogre::Bitwise::ctz64 ( uint64  value)
inlinestatic

◆ firstPO2From()

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

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.

◆ fixedToFixed()

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

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)

◆ fixedToFloat()

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

Fixed point to float.

◆ floatToFixed()

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

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.

◆ floatToHalf()

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

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

References floatToHalfI().

◆ floatToHalfI()

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

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

Referenced by floatToHalf().

◆ floatToSnorm16()

static int16 Ogre::Bitwise::floatToSnorm16 ( float  v)
inlinestatic

References Ogre::Math::Clamp().

◆ floatToSnorm8()

static int8 Ogre::Bitwise::floatToSnorm8 ( float  v)
inlinestatic

References Ogre::Math::Clamp().

◆ getBitShift()

template<typename T >
static FORCEINLINE unsigned int Ogre::Bitwise::getBitShift ( mask)
inlinestatic

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

Referenced by convertBitPattern().

◆ halfToFloat()

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

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

References halfToFloatI().

Referenced by Ogre::VertexBufferDownloadHelper::getVector4().

◆ halfToFloatI()

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

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

Referenced by halfToFloat().

◆ intRead()

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

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

◆ intWrite()

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

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

◆ isPO2()

template<typename T >
static FORCEINLINE bool Ogre::Bitwise::isPO2 ( n)
inlinestatic

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

Note
0 and 1 are tread as power of two.

◆ mostSignificantBitSet()

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

Returns the most significant bit set in a value.

◆ snorm16ToFloat()

static float Ogre::Bitwise::snorm16ToFloat ( int16  v)
inlinestatic

◆ snorm8ToFloat()

static float Ogre::Bitwise::snorm8ToFloat ( int8  v)
inlinestatic

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