summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/opengl/src/tinygl.inc
blob: 8214d461d40b58a375393c6e4b7645c9946b9801 (plain)
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
845
846
847
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2005 by Karoly Balogh

     TinyGL/OpenGL wrapper include for MorphOS/PowerPC

    Thanks to Michal 'kiero' Wozniak and Mark 'bigfoot' Olsen
    for their help.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

{ ****************************************************************************************************** }
{ ** TinyGL syscalls                                                                                  ** }
{ ****************************************************************************************************** }

{$IFDEF GL_UNIT}
procedure _GLEnable(gcl: pointer; cap: GLenum);
syscall sysvbase TinyGLBase 28;

procedure _GLDisable(gcl: pointer; cap: GLenum);
syscall sysvbase TinyGLBase 34;

procedure _GLShadeModel(gcl: pointer; mode: GLenum);
syscall sysvbase TinyGLBase 46;

procedure _GLCullFace(gcl: pointer; mode: GLenum);
syscall sysvbase TinyGLBase 52;

procedure _GLBegin(gcl: pointer; mode: GLenum);
syscall sysvbase TinyGLBase 64;

procedure _GLEnd(gcl: pointer);
syscall sysvbase TinyGLBase 70;

procedure _GLVertex3f(gcl: pointer; x, y, z: GLfloat);
syscall sysvbase TinyGLBase 76;

procedure _GlVertex3fv(gcl: pointer; const v: PGLfloat);
syscall sysvbase TinyGLBase 88;

procedure _GLColor3f(gcl: pointer; red, green, blue: GLfloat); 
syscall sysvbase TinyGLBase 100;

procedure _GLColor4f(gcl: pointer; red, green, blue, alpha: GLfloat); 
syscall sysvbase TinyGLBase 106;

procedure _GLNormal3f(gcl: pointer; nx, ny, nz: GLfloat);
syscall sysvbase TinyGLBase 148;

procedure _GLTexCoord2f(gcl: pointer; s, t: GLfloat); 
syscall sysvbase TinyGLBase 160;

procedure _GLMatrixMode(gcl: pointer; mode: GLenum);
syscall sysvbase TinyGLBase 190;

procedure _GLLoadIdentity(gcl: pointer);
syscall sysvbase TinyGLBase 202;

procedure _GLPushMatrix(gcl: pointer);
syscall sysvbase TinyGLBase 214;

procedure _GLPopMatrix(gcl: pointer);
syscall sysvbase TinyGLBase 220;

procedure _GLRotatef(gcl: pointer; angle, x, y, z: GLfloat); 
syscall sysvbase TinyGLBase 226;

procedure _GLTranslatef(gcl: pointer; x, y, z: GLfloat); 
syscall sysvbase TinyGLBase 232;

procedure _GLScalef(gcl: pointer; x, y, z: GLfloat); 
syscall sysvbase TinyGLBase 238;

procedure _GLViewPort(gcl: pointer; x, y: GLint; width, height: GLsizei);
syscall sysvbase TinyGLBase 244;

procedure _GLFrustum(gcl: pointer; left, right, bottom, top, zNear, zFar: GLdouble); 
syscall sysvbase TinyGLBase 250;
{$ENDIF GL_UNIT}

{$IF DEFINED(GL_UNIT) OR DEFINED(GLU_UNIT)}
procedure _GLOrtho(gcl: pointer; left, right, bottom, top, zNear, zFar: GLdouble);
syscall sysvbase TinyGLBase 256;
{$ENDIF}

{$IFDEF GL_UNIT}
function  _GLGenLists(gcl: pointer; range: GLsizei): GLuint;
syscall sysvbase TinyGLBase 262;

procedure _GLNewList(gcl: pointer; list: GLuint; mode: GLenum);
syscall sysvbase TinyGLBase 274;

procedure _GLEndList(gcl: pointer);
syscall sysvbase TinyGLBase 280;

procedure _GLCallList(gcl: pointer; list: GLuint);
syscall sysvbase TinyGLBase 286;

procedure _GLDeleteLists(gcl: pointer; list: GLuint; range: GLsizei);
syscall sysvbase TinyGLBase 292;

procedure _GLClear(gcl: pointer; mask: GLbitfield);
syscall sysvbase TinyGLBase 298;

procedure _GLClearColor(gcl: pointer; red, green, blue, alpha: GLclampf);
syscall sysvbase TinyGLBase 304;

procedure _GLClearDepth(gcl: pointer; depth: GLclampd);
syscall sysvbase TinyGLBase 310;

procedure _GLGenTextures(gcl: pointer; n: GLsizei; textures: PGLuint);
syscall sysvbase TinyGLBase 352;

procedure _GLDeleteTextures(gcl: pointer; n: GLsizei; const textures: PGLuint);
syscall sysvbase TinyGLBase 358;

procedure _GLBindTexture(gcl: pointer; target: GLenum; texture: GLuint);
syscall sysvbase TinyGLBase 364;

procedure _GLTexImage2D(gcl: pointer; target: GLenum; level, internalformat: GLint; width, height: GLsizei; border: GLint; format, atype: GLenum; const pixels: Pointer);
syscall sysvbase TinyGLBase 370;

procedure _GLTexParameteri(gcl: pointer; target: GLenum; pname: GLenum; param: GLint);
syscall sysvbase TinyGLBase 394;

procedure _GLTexParameterf(gcl: pointer; target: GLenum; pname: GLenum; param: GLfloat);
syscall sysvbase TinyGLBase 400;

procedure _GLTexGeni(gcl: pointer; coord: GLenum; pname: GLenum; param: GLint);
syscall sysvbase TinyGLBase 418;

procedure _GLMaterialfv(gcl: pointer; face, pname: GLenum; const params: PGLfloat);
syscall sysvbase TinyGLBase 430;

procedure _GLMaterialf(gcl: pointer; face, pname: GLenum; param: GLfloat);
syscall sysvbase TinyGLBase 436;

procedure _GLLightfv(gcl: pointer; light, pname: GLenum; const params: PGLfloat);
syscall sysvbase TinyGLBase 448;

procedure _GLLightf(gcl: pointer; light, pname: GLenum; param: GLfloat);
syscall sysvbase TinyGLBase 454;

procedure _GLLightModelfv(gcl: pointer; pname: GLenum; const params: PGLfloat);
syscall sysvbase TinyGLBase 466;

procedure _GLFlush(gcl: pointer);
syscall sysvbase TinyGLBase 478;

procedure _GLHint(gcl: pointer; target, mode: GLenum);
syscall sysvbase TinyGLBase 484;

procedure _GLGetFloatv(gcl: pointer; pname: GLenum; params: PGLfloat);
syscall sysvbase TinyGLBase 496;

procedure _GLEnableClientState(gcl: pointer; aarray: GLenum);
syscall sysvbase TinyGLBase 508;

procedure _GLDisableClientState(gcl: pointer; aarray: GLenum);
syscall sysvbase TinyGLBase 514;

procedure _GLVertexPointer(gcl: pointer; size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer);
syscall sysvbase TinyGLBase 526;

procedure _GLColorPointer(gcl: pointer; size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer);
syscall sysvbase TinyGLBase 532;

procedure _GLNormalPointer(gcl: pointer; atype: GLenum; stride: GLsizei; const pointer: Pointer);
syscall sysvbase TinyGLBase 538;

procedure _GLTexCoordPointer(gcl: pointer; size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer);
syscall sysvbase TinyGLBase 544;

procedure _GLDrawElements(gcl: pointer; mode: GLenum; count: GLsizei; atype: GLenum; const indices: Pointer);
syscall sysvbase TinyGLBase 562;

procedure _GLBlendFunc(gcl: pointer; sfactor, dfactor: GLenum);
syscall sysvbase TinyGLBase 586;

procedure _GLDepthMask(gcl: pointer; flag: GLboolean);
syscall sysvbase TinyGLBase 592;

procedure _GLAlphaFunc(gcl: pointer; func: GLenum; ref: GLclampf);
syscall sysvbase TinyGLBase 598;

procedure _GLPointSize(gcl: pointer; size: GLfloat);
syscall sysvbase TinyGLBase 604;

procedure _GLDepthFunc(gcl: pointer; func: GLenum);
syscall sysvbase TinyGLBase 628;

function _GLInit: Pointer; 
syscall sysvbase TinyGLBase 640;

procedure _GLClose(gcl: pointer);
syscall sysvbase TinyGLBase 646;
{$ENDIF GL_UNIT}

{$IFDEF GLU_UNIT}
procedure _GLUPerspective(gcl: pointer; fovy, aspect, zNear, zFar: GLdouble);
syscall sysvbase TinyGLBase 652;

procedure _GLULookAt(gcl: pointer; eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble);
syscall sysvbase TinyGLBase 658;
{$ENDIF GLU_UNIT}

{$IFDEF GLUT_UNIT}
procedure _GLUTInit(gcl: pointer; argcp: PLongInt; argv: PPChar);
syscall sysvbase TinyGLBase 664;

procedure _GLUTInitWindowPosition(gcl: pointer; x, y: Integer);
syscall sysvbase TinyGLBase 670;

procedure _GLUTInitWindowSize(gcl: pointer; width, height: LongInt);
syscall sysvbase TinyGLBase 676;

function  _GLUTCreateWindow(gcl: pointer; const title: PChar): LongInt;
syscall sysvbase TinyGLBase 682;

procedure _GLUTFullScreen(gcl: pointer);
syscall sysvbase TinyGLBase 688;

procedure _GLUTDestroyWindow(gcl: pointer; win: LongInt);
syscall sysvbase TinyGLBase 706;

procedure _GLUTSwapBuffers(gcl: pointer);
syscall sysvbase TinyGLBase 712;

procedure _GLUTMainLoop(gcl: pointer);
syscall sysvbase TinyGLBase 718;

procedure _GLUTPostRedisplay(gcl: pointer);
syscall sysvbase TinyGLBase 724;

procedure _GLUTDisplayFunc(gcl: pointer; f: TGlutVoidCallback);
syscall sysvbase TinyGLBase 730;

procedure _GLUTReshapeFunc(gcl: pointer; f: TGlut2IntCallback);
syscall sysvbase TinyGLBase 736;

procedure _GLUTIdleFunc(gcl: pointer; f: TGlutVoidCallback);
syscall sysvbase TinyGLBase 742; 

procedure _GLUTKeyboardFunc(gcl: pointer; f: TGlut1Char2IntCallback);
syscall sysvbase TinyGLBase 748;

procedure _GLUTMouseFunc(gcl: pointer; f: TGlut4IntCallback);
syscall sysvbase TinyGLBase 760;

procedure _GLUTMotionFunc(gcl: pointer; f: TGlut2IntCallback);
syscall sysvbase TinyGLBase 766;

function _GLUTGet(gcl: pointer; t: GLenum): LongInt;
syscall sysvbase TinyGLBase 802;

procedure _GLUTInitDisplayMode(gcl: pointer; mode: Word);
syscall sysvbase TinyGLBase 808;

procedure _GLUTSpecialFunc(gcl: pointer; f: TGlut3IntCallback);
syscall sysvbase TinyGLBase 814;

procedure _GLUTTimerFunc(gcl: pointer; millis: Word; f: TGlut1IntCallback; value: LongInt);
syscall sysvbase TinyGLBase 820;

procedure _GLUTPassiveMotionFunc(gcl: pointer; f: TGlut2IntCallback);
syscall sysvbase TinyGLBase 832;

// MorphOS specific GLUT call, returns Intuition window handle
function _GLUTGetWindowHandle(gcl: pointer): Pointer;
syscall sysvbase TinyGLBase 856;
{$ENDIF GLUT_UNIT}

{$IFDEF GL_UNIT}
function _GLGetString(gcl: pointer; name: GLenum): PChar;
syscall sysvbase TinyGLBase 862;

procedure _GLCallLists(gcl: pointer; n: GLsizei; atype: GLenum; const lists: Pointer);
syscall sysvbase TinyGLBase 892;

procedure _GLLineWidth(gcl: pointer; width: GLfloat);
syscall sysvbase TinyGLBase 910;

procedure _GLRasterPos3f(gcl: pointer; x, y, z: GLfloat);
syscall sysvbase TinyGLBase 1108;
{$ENDIF GL_UNIT}

{$IFDEF GLUT_UNIT}
procedure _GLUTVisibilityFunc(gcl: pointer; f: TGlut1IntCallback);
syscall sysvbase TinyGLBase 1114;
{$ENDIF GLUT_UNIT}

{$IFDEF GL_UNIT}
procedure _GLFogf(gcl: pointer; pname: GLenum; param: GLfloat);
syscall sysvbase TinyGLBase 1120;

procedure _GLFogfv(gcl: pointer; pname: GLenum; const params: PGLfloat); 
syscall sysvbase TinyGLBase 1126;

procedure _GLReadPixels(gcl: pointer; x, y: GLint; width, height: GLsizei; format, atype: GLenum; pixels: Pointer);
syscall sysvbase TinyGLBase 1180;

procedure _GLStencilFunc(gcl: pointer; func: GLenum; ref: GLint; mask: GLuint);
syscall sysvbase TinyGLBase 1210;

procedure _GLStencilOp(gcl: pointer; fail, zfail, zpass: GLenum);
syscall sysvbase TinyGLBase 1216;

procedure _GLColorMask(gcl: pointer; red, green, blue, alpha: GLboolean);
syscall sysvbase TinyGLBase 1282;

procedure _GLCopyTexImage2D(gcl: pointer; target: GLenum; level: GLint; internalFormat: GLenum; x, y: GLint; width, height: GLsizei; border: GLint); inline;
syscall sysvbase TinyGLBase 1402;
{$ENDIF GL_UNIT}


{ ****************************************************************************************************** }
{ ** GL functions                                                                                     ** }
{ ****************************************************************************************************** }

{$IFDEF GL_UNIT}
procedure glAlphaFunc(func: GLenum; ref: GLclampf); inline;
begin
  _GLAlphaFunc(tglContext, func, ref);
end;

procedure glBegin(mode: GLenum); inline;
begin
  _GLBegin(tglContext, mode);
end;

procedure glCallList(list: GLuint); inline;
begin
  _GLCallList(tglContext, list);
end;

procedure glCallLists(n: GLsizei; atype: GLenum; const lists: Pointer); inline;
begin
  _GLCallLists(tglContext, n, atype, lists);
end;

procedure glClear(mask: GLbitfield); inline;
begin
  _GLClear(tglContext, mask);
end;

procedure glClearColor(red, green, blue, alpha: GLclampf); inline;
begin
  _GLClearColor(tglContext, red, green, blue, alpha);
end;

procedure glClearDepth(depth: GLclampd); inline;
begin
  _GLClearDepth(tglContext, depth);
end;

procedure glColorMask(red, green, blue, alpha: GLboolean); inline;
begin
  _GLColorMask(tglContext, red, green, blue, alpha);
end;

procedure glColorPointer(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); inline;
begin
  _GLColorPointer(tglContext, size, atype, stride, pointer);
end;

procedure glCopyTexImage2D(target: GLenum; level: GLint; internalFormat: GLenum; x, y: GLint; width, height: GLsizei; border: GLint); inline;
begin
 _GLCopyTexImage2D(tglContext, target, level, internalFormat, x, y, width, height, border);
end;

procedure glCullFace(mode: GLenum); inline;
begin
  _GLCullFace(tglContext, mode);
end;

procedure glDeleteLists(list: GLuint; range: GLsizei); inline;
begin
  _GLDeleteLists(tglContext, list, range);
end;

procedure glEnd; inline;
begin
  _GLEnd(tglContext);
end;

procedure glEndList; inline;
begin
  _GLEndList(tglContext);
end;

procedure glFlush; inline;
begin
  _GLFlush(tglContext);
end;

function  glGenLists(range: GLsizei): GLuint; inline;
begin
  glGenLists:=_GLGenLists(tglContext, range);
end;

procedure glGetFloatv(pname: GLenum; params: PGLfloat); inline;
begin
  _GLGetFloatv(tglContext, pname, params);
end;

function glGetString(name: GLenum): PChar; inline;
begin
  glGetString:=_GLGetString(tglContext, name);
end;

procedure glHint(target, mode: GLenum); inline;
begin
  _GLHint(tglContext, target, mode);
end;

procedure glIndexi(c: GLint); inline;
begin
{$WARNING glIndexi is dummy.}
  // DUMMY, FIX ME!!! 
end;

procedure glLightModelfv(pname: GLenum; const params: PGLfloat); inline;
begin
  _GLLightModelfv(tglContext, pname, params);
end;

procedure glNewList(list: GLuint; mode: GLenum); inline;
begin
  _GLNewList(tglContext, list, mode);
end;

procedure glVertex2f(x, y: GLfloat); inline;
begin
  _GLVertex3f(tglContext, x, y, 0);
end;

procedure glVertex2i(x, y: GLint); inline;
begin
  _GLVertex3f(tglContext, x, y, 0);
end;

procedure glVertex3f(x, y, z: GLfloat); inline;
begin
  _GLVertex3f(tglContext, x, y ,z);
end; 

procedure glVertex3fv(const v: PGLfloat); inline;
begin
  _GLVertex3fv(tglContext, v);
end;

procedure glLightf(light, pname: GLenum; param: GLfloat); inline;
begin
  _GLLightf(tglContext, light, pname, param);
end;

procedure glLightfv(light, pname: GLenum; const params: PGLfloat); inline;
begin
  _GLLightfv(tglContext, light, pname, params);
end;

procedure glLineWidth(width: GLfloat); inline;
begin
  _GLLineWidth(tglContext, width);
end;

procedure glLoadIdentity; inline;
begin
  _GLLoadIdentity(tglContext);
end;

procedure glMaterialf(face, pname: GLenum; param: GLfloat); inline;
begin
  _GLMaterialf(tglContext, face, pname, param);
end;

procedure glMaterialfv(face, pname: GLenum; const params: PGLfloat); inline;
begin
  _GLMaterialfv(tglContext, face, pname, params);
end;

procedure glMateriali(face, pname: GLenum; param: GLint); inline;
begin
  // WTF?! 
  _GLMaterialf(tglContext, face, pname, param);
end;

procedure glMaterialiv(face, pname: GLenum; const params: PGLint); inline;
begin
  // WTF?!
  _GLMaterialfv(tglContext, face, pname, PGLfloat(params));
end;

procedure glMatrixMode(mode: GLenum); inline;
begin
  _GLMatrixMode(tglContext, mode);
end; 

procedure glNormalPointer(atype: GLenum; stride: GLsizei; const pointer: Pointer); inline;
begin
  _GLNormalPointer(tglContext, atype, stride, pointer);
end;

procedure glPointSize(size: GLfloat); inline;
begin
  // 604! :)
  _GLPointSize(tglContext, size);
end;

procedure glRasterPos3f(x, y, z: GLfloat); inline;
begin
  _GLRasterPos3f(tglContext, x, y, z);
end;

procedure glReadPixels(x, y: GLint; width, height: GLsizei; format, atype: GLenum; pixels: Pointer); inline;
begin
  _GLReadPixels(tglContext, x, y, width, height, format, atype, pixels);
end;

procedure glShadeModel(mode: GLenum); inline;
begin
  _GLShadeModel(tglContext, mode);
end;

procedure glStencilFunc(func: GLenum; ref: GLint; mask: GLuint); inline;
begin
  _GLStencilFunc(tglContext, func, ref, mask);
end;

procedure glStencilOp(fail, zfail, zpass: GLenum); inline;
begin
  _GLStencilOp(tglContext, fail, zfail, zpass);
end;

procedure glTexCoordPointer(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); inline;
begin
  _GLTexCoordPointer(tglContext, size, atype, stride, pointer);
end;

procedure glTexParameterf(target: GLenum; pname: GLenum; param: GLfloat); inline;
begin
  _GLTexParameterf(tglContext, target, pname, param);
end;

procedure glFrustum(left, right, bottom, top, zNear, zFar: GLdouble); inline;
begin
  _GLFrustum(tglContext, left, right, bottom, top, zNear, zFar);
end; 

procedure glTranslatef(x, y, z: GLfloat); inline;
begin
  _GLTranslatef(tglContext, x, y, z);
end; 

procedure glScalef(x, y, z: GLfloat); inline;
begin
  _GLScalef(tglContext, x, y, z);
end; 

procedure glRotatef(angle, x, y, z: GLfloat); inline;
begin
  _GLRotatef(tglContext, angle, x, y, z);
end; 

procedure glColor3f(red, green, blue: GLfloat); inline;
begin
  _GLColor3f(tglContext, red, green, blue);
end; 

procedure glColor4f(red, green, blue, alpha: GLfloat); inline;
begin
  _GLColor4f(tglContext, red, green, blue, alpha);
end; 

procedure glNormal3f(nx, ny, nz: GLfloat); inline;
begin
  _GLNormal3f(tglContext, nx, ny, nz);
end;

procedure glDeleteTextures(n: GLsizei; const textures: PGLuint); inline;
begin
  _GLDeleteTextures(tglContext, n, textures);
end;

procedure glDisable(cap: GLenum); inline;
begin
  _GLDisable(tglContext, cap);
end;

procedure glDisableClientState(aarray: GLenum); inline;
begin
  _GLDisableClientState(tglContext, aarray);
end;

procedure glDrawElements(mode: GLenum; count: GLsizei; atype: GLenum; const indices: Pointer); inline;
begin
  _GLDrawElements(tglContext, mode, count, atype, indices);
end;

procedure glEnable(cap: GLenum); inline;
begin
  _GLEnable(tglContext, cap);
end;

procedure glEnableClientState(aarray: GLenum); inline;
begin
  _GLEnableClientState(tglContext, aarray);
end;

procedure glFogf(pname: GLenum; param: GLfloat); inline;
begin
  _GLFogf(tglContext, pname, param);
end;

procedure glFogfv(pname: GLenum; const params: PGLfloat); inline;
begin
  _GLFogfv(tglContext, pname, params);
end;

procedure glFogi(pname: GLenum; param: GLint); inline;
begin
  // WTF!? And it actually works!
  _GLFogf(tglContext, pname, param);
end;

procedure glOrtho(left, right, bottom, top, zNear, zFar: GLdouble); inline;
begin
  _GLOrtho(tglContext, left, right, bottom, top, zNear, zFar);
end;

procedure glPopMatrix; inline;
begin
  _GLPopMatrix(tglContext);
end;

procedure glPushMatrix; inline;
begin
  _GLPushMatrix(tglContext);
end;

procedure glTexImage2D(target: GLenum; level, internalformat: GLint; width, height: GLsizei; border: GLint; format, atype: GLenum; const pixels: Pointer); inline;
begin
  _GLTexImage2D(tglContext, target, level, internalformat, width, height, border, format, atype, pixels);
end;

procedure glTexParameteri(target: GLenum; pname: GLenum; param: GLint); inline;
begin
  _GLTexParameteri(tglContext, target, pname, param);
end;

procedure glTexCoord2f(s, t: GLfloat); inline;
begin
  _GLTexCoord2f(tglContext, s, t);
end;

procedure glTexGeni(coord: GLenum; pname: GLenum; param: GLint); inline;
begin
  _GLTexGeni(tglContext, coord, pname, param);
end;

procedure glBindTexture(target: GLenum; texture: GLuint); inline;
begin
  _GLBindTexture(tglContext, target, texture);
end;

procedure glGenTextures(n: GLsizei; textures: PGLuint); inline;
begin
  _GLGenTextures(tglContext, n, textures);
end;

procedure glBlendFunc(sfactor, dfactor: GLenum); inline;
begin
  _GLBlendFunc(tglContext, sfactor, dfactor);
end;

procedure glDepthFunc(func: GLenum); inline;
begin
  _GLDepthFunc(tglContext, func);
end;

procedure glDepthMask(flag: GLboolean); inline;
begin
  _GLDepthMask(tglContext, flag);
end;

procedure glVertexPointer(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); inline;
begin
  _GLVertexPointer(tglContext, size, atype, stride, pointer);
end;

procedure glViewport(x, y: GLint; width, height: GLsizei); inline;
begin
  _GLViewport(tglContext, x, x, width, height);
end;
{$ENDIF GL_UNIT}


{ ****************************************************************************************************** }
{ ** GLU functions                                                                                    ** }
{ ****************************************************************************************************** }

{$IFDEF GLU_UNIT}
procedure gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble); inline;
begin
  _GLULookAt(tglContext, eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz);
end;

procedure gluOrtho2D(left,right, bottom, top: GLdouble); inline;
begin
  _GLOrtho(tglContext, left, right, bottom, top, -1.0, 1.0)
end;

procedure gluPerspective(fovy, aspect, zNear, zFar: GLdouble); inline;
begin
  _GLUPerspective(tglContext, fovy, aspect, zNear, zFar);
end;
{$ENDIF GLU_UNIT}


{ ****************************************************************************************************** }
{ ** GLUT functions                                                                                   ** }
{ ****************************************************************************************************** }

{$IFDEF GLUT_UNIT}
procedure GLUTInit(argcp: PLongInt; argv: PPChar); inline;
begin
  _GLUTInit(tglContext,argcp,argv);
end;

procedure GLUTInitDisplayMode(mode: Word); inline;
begin
  _GLUTInitDisplayMode(tglContext,mode);
end;

procedure GLUTInitWindowPosition(x, y: Integer); inline;
begin
 _GLUTInitWindowPosition(tglContext, x, y);
end;

procedure GLUTInitWindowSize(width, height: LongInt); inline;
begin
  _GLUTInitWindowSize(tglContext, width, height);
end;

procedure GLUTSwapBuffers; inline;
begin
  _GLUTSwapBuffers(tglContext);
end;

procedure GLUTPostRedisplay; inline;
begin
  _GLUTPostRedisplay(tglContext);
end;

procedure GLUTReshapeFunc(f: TGlut2IntCallback); inline;
begin
  _GLUTReshapeFunc(tglContext, f);
end;

function GLUTCreateWindow(const title: PChar): LongInt; inline;
begin
  GLUTCreateWindow:=_GLUTCreateWindow(tglContext, title);
end;

procedure GLUTDestroyWindow(win: LongInt); inline;
begin
  _GLUTDestroyWindow(tglContext, win);
end;

procedure GLUTDisplayFunc(f: TGlutVoidCallback); inline;
begin
  _GLUTDisplayFunc(tglContext, f);
end;

procedure GLUTIdleFunc(f: TGlutVoidCallback); inline;
begin
  _GLUTIdleFunc(tglContext, f);
end;

procedure GLUTTimerFunc(millis: Word; f: TGlut1IntCallback; value: LongInt); inline;
begin
  _GLUTTimerFunc(tglContext, millis, f, value);
end;

procedure GLUTKeyboardFunc(f: TGlut1Char2IntCallback); inline;
begin
  _GLUTKeyboardFunc(tglContext, f);
end;

procedure GLUTMouseFunc(f: TGlut4IntCallback); inline;
begin
  _GLUTMouseFunc(tglContext, f);
end;

procedure GLUTSpecialFunc(f: TGlut3IntCallback); inline;
begin
  _GLUTSpecialFunc(tglContext, f);
end;

procedure GLUTMotionFunc(f: TGlut2IntCallback); inline;
begin
  _GLUTMotionFunc(tglContext, f);
end;

procedure GLUTPassiveMotionFunc(f: TGlut2IntCallback); inline;
begin
  _GLUTPassiveMotionFunc(tglContext, f);
end;

function GLUTGetWindowHandle: pointer; inline;
begin
  GLUTGetWindowHandle:=_GLUTGetWindowHandle(tglContext);
end;

procedure GLUTVisibilityFunc(f: TGlut1IntCallback); inline;
begin
  _GLUTVisibilityFunc(tglContext, f);
end;

function  GLUTGet(t: GLenum): LongInt; inline;
begin
  GLUTGet:=_GLUTGet(tglContext,t);
end;

procedure GLUTMainLoop; inline;
begin
  _GLUTMainLoop(tglContext);
end;

procedure GLUTFullScreen; inline;
begin
  _GLUTFullScreen(tglContext);
end;

procedure GLUTSetColor(cell: Integer; red, green, blue: GLfloat); inline;
begin
{$WARNING GLUTSetColor is dummy.}
  // DUMMY, FIX ME!!! 
end;
{$ENDIF GLUT_UNIT}