/
common.cpp
846 lines (726 loc) · 16.5 KB
/
common.cpp
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
#define COMMON_MODULE
#include "common.h"
#define _TEXTURE_SIZE 128
// Variables private to the Common module
Mesh cube;
Texture cubeTex;
Texture curveBorder, curveBackground;
/* ************ *
* Colour class *
* ************ */
Colour::Colour()
{
r = g = b = 0.0f;
a = 1.0f;
}
Colour::Colour(float shade)
{
r = g = b = shade;
a = 1.0f;
}
Colour::Colour(float shade, float alpha)
{
r = g = b = shade;
a = alpha;
}
Colour::Colour(float red, float green, float blue)
{
r = red;
g = green;
b = blue;
a = 1.0f;
}
Colour::Colour(float red, float green, float blue, float alpha)
{
r = red;
g = green;
b = blue;
a = alpha;
}
void Colour::fillArray(float a[]) const
{
a[0] = r;
a[1] = g;
a[2] = b;
a[3] = this->a;
}
void Colour::apply() const
{
glColor4f(r, g, b, a);
}
void Colour::apply(float alpha) const
{
glColor4f(r, g, b, alpha);
}
void Colour::applyMaterial() const
{
float values[4] = {r, g, b, a};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, values);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, values);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, values);
}
void Colour::applyMaterial(int attribute) const
{
float values[4] = {r, g, b, a};
glMaterialfv(GL_FRONT_AND_BACK, attribute, values);
}
void Colour::applyMaterialShiny(float shininess) const
{
applyMaterial();
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
}
void Colour::applyMaterialAlpha(float alpha) const
{
float values[4] = {r, g, b, alpha};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, values);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, values);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, values);
}
void Colour::applyLightAttribute(int number, int attribute) const
{
float values[4] = {r, g, b, a};
glLightfv(number, attribute, values);
}
void Colour::applyLightAttribute(int number, int attribute, float power) const
{
float values[4] = {r*power, g*power, b*power, a};
glLightfv(number, attribute, values);
}
float Colour::brightness() const
{
return sqrtf(r*r + g*g + b*b);
}
Colour Colour::brighter(float v) const
{
// nc = (1-(1-c)*(1-v)) = 1 - ((1-v) - (1-v)*c) = 1 - (1 - v - c + c*v) = v + c - c*v
return Colour(v+r-v*r, v+g-v*g, v+b-v*b, a);
}
Colour Colour::darker(float v) const
{
return Colour(r*(1-v), g*(1-v), b*(1-v), a);
}
string Colour::toString() const
{
ostringstream result;
result.width(6);
result << "Colour: " << r << ", " << g << ", " << b;
return result.str();
}
/* ************** *
* Position class *
* ************** */
Position::Position()
{
x = y = z = 0.0f;
}
Position::Position(const Position& p)
{
x = p.x;
y = p.y;
z = p.z;
}
Position::Position(float x, float y, float z)
{
this->x = x;
this->y = y;
this->z = z;
}
void Position::applyTranslation() const
{
glTranslatef(x, y, z);
}
void Position::applyTranslation(float amount) const
{
#ifdef DEBUG
printf("Information: Applying translation (%.2f, %.2f, %.2f)x%.2f\n", x, y, z, amount);
#endif
glTranslatef(amount*x, amount*y, amount*z);
}
void Position::applyNormal() const
{
glNormal3f(x, y, z);
}
void Position::applyVertex() const
{
glVertex3f(x, y, z);
}
void Position::applyTexCoords() const
{
#ifdef DEBUG
printf("Information: Position::applyTexCoords(): Applying 2D texture coordinate (%.2f,%.2f)\n", x, y);
#endif
glTexCoord2f(x, y);
}
Position Position::operator+=(const Position& p)
{
x += p.x;
y += p.y;
z += p.z;
return *this;
}
/* *********** *
* Light class *
* *********** */
Light::Light(const Position& p, float w, const Colour& c)
{
pos = p;
this->w = w;
this->c = c;
}
void Light::apply(int number) const
{
glEnable(GL_LIGHTING);
glEnable(number);
float values[] = {pos.x, pos.y, pos.z, w};
glLightfv(number, GL_POSITION, values);
c.applyLightAttribute(number, GL_AMBIENT);
c.applyLightAttribute(number, GL_DIFFUSE);
c.applyLightAttribute(number, GL_SPECULAR);
}
void Light::disable(int number) const
{
glDisable(number);
}
/* ************ *
* Camera class *
* ************ */
Camera::Camera()
{
Camera(Position(0, -5, 0), Position(0, 0, 0));
}
Camera::Camera(Position pos)
{
Camera(pos, Position(0, 0, 0));
}
Camera::Camera(Position pos, Position rot)
{
this->pos = pos;
this->rotation = rot;
}
Camera::Camera(const Camera& c)
{
pos = c.pos;
rotation = c.rotation;
}
void Camera::apply() const
{
gluLookAt(0, 0, 0, // Start at 0,0,0
0, 1, 0, // Look at 0,1,0
0, 0, 1); // Up is 0,0,1
pos.applyTranslation();
// glRotatef(rotation.z, 0, 0, 1);
// glRotatef(rotation.y, 0, 1, 0);
// glRotatef(rotation.x, 1, 0, 0);
}
void Camera::move(float dx, float dy, float dz)
{
move(Position(dx, dy, dz));
}
void Camera::move(Position dp)
{
pos += dp;
}
void Camera::rotate(float dx, float dy, float dz)
{
rotate(Position(dx, dy, dz));
}
void Camera::rotate(Position dr)
{
rotation += dr;
}
bool Camera::animate(float dTime)
{
// TODO: Animate the camera motions here
return false;
}
/* ****************** *
* Bezier curve class *
* ****************** */
Bezier::Bezier()
{
a = b = c = d = 0.0f;
type = 0;
}
Bezier::Bezier(const Bezier& curve)
{
a = curve.a;
b = curve.b;
c = curve.c;
d = curve.d;
type = curve.type;
}
Bezier::Bezier(float startV, float endV, float dStart, float dEnd)
{
a = startV;
b = dStart;
c = 3*(endV - startV) - (dEnd + 2*dStart);
d = 2*(startV - endV) + (dStart + dEnd);
type = (a == 0.0f ? 0 : 0x01) |
(b == 0.0f ? 0 : 0x02) |
(c == 0.0f ? 0 : 0x04) |
(d == 0.0f ? 0 : 0x08);
}
float Bezier::f(float t) const
{
switch (type)
{
case 0:
return 0.0f;
case 1:
return a;
case 2:
return b*t;
case 3:
return a + b*t;
case 4:
return c*t*t;
case 5:
return a + c*t*t;
case 6:
return b*t + c*t*t;
case 7:
return a + b*t + c*t*t;
case 8:
return d*t*t*t;
case 9:
return a + d*t*t*t;
case 10:
return b*t + d*t*t*t;
case 11:
return a + b*t + d*t*t*t;
case 12:
return c*t*t + d*t*t*t;
case 13:
return a + c*t*t + d*t*t*t;
case 14:
return b*t + c*t*t + d*t*t*t;
default:
return a + b*t + c*t*t + d*t*t*t;
}
}
float Bezier::df(float t) const
{
return b + t*(2*c + 3*t*d);
}
bool Bezier::isFlat() const
{
return type == 0;
}
void Bezier::changeCurve(float startV, float endV, float dStart, float dEnd)
{
a = startV;
b = dStart;
c = 3*(endV - startV) - (dEnd + 2*dStart);
d = 2*(startV - endV) + (dStart + dEnd);
type = (a == 0.0f ? 0x01 : 0) |
(b == 0.0f ? 0x02 : 0) |
(c == 0.0f ? 0x04 : 0) |
(d == 0.0f ? 0x08 : 0);
}
Bezier& Bezier::operator=(const Bezier& curve)
{
a = curve.a;
b = curve.b;
c = curve.c;
d = curve.d;
type = curve.type;
return *this;
}
float Bezier::getA() const
{
return a;
}
float Bezier::getB() const
{
return b;
}
float Bezier::getC() const
{
return c;
}
float Bezier::getD() const
{
return d;
}
/* **************************** *
* Two-dimensional Bezier curve *
* **************************** */
Bezier2D::Bezier2D()
{
// Nothing to do here
}
Bezier2D::Bezier2D(const Bezier2D& b2d)
{
x = b2d.x;
y = b2d.y;
}
Bezier2D::Bezier2D(Bezier x, Bezier y)
{
this->x = x;
this->y = y;
}
Bezier2D::Bezier2D(float startX, float startY, float endX, float endY,
float dStartX, float dStartY, float dEndX, float dEndY) : x(startX, endX, dStartX, dEndX),
y(startY, endY, dStartY, dEndY)
{
// Nothing to do here
}
float Bezier2D::fx(float t) const
{
return x.f(t);
}
float Bezier2D::dfx(float t) const
{
return x.df(t);
}
float Bezier2D::fy(float t) const
{
return y.f(t);
}
float Bezier2D::dfy(float t) const
{
return y.df(t);
}
bool Bezier2D::isFlat() const
{
return x.isFlat() && y.isFlat();
}
/* ****************************** *
* Three-dimensional Bezier curve *
* ****************************** */
Bezier3D::Bezier3D()
{
// Nothing to do here
}
Bezier3D::Bezier3D(const Bezier3D& curve)
{
x = curve.x;
y = curve.y;
z = curve.z;
}
Bezier3D::Bezier3D(Bezier x, Bezier y, Bezier z)
{
this->x = x;
this->y = y;
this->z = z;
}
Bezier3D::Bezier3D(Position start, Position end, Position speedStart, Position speedEnd) :
x(start.x, end.x, speedStart.x, speedEnd.x),
y(start.y, end.y, speedStart.y, speedEnd.y),
z(start.z, end.z, speedStart.z, speedEnd.z)
{
// Nothing to do here
}
Position Bezier3D::f(float t) const
{
return Position(x.f(t), y.f(t), z.f(t));
}
Position Bezier3D::df(float t) const
{
return Position(x.df(t), y.df(t), z.df(t));
}
bool Bezier3D::isFlat() const
{
return x.isFlat() && y.isFlat() && z.isFlat();
}
/* ******************************* *
* Some generally-useful functions *
* ******************************* */
// Colour-related
Colour operator*(float s, const Colour& c)
{
return Colour(s*c.r, s*c.g, s*c.b, c.a);
}
Colour operator*(const Colour& c, float s)
{
return Colour(s*c.r, s*c.g, s*c.b, c.a);
}
// Position-related
Position operator+(const Position& a, const Position& b)
{
return Position(a.x+b.x, a.y+b.y, a.z+b.z);
}
Position operator-(const Position& a, const Position& b)
{
return Position(a.x-b.x, a.y-b.y, a.z-b.z);
}
Position operator*(const Position& p, float s)
{
return Position(s*p.x, s*p.y, s*p.z);
}
Position operator*(float s, const Position& p)
{
return Position(s*p.x, s*p.y, s*p.z);
}
Position operator/(const Position& p, float s)
{
return Position(p.x/s, p.y/s, p.z/s);
}
// Drawing-related
void comDrawCube(float x, float y, float scale, float rotation)
{
glPushMatrix();
glTranslatef(x + 0.5f, 0.0f, y + 0.5f);
glScalef(scale, scale, scale);
glRotatef(rotation, 0, 1, 0);
cube.render();
glPopMatrix();
}
void comDrawBlock(float x, float y, float scale, float rotation)
{
comDrawCube(x, y, scale, rotation);
}
void comDrawTexturedCube(float x, float y, float scale, float rotation)
{
glPushMatrix();
glTranslatef(x + 0.5f, 0.0f, y + 0.5f);
glScalef(scale, scale, scale);
glRotatef(rotation, 0, 1, 0);
cubeTex.applyTexture();
cube.render(true);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}
// Random-related
float comRandomFloat()
{
return (float)rand() / RAND_MAX;
}
float comRandomFloat(float min, float max)
{
return (max - min)*comRandomFloat() + min;
}
Colour comRandomColour()
{
#ifdef DEBUG
printf("Information: Creating random colour.\n");
#endif
float r = comRandomFloat(0.125f, 0.875f),
g = comRandomFloat(0.125f, 0.875f),
b = comRandomFloat(0.125f, 0.875f);
Colour result(r, g, b);
float brightness = comRandomFloat(0.4f, 0.6f);
brightness /= result.brightness();
result = result * brightness;
return result;
}
int comRandomInt(int count)
{
return (int)((count-1)*comRandomFloat() + 0.5f);
}
// File-related
string comReadLine(FILE* in)
{
string result;
if (in == NULL)
return result;
char c = getc(in);
while (!feof(in) && c != '\n')
{
result += c;
c = getc(in);
}
return result;
}
// String-related
bool comStartsWith(string& a, string& b)
{
return a.find_first_of(b) == 0;
}
vector<string> comSplitSpaces(string a)
{
vector<string> result;
unsigned int last = 0, next = a.find_first_of(" ");
do
{
next = a.find_first_of(" ", last+1);
if (next == string::npos)
{
result.push_back(a.substr(last));
break;
}
result.push_back(a.substr(last, next-last));
last = next;
}
while (next != string::npos);
vector<string>::iterator iter = result.begin();
while (iter != result.end())
{
while ((*iter).size() > 0 && (*iter)[0] == ' ')
(*iter) = (*iter).substr(1);
if ((*iter).size() < 1)
result.erase(iter);
else
iter++;
}
return result;
}
vector<string> comSplitString(string str, const string& delim)
{
vector<string> results;
unsigned int cut;
while ((cut = str.find_first_of(delim)) != string::npos)
{
results.push_back(str.substr(0, cut));
str = str.substr(cut+1);
}
if (str.length() > 0)
results.push_back(str);
return results;
}
// Drawing-related
void comDrawRect(int x, int y, int width, int height)
{
glBegin(GL_LINE_LOOP);
glVertex2i(x, y);
glVertex2i(x, y+height);
glVertex2i(x+width, y+height);
glVertex2i(x+width, y);
glEnd();
}
void comFillRect(int x, int y, int width, int height)
{
glBegin(GL_QUADS);
glVertex2i(x, y);
glVertex2i(x, y+height);
glVertex2i(x+width, y+height);
glVertex2i(x+width, y);
glEnd();
}
void comDrawRoundRect(int x, int y, int width, int height, float thickness, Colour c)
{
float thick = 0.5f*thickness;
float x1, x2, x3, x4;
float y1, y2, y3, y4;
x1 = x - thick;
x2 = x + thick;
x3 = x + width - thick;
x4 = x + width + thick;
y1 = y - thick;
y2 = y + thick;
y3 = y + height - thick;
y4 = y + height + thick;
c.apply();
curveBorder.applyTexture();
glBegin(GL_QUADS);
// Top-left quad
glTexCoord2f(1, 1); glVertex2f(x1, y1);
glTexCoord2f(1, 0); glVertex2f(x1, y2);
glTexCoord2f(0, 0); glVertex2f(x2, y2);
glTexCoord2f(0, 1); glVertex2f(x2, y1);
// Top-center quad
glTexCoord2f(0, 1); glVertex2f(x2, y1);
glTexCoord2f(0, 0); glVertex2f(x2, y2);
glTexCoord2f(0, 0); glVertex2f(x3, y2);
glTexCoord2f(0, 1); glVertex2f(x3, y1);
// Top-right quad
glTexCoord2f(0, 1); glVertex2f(x3, y1);
glTexCoord2f(0, 0); glVertex2f(x3, y2);
glTexCoord2f(1, 0); glVertex2f(x4, y2);
glTexCoord2f(1, 1); glVertex2f(x4, y1);
// Center-left quad
glTexCoord2f(1, 0); glVertex2f(x1, y2);
glTexCoord2f(1, 0); glVertex2f(x1, y3);
glTexCoord2f(0, 0); glVertex2f(x2, y3);
glTexCoord2f(0, 0); glVertex2f(x2, y2);
// Center quad (Do we need this one?)
// Center-right quad
glTexCoord2f(0, 0); glVertex2f(x3, y2);
glTexCoord2f(0, 0); glVertex2f(x3, y3);
glTexCoord2f(1, 0); glVertex2f(x4, y3);
glTexCoord2f(1, 0); glVertex2f(x4, y2);
// Bottom-left quad
glTexCoord2f(1, 0); glVertex2f(x1, y3);
glTexCoord2f(1, 1); glVertex2f(x1, y4);
glTexCoord2f(0, 1); glVertex2f(x2, y4);
glTexCoord2f(0, 0); glVertex2f(x2, y3);
// Bottom-center quad
glTexCoord2f(0, 0); glVertex2f(x2, y3);
glTexCoord2f(0, 1); glVertex2f(x2, y4);
glTexCoord2f(0, 1); glVertex2f(x3, y4);
glTexCoord2f(0, 0); glVertex2f(x3, y3);
// Bottom-right quad
glTexCoord2f(0, 0); glVertex2f(x3, y3);
glTexCoord2f(0, 1); glVertex2f(x3, y4);
glTexCoord2f(1, 1); glVertex2f(x4, y4);
glTexCoord2f(1, 0); glVertex2f(x4, y3);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void comFillRoundRect(int x, int y, int width, int height, float thickness, Colour c)
{
float thick = 0.5f*thickness;
float x1, x2, x3, x4;
float y1, y2, y3, y4;
x1 = x - thick;
x2 = x + thick;
x3 = x + width - thick;
x4 = x + width + thick;
y1 = y - thick;
y2 = y + thick;
y3 = y + height - thick;
y4 = y + height + thick;
c.apply();
curveBackground.applyTexture();
glBegin(GL_QUADS);
// Top-left quad
glTexCoord2f(1, 1); glVertex2f(x1, y1);
glTexCoord2f(1, 0); glVertex2f(x1, y2);
glTexCoord2f(0, 0); glVertex2f(x2, y2);
glTexCoord2f(0, 1); glVertex2f(x2, y1);
// Top-center quad
glTexCoord2f(0, 1); glVertex2f(x2, y1);
glTexCoord2f(0, 0); glVertex2f(x2, y2);
glTexCoord2f(0, 0); glVertex2f(x3, y2);
glTexCoord2f(0, 1); glVertex2f(x3, y1);
// Top-right quad
glTexCoord2f(0, 1); glVertex2f(x3, y1);
glTexCoord2f(0, 0); glVertex2f(x3, y2);
glTexCoord2f(1, 0); glVertex2f(x4, y2);
glTexCoord2f(1, 1); glVertex2f(x4, y1);
// Center-left quad
glTexCoord2f(1, 0); glVertex2f(x1, y2);
glTexCoord2f(1, 0); glVertex2f(x1, y3);
glTexCoord2f(0, 0); glVertex2f(x2, y3);
glTexCoord2f(0, 0); glVertex2f(x2, y2);
// Center quad
glTexCoord2f(0, 0);
glVertex2f(x2, y3);
glVertex2f(x2, y2);
glVertex2f(x3, y2);
glVertex2f(x3, y3);
// Center-right quad
glTexCoord2f(0, 0); glVertex2f(x3, y2);
glTexCoord2f(0, 0); glVertex2f(x3, y3);
glTexCoord2f(1, 0); glVertex2f(x4, y3);
glTexCoord2f(1, 0); glVertex2f(x4, y2);
// Bottom-left quad
glTexCoord2f(1, 0); glVertex2f(x1, y3);
glTexCoord2f(1, 1); glVertex2f(x1, y4);
glTexCoord2f(0, 1); glVertex2f(x2, y4);
glTexCoord2f(0, 0); glVertex2f(x2, y3);
// Bottom-center quad
glTexCoord2f(0, 0); glVertex2f(x2, y3);
glTexCoord2f(0, 1); glVertex2f(x2, y4);
glTexCoord2f(0, 1); glVertex2f(x3, y4);
glTexCoord2f(0, 0); glVertex2f(x3, y3);
// Bottom-right quad
glTexCoord2f(0, 0); glVertex2f(x3, y3);
glTexCoord2f(0, 1); glVertex2f(x3, y4);
glTexCoord2f(1, 1); glVertex2f(x4, y4);
glTexCoord2f(1, 0); glVertex2f(x4, y3);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void comInit()
{
Mesh::loadWavefrontObjectFile(&cube, "objects/block.obj");
cubeTex = texLoadTexture("textures/block-normals.png");
if (cubeTex.isValid())
printf("Information: Cube texture is valid.\n");
else
printf("Warning: Cube texture is invalid!\n");
curveBorder = texMakeCurveBorder(_TEXTURE_SIZE, _TEXTURE_SIZE, true);
curveBackground = texMakeCurveBackground(_TEXTURE_SIZE, _TEXTURE_SIZE, true);
// curveBackground = texLoadCustomTexture("textures/curve-background.png", GL_LUMINANCE_ALPHA);
}