source: Include/abgl.ab@ 63

Last change on this file since 63 was 63, checked in by NoWest, 17 years ago
File size: 26.3 KB
Line 
1#ifndef _INC_ABGL
2#define _INC_ABGL
3
4#include <GL/gl.sbp>
5#include <GL/glu.sbp>
6
7Type XYZ_FLOAT
8 x As GLfloat
9 y As GLfloat
10 z As GLfloat
11End Type
12
13Type XYZ_DOUBLE
14 x As GLdouble
15 y As GLdouble
16 z As GLdouble
17End Type
18
19Class Vector3f
20Public /* constructor */
21 Sub Vector3f(x As GLfloat, y As GLfloat, z As GLfloat)
22 xyz.x=x
23 xyz.y=y
24 xyz.z=z
25 End Sub
26
27Public /* destructor */
28 Sub ~Vector3f()
29 End Sub
30
31Public /* property */
32 Function X() As GLfloat
33 Return xyz.x
34 End Function
35 Function Y() As GLfloat
36 Return xyz.y
37 End Function
38 Function Z() As GLfloat
39 Return xyz.z
40 End Function
41 Sub X(x As GLfloat)
42 xyz.x=x
43 End Sub
44 Sub Y(y As GLfloat)
45 xyz.y=y
46 End Sub
47 Sub Z(z As GLfloat)
48 xyz.z=z
49 End Sub
50
51Protected
52 xyz As XYZ_FLOAT
53End Class
54
55Class Vector3d
56Public /* constructor */
57 Sub Vector3d(x As GLdouble, y As GLdouble, z As GLdouble)
58 xyz.x=x
59 xyz.y=y
60 xyz.z=z
61 End Sub
62
63Public /* destructor */
64 Sub ~Vector3d()
65 End Sub
66
67Public /* property */
68 Function X() As GLdouble
69 Return xyz.x
70 End Function
71 Function Y() As GLdouble
72 Return xyz.y
73 End Function
74 Function Z() As GLdouble
75 Return xyz.z
76 End Function
77 Sub X(x As GLdouble)
78 xyz.x=x
79 End Sub
80 Sub Y(y As GLdouble)
81 xyz.y=y
82 End Sub
83 Sub Z(z As GLdouble)
84 xyz.z=z
85 End Sub
86
87Protected
88 xyz As XYZ_DOUBLE
89End Class
90
91Type RGB_FLOAT
92 r As GLfloat
93 g As GLfloat
94 b As GLfloat
95End Type
96
97Type RGB_DOUBLE
98 r As GLdouble
99 g As GLdouble
100 b As GLdouble
101End Type
102
103Class Color3f
104Public /* constructor */
105 Sub Color3f(r As GLfloat, g As GLfloat, b As GLfloat)
106 rgb.r = r
107 rgb.g = g
108 rgb.b = b
109 End Sub
110
111Public /* destructor */
112 Sub ~Color3f()
113 End Sub
114
115Public /* property */
116 Function R() As GLfloat
117 Return rgb.r
118 End Function
119 Function G() As GLfloat
120 Return rgb.g
121 End Function
122 Function B() As GLfloat
123 Return rgb.r
124 End Function
125 Sub R(r As GLfloat)
126 rgb.r = r
127 End Sub
128 Sub G(g As GLfloat)
129 rgb.g = g
130 End Sub
131 Sub B(b As GLfloat)
132 rgb.b = b
133 End Sub
134
135Protected
136 rgb As RGB_FLOAT
137End Class
138
139Class Color3d
140Public /* constructor */
141 Sub Color3d(r As GLdouble, g As GLdouble, b As GLdouble)
142 rgb.r = r
143 rgb.g = g
144 rgb.b = b
145 End Sub
146
147Public /* destructor */
148 Sub ~Color3d()
149 End Sub
150
151Public /* property */
152 Function R() As GLdouble
153 Return rgb.r
154 End Function
155 Function G() As GLdouble
156 Return rgb.g
157 End Function
158 Function B() As GLdouble
159 Return rgb.r
160 End Function
161 Sub R(r As GLdouble)
162 rgb.r = r
163 End Sub
164 Sub G(g As GLdouble)
165 rgb.g = g
166 End Sub
167 Sub B(b As GLdouble)
168 rgb.b = b
169 End Sub
170
171Protected
172 rgb As RGB_DOUBLE
173End Class
174
175Type RGBA_FLOAT
176 r As GLfloat
177 g As GLfloat
178 b As GLfloat
179 a As GLfloat
180End Type
181
182Type RGBA_DOUBLE
183 r As GLdouble
184 g As GLdouble
185 b As GLdouble
186 a As GLdouble
187End Type
188
189Class Color4f
190Public /* constructor */
191 Sub Color4f(r As GLfloat, g As GLfloat, b As GLfloat, a As GLfloat)
192 rgba.r = r
193 rgba.g = g
194 rgba.b = b
195 rgba.a = a
196 End Sub
197
198Public /* destructor */
199 Sub ~Color4f()
200 End Sub
201
202Public /* property */
203 Function R() As GLfloat
204 Return rgba.r
205 End Function
206 Function G() As GLfloat
207 Return rgba.g
208 End Function
209 Function B() As GLfloat
210 Return rgba.r
211 End Function
212 Function A() As GLfloat
213 Return rgba.a
214 End Function
215 Sub R(r As GLfloat)
216 rgba.r = r
217 End Sub
218 Sub G(g As GLfloat)
219 rgba.g = g
220 End Sub
221 Sub B(b As GLfloat)
222 rgba.b = b
223 End Sub
224 Sub A(a As GLfloat)
225 rgba.a = a
226 End Sub
227
228Protected
229 rgba As RGBA_FLOAT
230End Class
231
232Class Color4d
233
234Public /* constructor */
235 Sub Color4d(r As GLdouble, g As GLdouble, b As GLdouble, a As GLdouble)
236 rgba.r = r
237 rgba.g = g
238 rgba.b = b
239 rgba.a = a
240 End Sub
241
242Public /* destructor */
243 Sub ~Color4d()
244 End Sub
245
246Public /* property */
247 Function R() As GLdouble
248 Return rgba.r
249 End Function
250 Function G() As GLdouble
251 Return rgba.g
252 End Function
253 Function B() As GLdouble
254 Return rgba.r
255 End Function
256 Function A() As GLdouble
257 Return rgba.a
258 End Function
259 Sub R(r As GLdouble)
260 rgba.r = r
261 End Sub
262 Sub G(g As GLdouble)
263 rgba.g = g
264 End Sub
265 Sub B(b As GLdouble)
266 rgba.b = b
267 End Sub
268 Sub A(a As GLdouble)
269 rgba.a = a
270 End Sub
271
272Protected
273 rgba As RGBA_DOUBLE
274End Class
275
276
277
278Class Light
279Private
280 Number As GLenum
281
282Public
283 Sub Enabled(enabled As GLboolean)
284 Dim lighting As GLboolean
285 glGetBooleanv(Number,VarPtr(lighting))
286 Return lighting
287 End Sub
288 Function Enable() As GLboolean
289 If enabled Then
290 glEnable(Number)
291 Else
292 glDisable(Number)
293 End If
294 End Function
295
296Public /* constructor */
297 Sub Light(num As GLenum)
298 Number=num
299 End Sub
300
301Public
302 Sub SetAmbient(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
303 Dim amb[3] As GLfloat
304 amb[0]=red
305 amb[1]=green
306 amb[2]=blue
307 amb[3]=alpha
308 glLightfv(Number,GL_AMBIENT,amb)
309 End Sub
310 Sub SetAmbient(color As Color4f)
311 Dim amb[3] As GLfloat
312 amb[0]=color.R
313 amb[1]=color.G
314 amb[2]=color.B
315 amb[3]=color.A
316 glLightfv(Number,GL_AMBIENT,amb)
317 End Sub
318 Sub SetAmbient(amb As *GLfloat)
319 glLightfv(Number,GL_AMBIENT,amb)
320 End Sub
321
322 Sub SetDiffuse(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
323 Dim dif[3] As GLfloat
324 dif[0]=red
325 dif[1]=green
326 dif[2]=blue
327 dif[3]=alpha
328 glLightfv(Number,GL_DIFFUSE,dif)
329 End Sub
330 Sub SetDiffuse(color As Color4f)
331 Dim dif[3] As GLfloat
332 amb[0]=color.R
333 amb[1]=color.G
334 amb[2]=color.B
335 amb[3]=color.A
336 glLightfv(Number,GL_DIFFUSE,dif)
337 End Sub
338 Sub SetDiffuse(dif As *GLfloat)
339 glLightfv(Number,GL_DIFFUSE,dif)
340 End Sub
341
342 Sub SetSpecular(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
343 Dim spc[3] As GLfloat
344 spc[0]=red
345 spc[1]=green
346 spc[2]=blue
347 spc[3]=alpha
348 glLightfv(Number,GL_SPECULAR,spc)
349 End Sub
350 Sub SetSpecular(color As Color4f)
351 Dim spc[3] As GLfloat
352 amb[0]=color.R
353 amb[1]=color.G
354 amb[2]=color.B
355 amb[3]=color.A
356 glLightfv(Number,GL_SPECULAR,spc)
357 End Sub
358 Sub SetSpecular(spc As *GLfloat)
359 glLightfv(Number,GL_SPECULAR,spc)
360 End Sub
361
362 Sub SetPosition(pos As *GLfloat)
363 glLightfv(Number,GL_POSITION,pos)
364 End Sub
365End Class
366
367Class Material
368Public
369 Sub Ambient(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
370 Dim face As GLenum
371 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
372 Dim amb[3] As GLfloat
373 amb[0]=red
374 amb[1]=green
375 amb[2]=blue
376 amb[3]=alpha
377 glMaterialfv(face,GL_AMBIENT,amb)
378 End Sub
379 Sub Ambient(color As Color4f)
380 Dim face As GLenum
381 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
382 Dim amb[3] As GLfloat
383 amb[0]=color.R
384 amb[1]=color.G
385 amb[2]=color.B
386 amb[3]=color.A
387 glMaterialfv(face,GL_AMBIENT,amb)
388 End Sub
389 Sub Ambient(amb As *GLfloat)
390 glMaterialfv(face,GL_AMBIENT,amb)
391 End Sub
392
393 Sub Diffuse(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
394 Dim face As GLenum
395 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
396 Dim dif[3] As GLfloat
397 dif[0]=red
398 dif[1]=green
399 dif[2]=blue
400 dif[3]=alpha
401 glMaterialfv(face,GL_DIFFUSE,dif)
402 End Sub
403 Sub Diffuse(color As Color4f)
404 Dim face As GLenum
405 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
406 Dim dif[3] As GLfloat
407 dif[0]=color.R
408 dif[1]=color.G
409 dif[2]=color.B
410 dif[3]=color.A
411 glMaterialfv(face,GL_DIFFUSE,dif)
412 End Sub
413 Sub Diffuse(dif As *GLfloat)
414 glMaterialfv(face,GL_DIFFUSE,dif)
415 End Sub
416
417 Sub Specular(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
418 Dim face As GLenum
419 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
420 Dim spc[3] As GLfloat
421 spc[0]=red
422 spc[1]=green
423 spc[2]=blue
424 spc[3]=alpha
425 glMaterialfv(face,GL_SPECULAR,spc)
426 End Sub
427 Sub Specular(color As Color4f)
428 Dim face As GLenum
429 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
430 Dim spc[3] As GLfloat
431 spc[0]=color.R
432 spc[1]=color.G
433 spc[2]=color.B
434 spc[3]=color.A
435 glMaterialfv(face,GL_SPECULAR,spc)
436 End Sub
437 Sub Specular(spc As *GLfloat)
438 glMaterialfv(face,GL_SPECULAR,spc)
439 End Sub
440
441 Sub Shininess(shin As GLfloat)
442 Dim face As GLenum
443 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
444 glMaterialf(face,GL_SHININESS,shin)
445 End Sub
446
447 Sub Emission(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
448 Dim face As GLenum
449 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
450 Dim ems[3] As GLfloat
451 ems[0]=red
452 ems[1]=green
453 ems[2]=blue
454 ems[3]=alpha
455 glMaterialfv(face,GL_EMISSION,ems)
456 End Sub
457End Class
458
459Class ModelView
460Public
461 Sub LoadIdentity()
462 Dim mode As GLenum
463 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
464 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
465 glLoadIdentity()
466 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
467 End Sub
468 Sub LookAt(eyex As GLdouble, eyey As GLdouble, eyez As GLdouble, centerx As GLdouble, centery As GLdouble, centerz As GLdouble, upx As GLdouble, upy As GLdouble, upz As GLdouble)
469 Dim mode As GLenum
470 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
471 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
472 gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz)
473 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
474 End Sub
475 Sub RotateX(angle As GLdouble)
476 Dim mode As GLenum
477 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
478 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
479 glRotated(angle, 1.0 As GLdouble, 0.0 As GLdouble, 0.0 As GLdouble)
480 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
481 End Sub
482 Sub RotateX(angle As GLfloat)
483 Dim mode As GLenum
484 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
485 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
486 glRotatef(angle, 1.0 As GLfloat, 0.0 As GLfloat, 0.0 As GLfloat)
487 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
488 End Sub
489 Sub RotateY(angle As GLdouble)
490 Dim mode As GLenum
491 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
492 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
493 glRotated(angle, 0.0 As GLdouble, 1.0 As GLdouble, 0.0 As GLdouble)
494 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
495 End Sub
496 Sub RotateY(angle As GLfloat)
497 Dim mode As GLenum
498 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
499 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
500 glRotatef(angle, 0.0 As GLfloat, 1.0 As GLfloat, 0.0 As GLfloat)
501 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
502 End Sub
503 Sub RotateZ(angle As GLdouble)
504 Dim mode As GLenum
505 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
506 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
507 glRotated(angle, 0.0 As GLdouble, 0.0 As GLdouble, 1.0 As GLdouble)
508 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
509 End Sub
510 Sub RotateZ(angle As GLfloat)
511 Dim mode As GLenum
512 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
513 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
514 glRotatef(angle, 0.0 As GLfloat, 0.0 As GLfloat, 1.0 As GLfloat)
515 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
516 End Sub
517 Sub Scale(x As GLdouble, y As GLdouble, z As GLdouble)
518 Dim mode As GLenum
519 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
520 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
521 glScaled(x, y, z)
522 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
523 End Sub
524 Sub Scale(x As GLfloat, y As GLfloat, z As GLfloat)
525 Dim mode As GLenum
526 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
527 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
528 glScalef(x, y, z)
529 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
530 End Sub
531 Sub Translate(x As GLdouble, y As GLdouble, z As GLdouble)
532 Dim mode As GLenum
533 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
534 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
535 glTranslated(x, y, z)
536 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
537 End Sub
538 Sub Translate(x As GLfloat, y As GLfloat, z As GLfloat)
539 Dim mode As GLenum
540 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
541 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
542 glTranslatef(x, y, z)
543 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
544 End Sub
545End Class
546
547Class Projection
548Public
549 Sub LoadIdentity()
550 Dim mode As GLenum
551 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
552 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
553 glLoadIdentity()
554 If mode<>GL_PROJECTION Then glMatrixMode(mode)
555 End Sub
556 Sub Ortho2D(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble)
557 Dim mode As GLenum
558 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
559 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
560 gluOrtho2D(left, right, bottom, top)
561 If mode<>GL_PROJECTION Then glMatrixMode(mode)
562 End Sub
563 Sub Ortho3D(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble, zNear As GLdouble, zFar As GLdouble)
564 Dim mode As GLenum
565 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
566 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
567 glOrtho(left, right, bottom, top, zNear, zFar)
568 If mode<>GL_PROJECTION Then glMatrixMode(mode)
569 End Sub
570 Sub Frustum(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble, zNear As GLdouble, zFar As GLdouble)
571 Dim mode As GLenum
572 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
573 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
574 glFrustum(left, right, bottom, top, zNear, zFar)
575 If mode<>GL_PROJECTION Then glMatrixMode(mode)
576 End Sub
577 Sub Perspective(fovy As GLdouble, aspect As GLdouble, zNear As GLdouble, zFar As GLdouble)
578 Dim mode As GLenum
579 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
580 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
581 gluPerspective(fovy, aspect, zNear, zFar)
582 If mode<>GL_PROJECTION Then glMatrixMode(mode)
583 End Sub
584End Class
585
586Class Transform
587Public
588 Projection As Projection
589 ModelView As ModelView
590End Class
591
592Class LightModel
593Public
594/* Function Ambient () As GLenum
595 Dim amb As GLenum
596 glGetFloatv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb))
597 Return func
598 End Function*/
599 Sub Ambient(amb As *GLfloat)
600 glLightModelfv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb))
601 End Sub
602
603 Function LocalView() As GLboolean
604 Dim local As GLboolean
605 glGetBooleanv(GL_LIGHT_MODEL_LOCAL_VIEW,VarPtr(local))
606 Return local
607 End Function
608 Sub LocalView(enable As GLboolean)
609 If enable Then
610 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEW,GL_TRUE)
611 Else
612 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEW,GL_FALSE)
613 End If
614 End Sub
615
616 Function TwoSide() As GLboolean
617 Dim local As GLboolean
618 glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE,VarPtr(local))
619 Return local
620 End Function
621 Sub TwoSide(enable As GLboolean)
622 If enable Then
623 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE)
624 Else
625 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE)
626 End If
627 End Sub
628End Class
629
630Class RenderState
631Public /* Composiotion */
632 LightModel As LightModel
633
634Public
635 Function AlphaTestEnable() As GLboolean
636 Dim alpha As GLboolean
637 glGetBooleanv(GL_ALPHA_TEST,VarPtr(alpha))
638 Return alpha
639 End Function
640 Sub AlphaTestEnable(enable As GLboolean)
641 If enable Then
642 glEnable(GL_ALPHA_TEST)
643 Else
644 glDisable(GL_ALPHA_TEST)
645 End If
646 End Sub
647
648 Function AlphaFunction() As GLenum
649 Dim func As GLenum
650 glGetIntegerv(GL_ALPHA_TEST_FUNC,VarPtr(func))
651 Return func
652 End Function
653 Sub AlphaFunction(func As GLenum)
654 Dim ref As GLclampf
655 glGetFloatv(GL_ALPHA_TEST_REF,VarPtr(ref))
656 glAlphaFunc(func,ref)
657 End Sub
658
659 Function BlendEnable() As GLboolean
660 Dim blend As GLboolean
661 glGetBooleanv(GL_BLEND,VarPtr(blend))
662 Return blend
663 End Function
664 Sub BlendEnable(enable As GLboolean)
665 If enable Then
666 glEnable(GL_BLEND)
667 Else
668 glDisable(GL_BLEND)
669 End If
670 End Sub
671
672 Function BlendDestinationFactor() As GLenum
673 Dim dfactor As GLenum
674 glGetIntegerv(GL_BLEND_DST,VarPtr(dfactor))
675 Return dfactor
676 End Function
677 Sub BlendDestinationFactor(dfactor As GLenum)
678 Dim sfactor As GLenum
679 glGetIntegerv(GL_BLEND_SRC,VarPtr(sfactor))
680 glBlendFunc(sfactor,dfactor)
681 End Sub
682
683 Function BlendSourceFactor() As GLenum
684 Dim sfactor As GLenum
685 glGetIntegerv(GL_BLEND_SRC,VarPtr(sfactor))
686 Return sfactor
687 End Function
688 Sub BlendSourceFactor(sfactor As GLenum)
689 Dim dfactor As GLenum
690 glGetIntegerv(GL_BLEND_DST,VarPtr(dfactor))
691 glBlendFunc(sfactor,dfactor)
692 End Sub
693
694 Function CullFaceEnable() As GLboolean
695 Dim cull As GLboolean
696 glGetBooleanv(GL_CULL_FACE,VarPtr(cull))
697 Return cull
698 End Function
699 Sub CullFaceEnable(enable As GLboolean)
700 If enable Then
701 glEnable(GL_CULL_FACE)
702 Else
703 glDisable(GL_CULL_FACE)
704 End If
705 End Sub
706
707 Function CullFaceMode () As GLenum
708 Dim mode As GLenum
709 glGetIntegerv(GL_CULL_FACE_MODE,VarPtr(mode))
710 Return mode
711 End Function
712 Sub CullFaceMode(mode As GLenum)
713 glCullFace(mode)
714 End Sub
715
716 Function DepthTestEnable () As GLboolean
717 Dim depth As GLboolean
718 glGetBooleanv(GL_DEPTH_TEST,VarPtr(depth))
719 Return depth
720 End Function
721 Sub DepthTestEnable(enable As GLboolean)
722 If enable Then
723 glEnable(GL_DEPTH_TEST)
724 Else
725 glDisable(GL_DEPTH_TEST)
726 End If
727 End Sub
728
729 Function DepthFunction () As GLenum
730 Dim func As GLenum
731 glGetIntegerv(GL_DEPTH_FUNC,VarPtr(func))
732 Return func
733 End Function
734 Sub DepthFunction(func As GLenum)
735 glDepthFunc(func)
736 End Sub
737
738 Function DepthBufferWritable() As GLboolean
739 Dim writable As GLboolean
740 glGetBooleanv(GL_DEPTH_WRITEMASK,VarPtr(writable))
741 Return writable
742 End Function
743 Sub DepthBufferWritable(enable As GLboolean)
744 If enable Then
745 glDepthMask(GL_DEPTH_WRITEMASK)
746 Else
747 glDepthMask(GL_DEPTH_WRITEMASK)
748 End If
749 End Sub
750
751 Function DitherEnable() As GLboolean
752 Dim dither As GLboolean
753 glGetBooleanv(GL_DITHER,VarPtr(dither))
754 Return dither
755 End Function
756 Sub DitherEnable(enable As GLboolean)
757 If enable Then
758 glEnable(GL_DITHER)
759 Else
760 glDisable(GL_DITHER)
761 End If
762 End Sub
763
764 Function FogEnable () As GLboolean
765 Dim fog As GLboolean
766 glGetBooleanv(GL_FOG,VarPtr(fog))
767 Return fog
768 End Function
769 Sub FogEnable(enable As GLboolean)
770 If enable Then
771 glEnable(GL_FOG)
772 Else
773 glDisable(GL_FOG)
774 End If
775 End Sub
776
777 Function FogMode() As GLenum
778 Dim mode As GLenum
779 glGetIntegerv(GL_FOG_MODE,VarPtr(mode))
780 Return mode
781 End Function
782 Sub FogMode(mode As GLenum)
783 glFogi(GL_FOG_MODE,mode)
784 End Sub
785
786 Function FogColor() As *GLfloat
787 glGetFloatv(GL_FOG_COLOR,FogColor)
788 Return FogColor
789 End Function
790 Sub FogColor(fcolor As *GLfloat)
791 glFogfv(GL_FOG_COLOR,fcolor)
792 End Sub
793
794 Function FogDensity() As GLfloat
795 Dim density As GLfloat
796 glGetFloatv(GL_FOG_DENSITY,density)
797 Return density
798 End Function
799 Sub FogDensity(density As GLfloat)
800 glFogf(GL_FOG_DENSITY,density)
801 End Sub
802
803 Function FogStart() As GLfloat
804 Dim fstrat As GLfloat
805 glGetFloatv(GL_FOG_START,fstrat)
806 Return fstrat
807 End Function
808 Sub FogStart(fstrat As GLfloat)
809 glFogf(GL_FOG_START,fstrat)
810 End Sub
811
812 Function FogEnd() As GLfloat
813 Dim fend As GLfloat
814 glGetFloatv(GL_FOG_END,fend)
815 Return fend
816 End Function
817 Sub FogEnd(fend As GLfloat)
818 glFogf(GL_FOG_END,fend)
819 End Sub
820
821 Function Lighting() As GLboolean
822 Dim lighting As GLboolean
823 glGetBooleanv(GL_LIGHTING,VarPtr(lighting))
824 Return lighting
825 End Function
826 Sub Lighting(enable As GLboolean)
827 If enable Then
828 glEnable(GL_LIGHTING)
829 Else
830 glDisable(GL_LIGHTING)
831 End If
832 End Sub
833
834 Function LineSmoothEnable() As GLboolean
835 Dim smooth As GLboolean
836 glGetBooleanv(GL_LINE_SMOOTH,VarPtr(smooth))
837 Return smooth
838 End Function
839 Sub LineSmoothEnable(enable As GLboolean)
840 If enable Then
841 glEnable(GL_LINE_SMOOTH)
842 Else
843 glDisable(GL_LINE_SMOOTH)
844 End If
845 End Sub
846
847 Function LogicOpEnable() As GLboolean
848 Dim logic As GLboolean
849 glGetBooleanv(GL_COLOR_LOGIC_OP,VarPtr(logic))
850 Return logic
851 End Function
852 Sub LogicOpEnable(enable As GLboolean)
853 If enable Then
854 glEnable(GL_COLOR_LOGIC_OP)
855 Else
856 glDisable(GL_COLOR_LOGIC_OP)
857 End If
858 End Sub
859
860 Function LogicOpCode() As GLenum
861 Dim code As GLenum
862 glGetFloatv(GL_COLOR_LOGIC_OP_MODE,code)
863 Return code
864 End Function
865 Sub LogicOpCode(code As GLenum)
866 glLogicOp(code)
867 End Sub
868
869 Function PointSmoothEnable() As GLboolean
870 Dim smooth As GLboolean
871 glGetBooleanv(GL_POINT_SMOOTH,VarPtr(smooth))
872 Return smooth
873 End Function
874 Sub PointSmoothEnable(enable As GLboolean)
875 If enable Then
876 glEnable(GL_POINT_SMOOTH)
877 Else
878 glDisable(GL_POINT_SMOOTH)
879 End If
880 End Sub
881
882 Function PolygonSmoothEnable() As GLboolean
883 Dim smooth As GLboolean
884 glGetBooleanv(GL_POLYGON_SMOOTH,VarPtr(smooth))
885 Return smooth
886 End Function
887 Sub PolygonSmoothEnable(enable As GLboolean)
888 If enable Then
889 glEnable(GL_POLYGON_SMOOTH)
890 Else
891 glDisable(GL_POLYGON_SMOOTH)
892 End If
893 End Sub
894
895 Function ReferenceAlpha() As GLclampf
896 Dim ref As GLclampf
897 glGetFloatv(GL_ALPHA_TEST_REF,VarPtr(ref))
898 Return ref
899 End Function
900 Sub ReferenceAlpha(ref As GLclampf)
901 Dim func As GLenum
902 glGetIntegerv(GL_ALPHA_TEST_FUNC,VarPtr(func))
903 glAlphaFunc(func,ref)
904 End Sub
905
906 Function ShadeModel() As GLenum
907 Dim mode As GLenum
908 glGetIntegerv(GL_SHADE_MODEL,VarPtr(mode))
909 Return mode
910 End Function
911 Sub ShadeModel(mode As GLenum)
912 glShadeModel(mode)
913 End Sub
914End Class
915
916
917Enum ColorType
918 RgbColor=0
919 RgbaColor=0
920 IndexColor
921End Enum
922
923Enum BufferType
924 SingleBuffer=0
925 DoubleBuffer
926End Enum
927
928Enum ClearBuffer
929 DepthBufferBit = &H00000100
930 AccumBufferBit = &H00000200
931 StencilBufferBit = &H00000400
932 ColorBufferBit = &H00004000
933End Enum
934
935Enum PrimitiveMode
936 Points = &H0000
937 Lines = &H0001
938 LineLoop = &H0002
939 LineStrip = &H0003
940 Triangles = &H0004
941 TriangleStrip = &H0005
942 TriangleFan = &H0006
943 Quads = &H0007
944 QuadStrip = &H0008
945 Polygon = &H0009
946End Enum
947
948Class RenderingContext
949Public /* Composiotion */
950 Material As Material
951 RenderState As RenderState
952 Transform As Transform
953 Lights[ELM(8)] As Light
954
955Public /* Constructor */
956 Sub RenderingContext()
957 Dim hrc As HGLRC
958 hrc=wglGetCurrentContext()
959 If hrc Then
960 wglMakeCurrent(NULL,NULL)
961 wglDeleteContext(hrc)
962 End If
963
964 Lights[0].Light(GL_LIGHT0)
965 Lights[1].Light(GL_LIGHT1)
966 Lights[2].Light(GL_LIGHT2)
967 Lights[3].Light(GL_LIGHT3)
968 Lights[4].Light(GL_LIGHT4)
969 Lights[5].Light(GL_LIGHT5)
970 Lights[6].Light(GL_LIGHT6)
971 Lights[7].Light(GL_LIGHT7)
972 End Sub
973 Sub RenderingContext(hdc As HDC, ByRef pfd As PIXELFORMATDESCRIPTOR)
974 RenderingContext()
975
976 Dim pf As Long
977 pf=ChoosePixelFormat(hdc,pfd)
978 If pf=0 Then
979 MessageBox(NULL,"Choose Pixel Format failed","error",MB_OK)
980 Exit Sub
981 End If
982 If SetPixelFormat(hdc,pf,pfd)=FALSE Then
983 MessageBox(NULL,"Set Pixel Format failed","error",MB_OK)
984 Exit Sub
985 End If
986
987 Dim hrc As HGLRC
988 hrc=wglCreateContext(hdc)
989 wglMakeCurrent(hdc,hrc)
990 End Sub
991 Sub RenderingContext(hdc As HDC, ByRef ctype As ColorType, ByRef btype As BufferType)
992 RenderingContext()
993
994 Dim pfd As PIXELFORMATDESCRIPTOR
995 pfd.nSize=SizeOf(PIXELFORMATDESCRIPTOR) As Word
996 pfd.nVersion=GL_VERSION_1_1
997 If btype=BufferType.DoubleBuffer As Long Then
998 pfd.dwFlags or=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
999 Else
1000 pfd.dwFlags or=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL
1001 End If
1002 If ctype=ColorType.RgbColor As Long Then
1003 pfd.iPixelType=PFD_TYPE_RGBA
1004 Else
1005 pfd.iPixelType=PFD_TYPE_COLORINDEX
1006 End If
1007 pfd.cColorBits=24
1008 pfd.cRedBits=0
1009 pfd.cRedShift=0
1010 pfd.cGreenBits=0
1011 pfd.cGreenShift=0
1012 pfd.cBlueBits=0
1013 pfd.cBlueShift=0
1014 pfd.cAlphaBits=0
1015 pfd.cAlphaShift=0
1016 pfd.cAccumBits=0
1017 pfd.cAccumRedBits=0
1018 pfd.cAccumGreenBits=0
1019 pfd.cAccumBlueBits=0
1020 pfd.cAccumAlphaBits=0
1021 pfd.cDepthBits=32
1022 pfd.cStencilBits=0
1023 pfd.cAuxBuffers=0
1024 pfd.iLayerType=PFD_MAIN_PLANE
1025 pfd.bReserved=0
1026 pfd.dwLayerMask=0
1027 pfd.dwVisibleMask=0
1028 pfd.dwDamageMask=0
1029 RenderingContext(hdc,pfd)
1030 End Sub
1031 Sub RenderingContext(hdc As HDC)
1032 RenderingContext(hdc As HDC, ColorType.RgbColor, BufferType.DoubleBuffer)
1033 End Sub
1034
1035Public /* Destructor */
1036 Sub ~RenderingContext()
1037 Dim hrc As HGLRC
1038 hrc=wglGetCurrentContext()
1039 wglMakeCurrent(NULL,NULL)
1040 wglDeleteContext(hrc)
1041 End Sub
1042
1043Public /* Method */
1044 Sub Begin(mode As GLenum)
1045 glBegin(mode)
1046 End Sub
1047 Sub Begin(mode As PrimitiveMode)
1048 glBegin(mode)
1049 End Sub
1050 Sub Clear(mask As GLbitfield)
1051 glClear(mask)
1052 End Sub
1053 Sub Clear(mask As ClearBuffer)
1054 glClear(mask)
1055 End Sub
1056
1057 Sub ClearAccum(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1058 glClearAccum(red, green, blue, alpha)
1059 End Sub
1060 Sub ClearAccum(color As Color4f)
1061 glClearAccum(color.R, color.G, color.B, color.A)
1062 End Sub
1063 Sub ClearColor(red As GLclampf, green As GLclampf, blue As GLclampf, alpha As GLclampf)
1064 glClearColor(red, green, blue, alpha)
1065 End Sub
1066 Sub ClearColor(color As Color4f)
1067 glClearColor(color.R, color.G, color.B, color.A)
1068 End Sub
1069 Sub ClearDepth(depth As GLclampd)
1070 glClearDepth(depth)
1071 End Sub
1072 Sub ClearIndex(c As GLfloat)
1073 glClearIndex(c)
1074 End Sub
1075 Sub ClearStencil(s As GLint)
1076 glClearStencil(s)
1077 End Sub
1078
1079 Sub Color(red As GLdouble, green As GLdouble, blue As GLdouble)
1080 glColor3d(red,green,blue)
1081 End Sub
1082 Sub Color(red As GLdouble, green As GLdouble, blue As GLdouble, alpha As GLdouble)
1083 glColor4d(red,green,blue,alpha)
1084 End Sub
1085
1086 Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat)
1087 glColor3f(red,green,blue)
1088 End Sub
1089 Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1090 glColor4f(red,green,blue,alpha)
1091 End Sub
1092
1093 Sub DrawPrimiteve()
1094 End Sub
1095
1096 Sub End()
1097 glEnd()
1098 End Sub
1099
1100 Sub Finish()
1101 glFinish()
1102 End Sub
1103 Sub Flush()
1104 glFlush()
1105 End Sub
1106
1107 Function GenerateTexures() As GLint
1108 glGenTextures()
1109 End Function
1110
1111 Sub MatrixMode(mode As GLenum)
1112 glMatrixMode(mode)
1113 End Sub
1114
1115 Sub Present()
1116 SwapBuffers(wglGetCurrentDC())
1117 End Sub
1118 Sub Present(hdc As HDC)
1119 SwapBuffers(hdc)
1120 End Sub
1121
1122 Sub PopMatrix()
1123 glPopMatrix()
1124 End Sub
1125
1126 Sub PushMatrix()
1127 glPushMatrix()
1128 End Sub
1129
1130 Sub Vertex(x As GLdouble, y As GLdouble)
1131 glVertex2d(x,y)
1132 End Sub
1133 Sub Vertex(x As GLdouble, y As GLdouble, z As GLdouble)
1134 glVertex3d(x,y,z)
1135 End Sub
1136 Sub Vertex(x As GLdouble, y As GLdouble, z As GLdouble, w As GLdouble)
1137 glVertex4d(x,y,z,w)
1138 End Sub
1139 Sub Vertex(x As GLfloat, y As GLfloat)
1140 glVertex2f(x,y)
1141 End Sub
1142 Sub Vertex(x As GLfloat, y As GLfloat, z As GLfloat)
1143 glVertex3f(x,y,z)
1144 End Sub
1145 Sub Vertex(x As GLfloat, y As GLfloat, z As GLfloat, w As GLfloat)
1146 glVertex4f(x,y,z,w)
1147 End Sub
1148
1149 Sub Viewport(x As GLint, y As GLint, width As GLsizei, height As GLsizei)
1150 glViewport(x, y, width, height)
1151 End Sub
1152End Class
1153
1154
1155
1156#endif
Note: See TracBrowser for help on using the repository browser.