forked from skeeto/pixelcity
-
Notifications
You must be signed in to change notification settings - Fork 2
/
glTypes.h
219 lines (186 loc) · 5.28 KB
/
glTypes.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#ifndef glTYPES
#define glTYPES
#include <iostream>
#define GL_CLAMP_TO_EDGE 0x812F
#define OPERATORS(type) \
type operator+ (const type& c); \
type operator+ (const float& c);\
void operator+= (const type& c);\
void operator+= (const float& c);\
type operator- (const type& c);\
type operator- (const float& c);\
void operator-= (const type& c);\
void operator-= (const float& c);\
type operator* (const type& c);\
type operator* (const float& c);\
void operator*= (const type& c);\
void operator*= (const float& c);\
type operator/ (const type& c);\
type operator/ (const float& c);\
void operator/= (const type& c);\
void operator/= (const float& c);\
bool operator== (const type& c)
#define JOINT_MAX_CHILDREN 8
struct GLquat
{
float x;
float y;
float z;
float w;
};
struct GLvector
{
float x;
float y;
float z;
OPERATORS(GLvector);
};
typedef GLvector GLvector3;
// for non-windows version of Ini.cpp
inline std::ostream& operator<<(std::ostream& out, const GLvector& v) {
return out << v.x << " " << v.y << " " << v.z;
}
inline std::istream& operator>>(std::istream& in, GLvector& v) {
return in >> v.x >> v.y >> v.z;
}
struct GLvector2
{
float x;
float y;
OPERATORS(GLvector2);
};
struct GLrgba
{
float red;
float green;
float blue;
float alpha;
OPERATORS(GLrgba);
};
struct GLmatrix
{
float elements[4][4];
};
struct GLbbox
{
GLvector3 min;
GLvector3 max;
};
struct GLvertex
{
GLvector3 position;
GLvector2 uv;
GLrgba color;
int bone;
};
struct GLrect
{
float left;
float top;
float right;
float bottom;
};
struct GLtriangle
{
int v1;
int v2;
int v3;
int normal1;
int normal2;
int normal3;
};
/*
class GLmodel
{
public:
unsigned vertex_count;
unsigned triangle_count;
unsigned normal_count;
GLvertex* vertex;
GLvector* normal;
GLtriangle* triangle;
void TriangleRender (unsigned n);
GLtriangle* TriangleAdd (unsigned v1, int unsigned, int unsigned);
GLtriangle* TriangleAdd (GLtriangle c);
void NormalAdd (GLvector n);
void VertexAdd (GLvertex v);
GLmodel ();
~GLmodel ();
void Render ();
GLbbox BBox ();
private:
GLbbox m_bbox;
};
struct GLkeyframe
{
float time;
GLvector offset;
GLvector rotation;
};
struct GLsegment
{
int index;
GLvector rotation;
GLvector offset;
GLkeyframe keyframes[255];
int frame_count;
};
class GLanimate
{
public:
GLanimate ();
void KeyframeAdd (int joint, float time, GLquat q);
void TimeSet (float time);
void PositionSet (float pos);
GLvector Rotation (int);
GLvector Offset (int);
private:
GLsegment* m_segments;
int m_segment_count;
float m_length;
};
*/
GLbbox glBboxClear (void);
GLbbox glBboxContainPoint (GLbbox box, GLvector point);
bool glBboxTestPoint (GLbbox box, GLvector point);
//GLrgba glRgba (char* string);
GLrgba glRgba (float red, float green, float blue);
GLrgba glRgba (float luminance);
GLrgba glRgba (float red, float green, float blue, float alpha);
//GLrgba glRgba (long c);
GLrgba glRgba (int red, int green, int blue);
GLrgba glRgbaAdd (GLrgba c1, GLrgba c2);
GLrgba glRgbaSubtract (GLrgba c1, GLrgba c2);
GLrgba glRgbaInterpolate (GLrgba c1, GLrgba c2, float delta);
GLrgba glRgbaScale (GLrgba c, float scale);
GLrgba glRgbaMultiply (GLrgba c1, GLrgba c2);
GLrgba glRgbaUnique (int i);
GLrgba glRgbaFromHsl (float h, float s, float l);
GLmatrix glMatrixIdentity (void);
void glMatrixElementsSet (GLmatrix* m, float* in);
GLmatrix glMatrixMultiply (GLmatrix a, GLmatrix b);
GLvector glMatrixTransformPoint (GLmatrix m, GLvector in);
GLmatrix glMatrixTranslate (GLmatrix m, GLvector in);
GLmatrix glMatrixRotate (GLmatrix m, float theta, float x, float y, float z);
GLvector glMatrixToEuler (GLmatrix mat, int order);
GLquat glQuat (float x, float y, float z, float w);
GLvector glQuatToEuler (GLquat q, int order);
GLvector glVector (float x, float y, float z);
GLvector glVectorCrossProduct (GLvector v1, GLvector v2);
float glVectorDotProduct (GLvector v1, GLvector v2);
void glVectorGl (GLvector v);
GLvector glVectorInterpolate (GLvector v1, GLvector v2, float scalar);
float glVectorLength (GLvector v);
GLvector glVectorNormalize (GLvector v);
GLvector glVectorReflect (GLvector3 ray, GLvector3 normal);
GLvector2 glVector (float x, float y);
GLvector2 glVectorAdd (GLvector2 val1, GLvector2 val2);
GLvector2 glVectorSubtract (GLvector2 val1, GLvector2 val2);
GLvector2 glVectorNormalize (GLvector2 v);
GLvector2 glVectorInterpolate (GLvector2 v1, GLvector2 v2, float scalar);
GLvector2 glVectorSinCos (float angle);
float glVectorLength (GLvector2 v);
#endif
#ifndef NULL
#define NULL 0
#endif