-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnglCommon.h
107 lines (72 loc) · 2.32 KB
/
nglCommon.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "glm/glm.hpp"
#include "gl/glew.h"
#include <stdlib.h>
#include "raxStringUtils.h"
#ifndef nglCommon_h__
#define nglCommon_h__
/************************************************************************/
/* OPTIONS */
/************************************************************************/
#define NGL_RESOURCEMANAGER_DIR_SEPERATOR "/"
#define NGL_RENDER_SHADOWMAP_RES 8192
#define NGL_PI 3.1415926
#define NGL_DEGTORAD(Deg) ((Deg * NGL_PI) / 180.0)
#define NGL_RADTODEG(Rad) ((180.0 * Rad) / NGL_PI)
typedef glm::vec4 nglVec4;
typedef glm::vec3 nglVertex3P;
typedef glm::vec3 nglVec3;
typedef glm::vec2 nglVec2;
typedef glm::u8vec2 nglVec2U8;
typedef glm::u16vec2 nglVec2U16;
typedef glm::mat4 nglMat4;
typedef glm::mat3 nglMat3;
typedef glm::u8vec3 nglRGB;
typedef glm::vec3 nglRGB3F;
typedef nglVec2 nglUV;
//generate random color, normalized
inline nglVec3 GenerateRandomNormalizedColor(){
nglVec3 col;
col.x = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
col.y = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
col.z = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
return col;
}
inline std::string Vec3ToString(nglVec3& vec){
std::string res = "";
res += "x:" + rax::utils::StringUtils::NumberToString<float>(vec.x);
res += "y:" + rax::utils::StringUtils::NumberToString<float>(vec.y);
res += "z:" + rax::utils::StringUtils::NumberToString<float>(vec.z);
res += "\n";
return res;
}
//#define cornflowerblue (100, 149, 237) // important
struct nglVertex3P3N {
nglVertex3P position;
//vertex normal
//http://en.wikipedia.org/wiki/Vertex_normal
glm::vec3 normal;
};
// #pragma pack(push, 1)
// struct nglFace3US {
// //vertex indices
// GLushort v0,v1,v2;
//
// nglFace3US operator= (const nglFace3US& other) {
// v0 = other.v0;
// v1 = other.v1;
// v2 = other.v2;
// return *this;
// }
// };
// #pragma pack(pop)
struct nglTriangle {
nglVertex3P p0,p1,p2;
};
enum NGL_ARRAY_DATA_TYPE {
NGL_ARRAY_DATA_TYPE_VERTEX = 1,
NGL_ARRAY_DATA_TYPE_INDEX = 2,
NGL_ARRAY_DATA_TYPE_NORMALS = 4,
NGL_ARRAY_DATA_TYPE_UV = 8,
NGL_ARRAY_DATA_TYPE_COLORS = 16
};
#endif // nglCommon_h__