/
utilities.h
58 lines (46 loc) · 1.02 KB
/
utilities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef UTILITIES_H
#define UTILITIES_H
#define GL_GLEXT_PROTOTYPES
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>
#endif
#include <string>
#include <istream>
#include <svl/SVL.h>
#include "glwin.h"
typedef unsigned char uint8;
typedef unsigned char uchar;
typedef unsigned int uint32;
typedef unsigned int uint;
using namespace std;
namespace Utilities
{
void fatal(const string& message);
void normalizeVector(float* v);
float interpolate(float tl, float tr, float bl, float br, float weightX, float weightY, float cWeightX, float cWeightY);
float clamp(float v, float lower, float upper);
float sign(float v);
template<class T>
T read(istream& stream)
{
T ret;
stream.read((char*) &ret, sizeof(T));
return ret;
}
template<int N>
Vec readVec(istream& stream)
{
Vec ret(N);
for (int i=0 ; i<N ; ++i)
ret[i] = read<float>(stream);
return ret;
}
string readString(istream& stream);
};
#endif