The LARC Game Engine
A Simple Game Engine from the Laboratory for Recreational Computing
Macros | Functions
Helpers.h File Reference

Header file for helper functions. More...

#include "Defines.h"

Macros

#define SAFE_DELETE(p)   {delete (p); (p) = nullptr;};
 Safe delete of a pointer. More...
 
#define lerp(t, a, b)   (a + t*(b - a))
 Linear interpolation.
 
#define spline3(t)   (t*t*(3.0f - 2.0f*t))
 Cubic spline.
 
#define spline5(t)   (t*t*t*(10.0f + 3.0f*t*(2.0f*t - 5.0f)))
 Quintic spline.
 
#define clamp(a, b, c)   (((b)<(a))?(a):(((b)>(c))?(c):(b)))
 Clamp between values.
 

Functions

void MakeWideFileName (_In_ const char *, _Out_ wchar_t *&)
 Make wide file name from a narrow one. More...
 
XMFLOAT4 HSVtoRGB (float, float, float)
 Convert color from HSV to RGB. More...
 

Macro Definition Documentation

◆ SAFE_DELETE

#define SAFE_DELETE (   p)    {delete (p); (p) = nullptr;};

Note that it is OK to delete a null pointer. Note the brackets and braces also.

Function Documentation

◆ HSVtoRGB()

XMFLOAT4 HSVtoRGB ( float  h,
float  s,
float  v 
)

Convert color in HSV format to RGB format. This is a helper function for generating a pseudorandom color. I snagged it from the interwebs.

Parameters
hHue.
sSaturation.
vValue.
Returns
Color in RGB format with an alpha value of 1.

◆ MakeWideFileName()

void MakeWideFileName ( _In_ const char *  filename,
_Out_ wchar_t *&  wfilename 
)

Helper function to make a wide file name out of a regular one. Creates a wide buffer and stores the wide version of a regular file name in it. Remember to delete the wide file name after it has been used.

Parameters
filename[in] The original file name.
wfilename[out] The wide file name.