Nebula
Loading...
Searching...
No Matches
Debug::DebugFloat Class Reference

#include <debugfloat.h>

Detailed Description

This class is supposed to make it easier, to restore the exact value of floating- point-based types, like vector, mat4, float etc.

for debugging. printf cuts values and rounds it. Also denormalized values might be printed as "0.0". Its particulary useful, if a certain set of input-parameters lets a function crash. Just call printHex for floating-point-based params so they are being printed to stdout with its exact bit-pattern. That dump can be passed to restoreHex and you can debug that function with that particular input-set.

Printing a vec4 to stdout works like this:

vec4 v(1.0f, 2.0f, 3.0f, 4.0f);
DebugFloat::printHex(v, "v");

The output in stdout is this:

v: 0x3F800000, 0x40000000, 0x40400000, 0x40800000

To restore the values, just pass the output to restoreHex

vec4 v = DebugFloat::restoreHex(0x3F800000, 0x40000000, 0x40400000, 0x40800000);

Now v has the exact same value(bit pattern) as it had when being printed with printHex

There is also a normal "print" for each type. Quite useful is the quaternion-version, since it gives a more human-readable output than just the normal debugger.

Static Public Member Functions

static void printHex (float val, const char *msg=NULL)
 print float's bit pattern as hex to stdout
 
static void printHex (const Math::vec4 &v, const char *msg=NULL)
 print vec4's bit pattern as hex to stdout
 
static void printHex (const Math::mat4 &m, const char *msg=NULL)
 print matrix's bit pattern as hex to stdout
 
static void printHex (const Math::quat &q, const char *msg=NULL)
 print quaternion's bit pattern as hex to stdout
 
static void printHex (const Math::plane &p, const char *msg=NULL)
 print plane's bit pattern as hex to stdout
 
static void restoreHex (float &v, int val)
 
static void restoreHex (Math::vec4 &v, int x, int y, int z, int w)
 
static void restoreHex (Math::mat4 &m, int m0, int m1, int m2, int m3, int m4, int m5, int m6, int m7, int m8, int m9, int m10, int m11, int m12, int m13, int m14, int m15)
 
static void restoreHex (Math::quat &q, int x, int y, int z, int w)
 
static void restoreHex (Math::plane &p, int x, int y, int z, int w)
 
static void print (const float &v, const char *msg=NULL)
 print float's values plain to stdout
 
static void print (const Math::vec4 &v, const char *msg=NULL)
 print vec4's values plain to stdout
 
static void print (const Math::mat4 &m, const char *msg=NULL)
 print matrix's values plain to stdout
 
static void print (const Math::quat &q, const char *msg=NULL)
 print quaternion's values plain to stdout
 
static void print (const Math::plane &p, const char *msg=NULL)
 print plane's values plain to stdout
 

Member Function Documentation

◆ print() [1/5]

void Debug::DebugFloat::print ( const float & v,
const char * msg = NULL )
inlinestatic

print float's values plain to stdout

◆ print() [2/5]

void Debug::DebugFloat::print ( const Math::mat4 & m,
const char * msg = NULL )
inlinestatic

print matrix's values plain to stdout

◆ print() [3/5]

static void Debug::DebugFloat::print ( const Math::plane & p,
const char * msg = NULL )
static

print plane's values plain to stdout

◆ print() [4/5]

void Debug::DebugFloat::print ( const Math::quat & q,
const char * msg = NULL )
inlinestatic

print quaternion's values plain to stdout

◆ print() [5/5]

void Debug::DebugFloat::print ( const Math::vec4 & v,
const char * msg = NULL )
inlinestatic

print vec4's values plain to stdout

◆ printHex() [1/5]

void Debug::DebugFloat::printHex ( const Math::mat4 & m,
const char * msg = NULL )
inlinestatic

print matrix's bit pattern as hex to stdout

◆ printHex() [2/5]

void Debug::DebugFloat::printHex ( const Math::plane & p,
const char * msg = NULL )
inlinestatic

print plane's bit pattern as hex to stdout

◆ printHex() [3/5]

void Debug::DebugFloat::printHex ( const Math::quat & q,
const char * msg = NULL )
inlinestatic

print quaternion's bit pattern as hex to stdout

◆ printHex() [4/5]

void Debug::DebugFloat::printHex ( const Math::vec4 & v,
const char * msg = NULL )
inlinestatic

print vec4's bit pattern as hex to stdout

◆ printHex() [5/5]

void Debug::DebugFloat::printHex ( float val,
const char * msg = NULL )
inlinestatic

print float's bit pattern as hex to stdout

◆ restoreHex() [1/5]

void Debug::DebugFloat::restoreHex ( float & v,
int val )
inlinestatic

◆ restoreHex() [2/5]

void Debug::DebugFloat::restoreHex ( Math::mat4 & m,
int m0,
int m1,
int m2,
int m3,
int m4,
int m5,
int m6,
int m7,
int m8,
int m9,
int m10,
int m11,
int m12,
int m13,
int m14,
int m15 )
inlinestatic

◆ restoreHex() [3/5]

void Debug::DebugFloat::restoreHex ( Math::plane & p,
int x,
int y,
int z,
int w )
inlinestatic

◆ restoreHex() [4/5]

void Debug::DebugFloat::restoreHex ( Math::quat & q,
int x,
int y,
int z,
int w )
inlinestatic

◆ restoreHex() [5/5]

void Debug::DebugFloat::restoreHex ( Math::vec4 & v,
int x,
int y,
int z,
int w )
inlinestatic

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