le3d - LightEngine 3D
A straightforward C++ 3D software engine for real-time graphics
Namespaces | Macros | Typedefs | Functions
global.h File Reference

LightEngine 3D: Global helpers and definitions. More...

#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>

Go to the source code of this file.

Namespaces

 LeGlobal
 

Macros

#define cmmax(a, b)   ((a)>(b)?(a):(b)) /** Return the maximum of two values */
 
#define cmmin(a, b)   ((a)<(b)?(a):(b)) /** Return the minimum of two values */
 
#define cmabs(a)   ((a)<0.0f?(-(a)):(a)) /** Return the absolute value */
 
#define cmbound(v, vmin, vmax)   ((v)>(vmax)?(vmax):((v)<(vmin)?(vmin):(v))) /** Limit a value between two bounds (included) */
 
#define cmsgn(a)   ((a)<0.0f?-1.0f:1.0f) /** Return the sign (+1.0 or -1.0) of a value */
 
#define cmthr(a, t)   ((a)<(-t)?-1.0f:((a)>(t)?1.0f:0.0f)) /** Compare a value to a threshold and return +1.0 (above), -1.0 (below) or 0.0f (inside) */
 
#define cmmod(a, m)   (((a) % (m) + (m)) % (m)) /** Perform a non-signed modulo (integer) */
 
#define cmmodf(a, m)   (fmodf((fmodf((a), (m)) + (m)), (m))) /** Perform a non-signed modulo (float) */
 
#define randf()   (((float) rand() / (float) (RAND_MAX >> 1)) - 1.0f) /** Compute a float random pseudo number */
 
#define d2r   (const float) (M_PI / 180.0f) /** Mutiply constant to convert degrees in radiants */
 
#define r2d   (const float) (180.0f / M_PI) /** Mutiply constant to convert radiants in degrees */
 
#define FROM_LEU16(x)   (x = ((uint8_t *) &(x))[0] + (((uint8_t *) &(x))[1] << 8))
 
#define FROM_LES16(x)   FROM_LEU16(x)
 
#define FROM_LEU32(x)   (x = ((uint8_t *) &x)[0] + (((uint8_t *) &x)[1] << 8) + (((uint8_t *) &x)[2] << 16) + (((uint8_t *) &x)[3] << 24))
 
#define FROM_LES32(x)   FROM_LEU32(x)
 
#define TO_LEU16(x)
 
#define TO_LES16(x)
 
#define TO_LEU32(x)
 
#define TO_LES32(x)
 

Typedefs

typedef unsigned long long LeHandle
 

Functions

void LeGlobal::toLower (char *txt)
 
void LeGlobal::toUpper (char *txt)
 
void LeGlobal::getFileExtention (char *ext, const int extSize, const char *path)
 
void LeGlobal::getFileName (char *name, const int nameSize, const char *path)
 
void LeGlobal::getFileDirectory (char *dir, int dirSize, const char *path)
 
int LeGlobal::log2i32 (int n)
 

Detailed Description

LightEngine 3D: Global helpers and definitions.

All platforms implementation

Author
Frederic Meslin (fred@.nosp@m.fred.nosp@m.slab..nosp@m.net) http://fredslab.net
Version
1.75

The MIT License (MIT) Copyright (c) 2015-2018 Frédéric Meslin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Macro Definition Documentation

#define cmabs (   a)    ((a)<0.0f?(-(a)):(a)) /** Return the absolute value */
#define cmbound (   v,
  vmin,
  vmax 
)    ((v)>(vmax)?(vmax):((v)<(vmin)?(vmin):(v))) /** Limit a value between two bounds (included) */
#define cmmax (   a,
 
)    ((a)>(b)?(a):(b)) /** Return the maximum of two values */

Native OS handle / pointer holder type Handful macros

#define cmmin (   a,
 
)    ((a)<(b)?(a):(b)) /** Return the minimum of two values */
#define cmmod (   a,
 
)    (((a) % (m) + (m)) % (m)) /** Perform a non-signed modulo (integer) */
#define cmmodf (   a,
 
)    (fmodf((fmodf((a), (m)) + (m)), (m))) /** Perform a non-signed modulo (float) */
#define cmsgn (   a)    ((a)<0.0f?-1.0f:1.0f) /** Return the sign (+1.0 or -1.0) of a value */
#define cmthr (   a,
 
)    ((a)<(-t)?-1.0f:((a)>(t)?1.0f:0.0f)) /** Compare a value to a threshold and return +1.0 (above), -1.0 (below) or 0.0f (inside) */
#define d2r   (const float) (M_PI / 180.0f) /** Mutiply constant to convert degrees in radiants */
#define FROM_LES16 (   x)    FROM_LEU16(x)
#define FROM_LES32 (   x)    FROM_LEU32(x)
#define FROM_LEU16 (   x)    (x = ((uint8_t *) &(x))[0] + (((uint8_t *) &(x))[1] << 8))

Compilers missing - Memory aligned allocation functions Brute force 128bit memory alignement (for SIMD maths) Compilers missing - intrinsics and maths functions Endianness conversion macros

#define FROM_LEU32 (   x)    (x = ((uint8_t *) &x)[0] + (((uint8_t *) &x)[1] << 8) + (((uint8_t *) &x)[2] << 16) + (((uint8_t *) &x)[3] << 24))
#define r2d   (const float) (180.0f / M_PI) /** Mutiply constant to convert radiants in degrees */
#define randf ( )    (((float) rand() / (float) (RAND_MAX >> 1)) - 1.0f) /** Compute a float random pseudo number */
#define TO_LES16 (   x)
Value:
(\
((uint8_t *) &(x))[0] = ((int16_t) (x)) & 0xFF, \
((uint8_t *) &(x))[1] = ((int16_t) (x)) >> 8 \
)
#define TO_LES32 (   x)
Value:
(\
((uint8_t *) &(x))[0] = ((int32_t) (x)) & 0xFF, \
((uint8_t *) &(x))[1] = ((int32_t) (x)) >> 8, \
((uint8_t *) &(x))[2] = ((int32_t) (x)) >> 16, \
((uint8_t *) &(x))[3] = ((int32_t) (x)) >> 24 \
)
#define TO_LEU16 (   x)
Value:
(\
((uint8_t *) &(x))[0] = ((uint16_t) (x)) & 0xFF, \
((uint8_t *) &(x))[1] = ((uint16_t) (x)) >> 8 \
)
#define TO_LEU32 (   x)
Value:
(\
((uint8_t *) &(x))[0] = ((uint32_t) (x)) & 0xFF, \
((uint8_t *) &(x))[1] = ((uint32_t) (x)) >> 8, \
((uint8_t *) &(x))[2] = ((uint32_t) (x)) >> 16, \
((uint8_t *) &(x))[3] = ((uint32_t) (x)) >> 24 \
)

Typedef Documentation

typedef unsigned long long LeHandle

Standard declarations