source: Include/abgl.ab@ 75

Last change on this file since 75 was 72, checked in by NoWest, 18 years ago
File size: 36.4 KB
Line 
1#ifndef _INC_ABGL
2#define _INC_ABGL
3
4#include <GL/gl.sbp>
5#include <GL/glu.sbp>
6
7Type XY_FLOAT
8 x As GLfloat
9 y As GLfloat
10End Type
11
12Type XY_DOUBLE
13 x As GLdouble
14 y As GLdouble
15End Type
16
17Class Vector2f
18Public /* constructor */
19 Sub Vector2f(x As GLfloat, y As GLfloat)
20 This.X=x
21 This.Y=y
22 End Sub
23
24Public /* destructor */
25 Sub ~Vector2f()
26 End Sub
27
28Public /* property */
29 Function X() As GLfloat
30 Return xy.x
31 End Function
32 Function Y() As GLfloat
33 Return xy.y
34 End Function
35 Sub X(x As GLfloat)
36 xy.x=x
37 End Sub
38 Sub Y(y As GLfloat)
39 xy.y=y
40 End Sub
41
42Public /* operator */
43 Sub Operator = (vec As Vector2f)
44 This.X=vec.X
45 This.Y=vec.Y
46 End Sub
47 Function Operator + (vec1 As Vector2f, vec2 As Vector2f) As Vector2f
48 Return Add(vec1,vec2)
49 End Function
50 Function Operator - (vec1 As Vector2f, vec2 As Vector2f) As Vector2f
51 Return Substract(vec1,vec2)
52 End Function
53/* Function Operator * (vec1 As Vector2f, vec2 As Vector2f) As Vector2f
54 Return Dot(vec1,vec2)
55 End Function
56*/
57 Function Operator * (vec As Vector2f, sca As GLfloat) As Vector2f
58 Dim ret As Vector2f(vec.X*sca,vec.Y*sca)
59 Return ret
60 End Function
61 Function Operator / (vec As Vector2f, sca As GLfloat) As Vector2f
62 Dim ret As Vector2f(vec.X/sca,vec.Y/sca)
63 Return ret
64 End Function
65
66
67Public /* method */
68 Function Add(vec1 As Vector2f, vec2 As Vector2f) As Vector2f
69 Dim ret As Vector2f(vec1.X+vec2.X,vec1.Y+vec2.Y)
70 Return ret
71 End Function
72 Function Distance(vec1 As Vector2f, vec2 As Vector2f) As GLfloat
73 Dim ret As Vector2f
74 ret=vec1-vec2
75 Return ret.Magnitude
76 End Function
77 Function Dot(vec1 As Vector2f, vec2 As Vector2f) As GLfloat
78 Return vec1.X*vec2.X+vec1.Y*vec2.Y
79 End Function
80 Function Magnitude() As GLfloat
81 Return Math.Sqrt(This.X^2+This.Y^2) As GLfloat
82 End Function
83 Sub Normalize()
84 Dim ret As Vector2f(This.X/This.Magnitude,This.Y/This.Magnitude)
85 This = ret
86 End Sub
87 Function NormalizedVector() As Vector2f
88 Dim ret As Vector2f(This.X/This.Magnitude,This.Y/This.Magnitude)
89 Return ret
90 End Function
91 Function Substract(vec1 As Vector2f, vec2 As Vector2f) As Vector2f
92 Dim ret As Vector2f(vec1.X-vec2.X,vec1.Y-vec2.Y)
93 Return ret
94 End Function
95 Sub Reverse()
96 Dim ret As Vector2f(-This.X,-This.Y)
97 This = ret
98 End Sub
99 Function ReversedVector() As Vector2f
100 Dim ret As Vector2f(-This.X,-This.Y)
101 Return ret
102 End Function
103
104Protected
105 xy As XY_FLOAT
106End Class
107
108Class Vector2d
109Public /* constructor */
110 Sub Vector2d(x As GLdouble, y As GLdouble)
111 xy.x=x
112 xy.y=y
113 End Sub
114
115Public /* destructor */
116 Sub ~Vector2d()
117 End Sub
118
119Public /* property */
120 Function X() As GLdouble
121 Return xy.x
122 End Function
123 Function Y() As GLdouble
124 Return xy.y
125 End Function
126 Sub X(x As GLdouble)
127 xy.x=x
128 End Sub
129 Sub Y(y As GLdouble)
130 xy.y=y
131 End Sub
132
133Public /* operator */
134 Sub Operator = (vec As Vector2d)
135 This.X=vec.X
136 This.Y=vec.Y
137 End Sub
138 Function Operator + (vec1 As Vector2d, vec2 As Vector2d) As Vector2d
139 Return Add(vec1,vec2)
140 End Function
141 Function Operator - (vec1 As Vector2d, vec2 As Vector2d) As Vector2d
142 Return Substract(vec1,vec2)
143 End Function
144/* Function Operator * (vec1 As Vector2d, vec2 As Vector2d) As Vector2d
145 Return Dot(vec1,vec2)
146 End Function*/
147
148 Function Operator * (vec As Vector2d, sca As GLfloat) As Vector2d
149 Dim ret As Vector2d(vec.X*sca,vec.Y*sca)
150 Return ret
151 End Function
152 Function Operator / (vec As Vector2d, sca As GLfloat) As Vector2d
153 Dim ret As Vector2d(vec.X/sca,vec.Y/sca)
154 Return ret
155 End Function
156
157
158Public /* method */
159 Function Add(vec1 As Vector2d, vec2 As Vector2d) As Vector2d
160 Dim ret As Vector2d(vec1.X+vec2.X,vec1.Y+vec2.Y)
161 Return ret
162 End Function
163 Function Distance(vec1 As Vector2d, vec2 As Vector2d) As GLdouble
164 Dim ret As Vector2d
165 ret=vec1-vec2
166 Return ret.Magnitude
167 End Function
168 Function Dot(vec1 As Vector2d, vec2 As Vector2d) As GLdouble
169 Return vec1.X*vec2.X+vec1.Y*vec2.Y
170 End Function
171 Function Magnitude() As GLdouble
172 Return Math.Sqrt(This.X^2+This.Y^2) As GLdouble
173 End Function
174 Sub Normalize()
175 Dim ret As Vector2d(This.X/This.Magnitude,This.Y/This.Magnitude)
176 This = ret
177 End Sub
178 Function NormalizedVector() As Vector2d
179 Dim ret As Vector2d(This.X/This.Magnitude,This.Y/This.Magnitude)
180 Return ret
181 End Function
182 Function Substract(vec1 As Vector2d, vec2 As Vector2d) As Vector2d
183 Dim ret As Vector2d(vec1.X-vec2.X,vec1.Y-vec2.Y)
184 Return ret
185 End Function
186 Sub Reverse()
187 Dim ret As Vector2d(-This.X,-This.Y)
188 This = ret
189 End Sub
190 Function ReversedVector() As Vector2d
191 Dim ret As Vector2d(-This.X,-This.Y)
192 Return ret
193 End Function
194
195Protected
196 xz As XY_DOUBLE
197End Class
198
199
200Type XYZ_FLOAT
201 x As GLfloat
202 y As GLfloat
203 z As GLfloat
204End Type
205
206Type XYZ_DOUBLE
207 x As GLdouble
208 y As GLdouble
209 z As GLdouble
210End Type
211
212Class Vector3f
213Public /* constructor */
214 Sub Vector3f(x As GLfloat, y As GLfloat, z As GLfloat)
215 xyz.x=x
216 xyz.y=y
217 xyz.z=z
218 End Sub
219
220Public /* destructor */
221 Sub ~Vector3f()
222 End Sub
223
224Public /* property */
225 Function X() As GLfloat
226 Return xyz.x
227 End Function
228 Function Y() As GLfloat
229 Return xyz.y
230 End Function
231 Function Z() As GLfloat
232 Return xyz.z
233 End Function
234 Sub X(x As GLfloat)
235 xyz.x=x
236 End Sub
237 Sub Y(y As GLfloat)
238 xyz.y=y
239 End Sub
240 Sub Z(z As GLfloat)
241 xyz.z=z
242 End Sub
243
244Public /* operator */
245 Sub Operator = (vec As Vector3f)
246 This.X=vec.X
247 This.Y=vec.Y
248 End Sub
249 Function Operator + (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
250 Return Add(vec1,vec2)
251 End Function
252 Function Operator - (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
253 Return Substract(vec1,vec2)
254 End Function
255/* Function Operator * (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
256 Return Dot(vec1,vec2)
257 End Function*/
258 Function Operator ^ (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
259 Return Cross(vec1,vec2)
260 End Function
261
262 Function Operator * (vec As Vector3f, sca As GLfloat) As Vector3f
263 Dim ret As Vector3f(vec.X*sca,vec.Y*sca)
264 Return ret
265 End Function
266 Function Operator / (vec As Vector3f, sca As GLfloat) As Vector3f
267 Dim ret As Vector3f(vec.X/sca,vec.Y/sca)
268 Return ret
269 End Function
270
271
272Public /* method */
273 Function Add(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
274 Dim ret As Vector3f(vec1.X+vec2.X,vec1.Y+vec2.Y,vec1.Z-vec2.Z)
275 Return ret
276 End Function
277 Function Cross(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
278 Dim ret As Vector3f(vec1.Y*vec2.Z-vec1.Z*vec2.Y,vec1.Z*vec2.X-vec1.X*vec2.Z,vec1.X*vec2.Y-vec1.Y*vec2.X)
279 Return ret
280 End Function
281 Function Distance(vec1 As Vector3f, vec2 As Vector3f) As GLfloat
282 Dim ret As Vector3f
283 ret=vec1-vec2
284 Return ret.Magnitude
285 End Function
286 Function Dot(vec1 As Vector3f, vec2 As Vector3f) As GLfloat
287 Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z
288 End Function
289 Function Magnitude() As GLfloat
290 Return Math.Sqrt(This.X^2+This.Y^2+This.Z^2) As GLfloat
291 End Function
292 Sub Normalize()
293 Dim ret As Vector3f(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude)
294 This = ret
295 End Sub
296 Function NormalizedVector() As Vector3f
297 Dim ret As Vector3f(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude)
298 Return ret
299 End Function
300 Function Substract(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
301 Dim ret As Vector3f(vec1.X-vec2.X,vec1.Y-vec2.Y,vec1.Z-vec2.Z)
302 Return ret
303 End Function
304 Sub Reverse()
305 Dim ret As Vector3f(-This.X,-This.Y,-This.Z)
306 This = ret
307 End Sub
308 Function ReversedVector() As Vector3f
309 Dim ret As Vector3f(-This.X,-This.Y,-This.Z)
310 Return ret
311 End Function
312
313Protected
314 xyz As XYZ_FLOAT
315End Class
316
317Class Vector3d
318Public /* constructor */
319 Sub Vector3d(x As GLdouble, y As GLdouble, z As GLdouble)
320 xyz.x=x
321 xyz.y=y
322 xyz.z=z
323 End Sub
324
325Public /* destructor */
326 Sub ~Vector3d()
327 End Sub
328
329
330Public /* property */
331 Function X() As GLdouble
332 Return xyz.x
333 End Function
334 Function Y() As GLdouble
335 Return xyz.y
336 End Function
337 Function Z() As GLdouble
338 Return xyz.z
339 End Function
340 Sub X(x As GLdouble)
341 xyz.x=x
342 End Sub
343 Sub Y(y As GLdouble)
344 xyz.y=y
345 End Sub
346 Sub Z(z As GLdouble)
347 xyz.z=z
348 End Sub
349
350
351Public /* operator */
352 Sub Operator = (vec As Vector3d)
353 This.X=vec.X
354 This.Y=vec.Y
355 End Sub
356 Function Operator + (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
357 Return Add(vec1,vec2)
358 End Function
359 Function Operator - (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
360 Return Substract(vec1,vec2)
361 End Function
362/* Function Operator * (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
363 Return Dot(vec1,vec2)
364 End Function*/
365 Function Operator ^ (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
366 Return Cross(vec1,vec2)
367 End Function
368
369 Function Operator * (vec As Vector3d, sca As GLdouble) As Vector3d
370 Dim ret As Vector3d(vec.X*sca,vec.Y*sca)
371 Return ret
372 End Function
373 Function Operator / (vec As Vector3d, sca As GLdouble) As Vector3d
374 Dim ret As Vector3d(vec.X/sca,vec.Y/sca)
375 Return ret
376 End Function
377
378
379Public /* method */
380 Function Add(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
381 Dim ret As Vector3d(vec1.X+vec2.X,vec1.Y+vec2.Y,vec1.Z-vec2.Z)
382 Return ret
383 End Function
384 Function Cross(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
385 Dim ret As Vector3d(vec1.Y*vec2.Z-vec1.Z*vec2.Y,vec1.Z*vec2.X-vec1.X*vec2.Z,vec1.X*vec2.Y-vec1.Y*vec2.X)
386 Return ret
387 End Function
388 Function Distance(vec1 As Vector3d, vec2 As Vector3d) As GLdouble
389 Dim ret As Vector3d
390 ret=vec1-vec2
391 Return ret.Magnitude
392 End Function
393 Function Dot(vec1 As Vector3d, vec2 As Vector3d) As GLdouble
394 Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z
395 End Function
396 Function Magnitude() As GLdouble
397 Return Math.Sqrt(This.X^2+This.Y^2+This.Z^2) As GLdouble
398 End Function
399 Sub Normalize()
400 Dim ret As Vector3d(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude)
401 This = ret
402 End Sub
403 Function NormalizedVector() As Vector3d
404 Dim ret As Vector3d(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude)
405 Return ret
406 End Function
407 Function Substract(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
408 Dim ret As Vector3d(vec1.X-vec2.X,vec1.Y-vec2.Y,vec1.Z-vec2.Z)
409 Return ret
410 End Function
411 Sub Reverse()
412 Dim ret As Vector3d(-This.X,-This.Y,-This.Z)
413 This = ret
414 End Sub
415 Function ReversedVector() As Vector3d
416 Dim ret As Vector3d(-This.X,-This.Y,-This.Z)
417 Return ret
418 End Function
419
420
421Protected
422 xyz As XYZ_DOUBLE
423End Class
424
425
426Type RGB_FLOAT
427 r As GLfloat
428 g As GLfloat
429 b As GLfloat
430End Type
431
432Type RGB_DOUBLE
433 r As GLdouble
434 g As GLdouble
435 b As GLdouble
436End Type
437
438Class Color3f
439Public /* constructor */
440 Sub Color3f(r As GLfloat, g As GLfloat, b As GLfloat)
441 rgb.r = r
442 rgb.g = g
443 rgb.b = b
444 End Sub
445
446Public /* destructor */
447 Sub ~Color3f()
448 End Sub
449
450Public /* property */
451 Function R() As GLfloat
452 Return rgb.r
453 End Function
454 Function G() As GLfloat
455 Return rgb.g
456 End Function
457 Function B() As GLfloat
458 Return rgb.r
459 End Function
460 Sub R(r As GLfloat)
461 rgb.r = r
462 End Sub
463 Sub G(g As GLfloat)
464 rgb.g = g
465 End Sub
466 Sub B(b As GLfloat)
467 rgb.b = b
468 End Sub
469
470Public /* operator */
471
472 ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした
473 ' Drawwing\Color.abをさらに参考にしました。
474 Function GetHue() As GLfloat
475 Dim max As GLfloat, min As GLfloat, d As GLfloat
476 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
477 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
478 d = max - min
479 If rgb.g = max Then
480 Return ((rgb.b - rgb.r) As Double / d * 1.0*_System_PI/3.0 + 2.0*_System_PI/3.0) As GLfloat
481 ElseIf rgb.b = max Then
482 Return ((rgb.r - rgb.g) As Double / d * 1.0*_System_PI/3.0 + 4.0*_System_PI/3.0) As GLfloat
483 ElseIf rgb.g < rgb.b Then
484 Return ((rgb.g - rgb.b) As Double / d * 1.0*_System_PI/3.0 + 6.0*_System_PI/3.0) As GLfloat
485 Else
486 Return ((rgb.g - rgb.b) As Double / d * 1.0*_System_PI/3.0) As GLfloat
487 EndIf
488 End Function
489
490 Function GetSaturation() As GLfloat
491 Dim max As GLfloat, min As GLfloat
492 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
493 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
494 Return (max - min) / max
495 End Function
496
497 Function GetBrightness() As GLfloat
498 Dim max As GLfloat
499 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
500 Return max
501 End Function
502Protected
503 rgb As RGB_FLOAT
504End Class
505
506Class Color3d
507Public /* constructor */
508 Sub Color3d(r As GLdouble, g As GLdouble, b As GLdouble)
509 rgb.r = r
510 rgb.g = g
511 rgb.b = b
512 End Sub
513
514Public /* destructor */
515 Sub ~Color3d()
516 End Sub
517
518Public /* property */
519 Function R() As GLdouble
520 Return rgb.r
521 End Function
522 Function G() As GLdouble
523 Return rgb.g
524 End Function
525 Function B() As GLdouble
526 Return rgb.r
527 End Function
528 Sub R(r As GLdouble)
529 rgb.r = r
530 End Sub
531 Sub G(g As GLdouble)
532 rgb.g = g
533 End Sub
534 Sub B(b As GLdouble)
535 rgb.b = b
536 End Sub
537
538Protected
539 rgb As RGB_DOUBLE
540End Class
541
542Type RGBA_FLOAT
543 r As GLfloat
544 g As GLfloat
545 b As GLfloat
546 a As GLfloat
547End Type
548
549Type RGBA_DOUBLE
550 r As GLdouble
551 g As GLdouble
552 b As GLdouble
553 a As GLdouble
554End Type
555
556Class Color4f
557Public /* constructor */
558 Sub Color4f(r As GLfloat, g As GLfloat, b As GLfloat, a As GLfloat)
559 rgba.r = r
560 rgba.g = g
561 rgba.b = b
562 rgba.a = a
563 End Sub
564
565Public /* destructor */
566 Sub ~Color4f()
567 End Sub
568
569Public /* property */
570 Function R() As GLfloat
571 Return rgba.r
572 End Function
573 Function G() As GLfloat
574 Return rgba.g
575 End Function
576 Function B() As GLfloat
577 Return rgba.r
578 End Function
579 Function A() As GLfloat
580 Return rgba.a
581 End Function
582 Sub R(r As GLfloat)
583 rgba.r = r
584 End Sub
585 Sub G(g As GLfloat)
586 rgba.g = g
587 End Sub
588 Sub B(b As GLfloat)
589 rgba.b = b
590 End Sub
591 Sub A(a As GLfloat)
592 rgba.a = a
593 End Sub
594
595Protected
596 rgba As RGBA_FLOAT
597End Class
598
599Class Color4d
600
601Public /* constructor */
602 Sub Color4d(r As GLdouble, g As GLdouble, b As GLdouble, a As GLdouble)
603 rgba.r = r
604 rgba.g = g
605 rgba.b = b
606 rgba.a = a
607 End Sub
608
609Public /* destructor */
610 Sub ~Color4d()
611 End Sub
612
613Public /* property */
614 Function R() As GLdouble
615 Return rgba.r
616 End Function
617 Function G() As GLdouble
618 Return rgba.g
619 End Function
620 Function B() As GLdouble
621 Return rgba.r
622 End Function
623 Function A() As GLdouble
624 Return rgba.a
625 End Function
626 Sub R(r As GLdouble)
627 rgba.r = r
628 End Sub
629 Sub G(g As GLdouble)
630 rgba.g = g
631 End Sub
632 Sub B(b As GLdouble)
633 rgba.b = b
634 End Sub
635 Sub A(a As GLdouble)
636 rgba.a = a
637 End Sub
638
639Protected
640 rgba As RGBA_DOUBLE
641End Class
642
643
644
645Class Light
646Private
647 Number As GLenum
648
649Public
650 Sub Enabled(enabled As GLboolean)
651 Dim lighting As GLboolean
652 glGetBooleanv(Number,VarPtr(lighting))
653 Return lighting
654 End Sub
655 Function Enable() As GLboolean
656 If enabled Then
657 glEnable(Number)
658 Else
659 glDisable(Number)
660 End If
661 End Function
662
663Public /* constructor */
664 Sub Light(num As GLenum)
665 Number=num
666 End Sub
667
668Public
669 Sub SetAmbient(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
670 Dim amb[3] As GLfloat
671 amb[0]=red
672 amb[1]=green
673 amb[2]=blue
674 amb[3]=alpha
675 glLightfv(Number,GL_AMBIENT,amb)
676 End Sub
677 Sub SetAmbient(color As Color4f)
678 Dim amb[3] As GLfloat
679 amb[0]=color.R
680 amb[1]=color.G
681 amb[2]=color.B
682 amb[3]=color.A
683 glLightfv(Number,GL_AMBIENT,amb)
684 End Sub
685 Sub SetAmbient(amb As *GLfloat)
686 glLightfv(Number,GL_AMBIENT,amb)
687 End Sub
688
689 Sub SetDiffuse(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
690 Dim dif[3] As GLfloat
691 dif[0]=red
692 dif[1]=green
693 dif[2]=blue
694 dif[3]=alpha
695 glLightfv(Number,GL_DIFFUSE,dif)
696 End Sub
697 Sub SetDiffuse(color As Color4f)
698 Dim dif[3] As GLfloat
699 amb[0]=color.R
700 amb[1]=color.G
701 amb[2]=color.B
702 amb[3]=color.A
703 glLightfv(Number,GL_DIFFUSE,dif)
704 End Sub
705 Sub SetDiffuse(dif As *GLfloat)
706 glLightfv(Number,GL_DIFFUSE,dif)
707 End Sub
708
709 Sub SetSpecular(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
710 Dim spc[3] As GLfloat
711 spc[0]=red
712 spc[1]=green
713 spc[2]=blue
714 spc[3]=alpha
715 glLightfv(Number,GL_SPECULAR,spc)
716 End Sub
717 Sub SetSpecular(color As Color4f)
718 Dim spc[3] As GLfloat
719 amb[0]=color.R
720 amb[1]=color.G
721 amb[2]=color.B
722 amb[3]=color.A
723 glLightfv(Number,GL_SPECULAR,spc)
724 End Sub
725 Sub SetSpecular(spc As *GLfloat)
726 glLightfv(Number,GL_SPECULAR,spc)
727 End Sub
728
729 Sub SetPosition(pos As *GLfloat)
730 glLightfv(Number,GL_POSITION,pos)
731 End Sub
732End Class
733
734Class Material
735Public
736 Sub Ambient(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
737 Dim face As GLenum
738 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
739 Dim amb[3] As GLfloat
740 amb[0]=red
741 amb[1]=green
742 amb[2]=blue
743 amb[3]=alpha
744 glMaterialfv(face,GL_AMBIENT,amb)
745 End Sub
746 Sub Ambient(color As Color4f)
747 Dim face As GLenum
748 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
749 Dim amb[3] As GLfloat
750 amb[0]=color.R
751 amb[1]=color.G
752 amb[2]=color.B
753 amb[3]=color.A
754 glMaterialfv(face,GL_AMBIENT,amb)
755 End Sub
756 Sub Ambient(amb As *GLfloat)
757 glMaterialfv(face,GL_AMBIENT,amb)
758 End Sub
759
760 Sub Diffuse(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
761 Dim face As GLenum
762 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
763 Dim dif[3] As GLfloat
764 dif[0]=red
765 dif[1]=green
766 dif[2]=blue
767 dif[3]=alpha
768 glMaterialfv(face,GL_DIFFUSE,dif)
769 End Sub
770 Sub Diffuse(color As Color4f)
771 Dim face As GLenum
772 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
773 Dim dif[3] As GLfloat
774 dif[0]=color.R
775 dif[1]=color.G
776 dif[2]=color.B
777 dif[3]=color.A
778 glMaterialfv(face,GL_DIFFUSE,dif)
779 End Sub
780 Sub Diffuse(dif As *GLfloat)
781 glMaterialfv(face,GL_DIFFUSE,dif)
782 End Sub
783
784 Sub Specular(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
785 Dim face As GLenum
786 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
787 Dim spc[3] As GLfloat
788 spc[0]=red
789 spc[1]=green
790 spc[2]=blue
791 spc[3]=alpha
792 glMaterialfv(face,GL_SPECULAR,spc)
793 End Sub
794 Sub Specular(color As Color4f)
795 Dim face As GLenum
796 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
797 Dim spc[3] As GLfloat
798 spc[0]=color.R
799 spc[1]=color.G
800 spc[2]=color.B
801 spc[3]=color.A
802 glMaterialfv(face,GL_SPECULAR,spc)
803 End Sub
804 Sub Specular(spc As *GLfloat)
805 glMaterialfv(face,GL_SPECULAR,spc)
806 End Sub
807
808 Sub Shininess(shin As GLfloat)
809 Dim face As GLenum
810 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
811 glMaterialf(face,GL_SHININESS,shin)
812 End Sub
813
814 Sub Emission(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
815 Dim face As GLenum
816 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
817 Dim ems[3] As GLfloat
818 ems[0]=red
819 ems[1]=green
820 ems[2]=blue
821 ems[3]=alpha
822 glMaterialfv(face,GL_EMISSION,ems)
823 End Sub
824End Class
825
826Class ModelView
827Public
828 Sub LoadIdentity()
829 Dim mode As GLenum
830 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
831 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
832 glLoadIdentity()
833 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
834 End Sub
835 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)
836 Dim mode As GLenum
837 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
838 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
839 gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz)
840 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
841 End Sub
842 Sub RotateX(angle As GLdouble)
843 Dim mode As GLenum
844 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
845 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
846 glRotated(angle, 1.0 As GLdouble, 0.0 As GLdouble, 0.0 As GLdouble)
847 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
848 End Sub
849 Sub RotateX(angle As GLfloat)
850 Dim mode As GLenum
851 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
852 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
853 glRotatef(angle, 1.0 As GLfloat, 0.0 As GLfloat, 0.0 As GLfloat)
854 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
855 End Sub
856 Sub RotateY(angle As GLdouble)
857 Dim mode As GLenum
858 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
859 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
860 glRotated(angle, 0.0 As GLdouble, 1.0 As GLdouble, 0.0 As GLdouble)
861 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
862 End Sub
863 Sub RotateY(angle As GLfloat)
864 Dim mode As GLenum
865 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
866 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
867 glRotatef(angle, 0.0 As GLfloat, 1.0 As GLfloat, 0.0 As GLfloat)
868 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
869 End Sub
870 Sub RotateZ(angle As GLdouble)
871 Dim mode As GLenum
872 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
873 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
874 glRotated(angle, 0.0 As GLdouble, 0.0 As GLdouble, 1.0 As GLdouble)
875 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
876 End Sub
877 Sub RotateZ(angle As GLfloat)
878 Dim mode As GLenum
879 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
880 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
881 glRotatef(angle, 0.0 As GLfloat, 0.0 As GLfloat, 1.0 As GLfloat)
882 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
883 End Sub
884 Sub Scale(x As GLdouble, y As GLdouble, z As GLdouble)
885 Dim mode As GLenum
886 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
887 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
888 glScaled(x, y, z)
889 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
890 End Sub
891 Sub Scale(x As GLfloat, y As GLfloat, z As GLfloat)
892 Dim mode As GLenum
893 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
894 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
895 glScalef(x, y, z)
896 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
897 End Sub
898 Sub Translate(x As GLdouble, y As GLdouble, z As GLdouble)
899 Dim mode As GLenum
900 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
901 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
902 glTranslated(x, y, z)
903 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
904 End Sub
905 Sub Translate(x As GLfloat, y As GLfloat, z As GLfloat)
906 Dim mode As GLenum
907 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
908 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
909 glTranslatef(x, y, z)
910 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
911 End Sub
912End Class
913
914Class Projection
915Public
916 Sub LoadIdentity()
917 Dim mode As GLenum
918 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
919 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
920 glLoadIdentity()
921 If mode<>GL_PROJECTION Then glMatrixMode(mode)
922 End Sub
923 Sub Ortho2D(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble)
924 Dim mode As GLenum
925 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
926 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
927 gluOrtho2D(left, right, bottom, top)
928 If mode<>GL_PROJECTION Then glMatrixMode(mode)
929 End Sub
930 Sub Ortho3D(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble, zNear As GLdouble, zFar As GLdouble)
931 Dim mode As GLenum
932 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
933 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
934 glOrtho(left, right, bottom, top, zNear, zFar)
935 If mode<>GL_PROJECTION Then glMatrixMode(mode)
936 End Sub
937 Sub Frustum(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble, zNear As GLdouble, zFar As GLdouble)
938 Dim mode As GLenum
939 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
940 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
941 glFrustum(left, right, bottom, top, zNear, zFar)
942 If mode<>GL_PROJECTION Then glMatrixMode(mode)
943 End Sub
944 Sub Perspective(fovy As GLdouble, aspect As GLdouble, zNear As GLdouble, zFar As GLdouble)
945 Dim mode As GLenum
946 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
947 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
948 gluPerspective(fovy, aspect, zNear, zFar)
949 If mode<>GL_PROJECTION Then glMatrixMode(mode)
950 End Sub
951End Class
952
953Class Transform
954Public
955 Projection As Projection
956 ModelView As ModelView
957End Class
958
959Class LightModel
960Public
961/* Function Ambient () As GLenum
962 Dim amb As GLenum
963 glGetFloatv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb))
964 Return func
965 End Function*/
966 Sub Ambient(amb As *GLfloat)
967 glLightModelfv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb))
968 End Sub
969
970 Function LocalView() As GLboolean
971 Dim local As GLboolean
972 glGetBooleanv(GL_LIGHT_MODEL_LOCAL_VIEW,VarPtr(local))
973 Return local
974 End Function
975 Sub LocalView(enable As GLboolean)
976 If enable Then
977 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEW,GL_TRUE)
978 Else
979 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEW,GL_FALSE)
980 End If
981 End Sub
982
983 Function TwoSide() As GLboolean
984 Dim local As GLboolean
985 glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE,VarPtr(local))
986 Return local
987 End Function
988 Sub TwoSide(enable As GLboolean)
989 If enable Then
990 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE)
991 Else
992 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE)
993 End If
994 End Sub
995End Class
996
997Class RenderState
998Public /* Composiotion */
999 LightModel As LightModel
1000
1001Public
1002 Function AlphaTestEnable() As GLboolean
1003 Dim alpha As GLboolean
1004 glGetBooleanv(GL_ALPHA_TEST,VarPtr(alpha))
1005 Return alpha
1006 End Function
1007 Sub AlphaTestEnable(enable As GLboolean)
1008 If enable Then
1009 glEnable(GL_ALPHA_TEST)
1010 Else
1011 glDisable(GL_ALPHA_TEST)
1012 End If
1013 End Sub
1014
1015 Function AlphaFunction() As GLenum
1016 Dim func As GLenum
1017 glGetIntegerv(GL_ALPHA_TEST_FUNC,VarPtr(func))
1018 Return func
1019 End Function
1020 Sub AlphaFunction(func As GLenum)
1021 Dim ref As GLclampf
1022 glGetFloatv(GL_ALPHA_TEST_REF,VarPtr(ref))
1023 glAlphaFunc(func,ref)
1024 End Sub
1025
1026 Function BlendEnable() As GLboolean
1027 Dim blend As GLboolean
1028 glGetBooleanv(GL_BLEND,VarPtr(blend))
1029 Return blend
1030 End Function
1031 Sub BlendEnable(enable As GLboolean)
1032 If enable Then
1033 glEnable(GL_BLEND)
1034 Else
1035 glDisable(GL_BLEND)
1036 End If
1037 End Sub
1038
1039 Function BlendDestinationFactor() As GLenum
1040 Dim dfactor As GLenum
1041 glGetIntegerv(GL_BLEND_DST,VarPtr(dfactor))
1042 Return dfactor
1043 End Function
1044 Sub BlendDestinationFactor(dfactor As GLenum)
1045 Dim sfactor As GLenum
1046 glGetIntegerv(GL_BLEND_SRC,VarPtr(sfactor))
1047 glBlendFunc(sfactor,dfactor)
1048 End Sub
1049
1050 Function BlendSourceFactor() As GLenum
1051 Dim sfactor As GLenum
1052 glGetIntegerv(GL_BLEND_SRC,VarPtr(sfactor))
1053 Return sfactor
1054 End Function
1055 Sub BlendSourceFactor(sfactor As GLenum)
1056 Dim dfactor As GLenum
1057 glGetIntegerv(GL_BLEND_DST,VarPtr(dfactor))
1058 glBlendFunc(sfactor,dfactor)
1059 End Sub
1060
1061 Function CullFaceEnable() As GLboolean
1062 Dim cull As GLboolean
1063 glGetBooleanv(GL_CULL_FACE,VarPtr(cull))
1064 Return cull
1065 End Function
1066 Sub CullFaceEnable(enable As GLboolean)
1067 If enable Then
1068 glEnable(GL_CULL_FACE)
1069 Else
1070 glDisable(GL_CULL_FACE)
1071 End If
1072 End Sub
1073
1074 Function CullFaceMode () As GLenum
1075 Dim mode As GLenum
1076 glGetIntegerv(GL_CULL_FACE_MODE,VarPtr(mode))
1077 Return mode
1078 End Function
1079 Sub CullFaceMode(mode As GLenum)
1080 glCullFace(mode)
1081 End Sub
1082
1083 Function DepthTestEnable () As GLboolean
1084 Dim depth As GLboolean
1085 glGetBooleanv(GL_DEPTH_TEST,VarPtr(depth))
1086 Return depth
1087 End Function
1088 Sub DepthTestEnable(enable As GLboolean)
1089 If enable Then
1090 glEnable(GL_DEPTH_TEST)
1091 Else
1092 glDisable(GL_DEPTH_TEST)
1093 End If
1094 End Sub
1095
1096 Function DepthFunction () As GLenum
1097 Dim func As GLenum
1098 glGetIntegerv(GL_DEPTH_FUNC,VarPtr(func))
1099 Return func
1100 End Function
1101 Sub DepthFunction(func As GLenum)
1102 glDepthFunc(func)
1103 End Sub
1104
1105 Function DepthBufferWritable() As GLboolean
1106 Dim writable As GLboolean
1107 glGetBooleanv(GL_DEPTH_WRITEMASK,VarPtr(writable))
1108 Return writable
1109 End Function
1110 Sub DepthBufferWritable(enable As GLboolean)
1111 If enable Then
1112 glDepthMask(GL_DEPTH_WRITEMASK)
1113 Else
1114 glDepthMask(GL_DEPTH_WRITEMASK)
1115 End If
1116 End Sub
1117
1118 Function DitherEnable() As GLboolean
1119 Dim dither As GLboolean
1120 glGetBooleanv(GL_DITHER,VarPtr(dither))
1121 Return dither
1122 End Function
1123 Sub DitherEnable(enable As GLboolean)
1124 If enable Then
1125 glEnable(GL_DITHER)
1126 Else
1127 glDisable(GL_DITHER)
1128 End If
1129 End Sub
1130
1131 Function FogEnable () As GLboolean
1132 Dim fog As GLboolean
1133 glGetBooleanv(GL_FOG,VarPtr(fog))
1134 Return fog
1135 End Function
1136 Sub FogEnable(enable As GLboolean)
1137 If enable Then
1138 glEnable(GL_FOG)
1139 Else
1140 glDisable(GL_FOG)
1141 End If
1142 End Sub
1143
1144 Function FogMode() As GLenum
1145 Dim mode As GLenum
1146 glGetIntegerv(GL_FOG_MODE,VarPtr(mode))
1147 Return mode
1148 End Function
1149 Sub FogMode(mode As GLenum)
1150 glFogi(GL_FOG_MODE,mode)
1151 End Sub
1152
1153 Function FogColor() As *GLfloat
1154 glGetFloatv(GL_FOG_COLOR,FogColor)
1155 Return FogColor
1156 End Function
1157 Sub FogColor(fcolor As *GLfloat)
1158 glFogfv(GL_FOG_COLOR,fcolor)
1159 End Sub
1160
1161 Function FogDensity() As GLfloat
1162 Dim density As GLfloat
1163 glGetFloatv(GL_FOG_DENSITY,density)
1164 Return density
1165 End Function
1166 Sub FogDensity(density As GLfloat)
1167 glFogf(GL_FOG_DENSITY,density)
1168 End Sub
1169
1170 Function FogStart() As GLfloat
1171 Dim fstrat As GLfloat
1172 glGetFloatv(GL_FOG_START,fstrat)
1173 Return fstrat
1174 End Function
1175 Sub FogStart(fstrat As GLfloat)
1176 glFogf(GL_FOG_START,fstrat)
1177 End Sub
1178
1179 Function FogEnd() As GLfloat
1180 Dim fend As GLfloat
1181 glGetFloatv(GL_FOG_END,fend)
1182 Return fend
1183 End Function
1184 Sub FogEnd(fend As GLfloat)
1185 glFogf(GL_FOG_END,fend)
1186 End Sub
1187
1188 Function Lighting() As GLboolean
1189 Dim lighting As GLboolean
1190 glGetBooleanv(GL_LIGHTING,VarPtr(lighting))
1191 Return lighting
1192 End Function
1193 Sub Lighting(enable As GLboolean)
1194 If enable Then
1195 glEnable(GL_LIGHTING)
1196 Else
1197 glDisable(GL_LIGHTING)
1198 End If
1199 End Sub
1200
1201 Function LineSmoothEnable() As GLboolean
1202 Dim smooth As GLboolean
1203 glGetBooleanv(GL_LINE_SMOOTH,VarPtr(smooth))
1204 Return smooth
1205 End Function
1206 Sub LineSmoothEnable(enable As GLboolean)
1207 If enable Then
1208 glEnable(GL_LINE_SMOOTH)
1209 Else
1210 glDisable(GL_LINE_SMOOTH)
1211 End If
1212 End Sub
1213
1214 Function LogicOpEnable() As GLboolean
1215 Dim logic As GLboolean
1216 glGetBooleanv(GL_COLOR_LOGIC_OP,VarPtr(logic))
1217 Return logic
1218 End Function
1219 Sub LogicOpEnable(enable As GLboolean)
1220 If enable Then
1221 glEnable(GL_COLOR_LOGIC_OP)
1222 Else
1223 glDisable(GL_COLOR_LOGIC_OP)
1224 End If
1225 End Sub
1226
1227 Function LogicOpCode() As GLenum
1228 Dim code As GLenum
1229 glGetFloatv(GL_COLOR_LOGIC_OP_MODE,code)
1230 Return code
1231 End Function
1232 Sub LogicOpCode(code As GLenum)
1233 glLogicOp(code)
1234 End Sub
1235
1236 Function PointSmoothEnable() As GLboolean
1237 Dim smooth As GLboolean
1238 glGetBooleanv(GL_POINT_SMOOTH,VarPtr(smooth))
1239 Return smooth
1240 End Function
1241 Sub PointSmoothEnable(enable As GLboolean)
1242 If enable Then
1243 glEnable(GL_POINT_SMOOTH)
1244 Else
1245 glDisable(GL_POINT_SMOOTH)
1246 End If
1247 End Sub
1248
1249 Function PolygonSmoothEnable() As GLboolean
1250 Dim smooth As GLboolean
1251 glGetBooleanv(GL_POLYGON_SMOOTH,VarPtr(smooth))
1252 Return smooth
1253 End Function
1254 Sub PolygonSmoothEnable(enable As GLboolean)
1255 If enable Then
1256 glEnable(GL_POLYGON_SMOOTH)
1257 Else
1258 glDisable(GL_POLYGON_SMOOTH)
1259 End If
1260 End Sub
1261
1262 Function ReferenceAlpha() As GLclampf
1263 Dim ref As GLclampf
1264 glGetFloatv(GL_ALPHA_TEST_REF,VarPtr(ref))
1265 Return ref
1266 End Function
1267 Sub ReferenceAlpha(ref As GLclampf)
1268 Dim func As GLenum
1269 glGetIntegerv(GL_ALPHA_TEST_FUNC,VarPtr(func))
1270 glAlphaFunc(func,ref)
1271 End Sub
1272
1273 Function ShadeModel() As GLenum
1274 Dim mode As GLenum
1275 glGetIntegerv(GL_SHADE_MODEL,VarPtr(mode))
1276 Return mode
1277 End Function
1278 Sub ShadeModel(mode As GLenum)
1279 glShadeModel(mode)
1280 End Sub
1281End Class
1282
1283
1284Enum ColorType
1285 RgbColor=0
1286 RgbaColor=0
1287 IndexColor
1288End Enum
1289
1290Enum BufferType
1291 SingleBuffer=0
1292 DoubleBuffer
1293End Enum
1294
1295Enum ClearBuffer
1296 DepthBufferBit = &H00000100
1297 AccumBufferBit = &H00000200
1298 StencilBufferBit = &H00000400
1299 ColorBufferBit = &H00004000
1300End Enum
1301
1302Enum PrimitiveMode
1303 Points = &H0000
1304 Lines = &H0001
1305 LineLoop = &H0002
1306 LineStrip = &H0003
1307 Triangles = &H0004
1308 TriangleStrip = &H0005
1309 TriangleFan = &H0006
1310 Quads = &H0007
1311 QuadStrip = &H0008
1312 Polygon = &H0009
1313End Enum
1314
1315Class RenderingContext
1316Public /* Composiotion */
1317 Material As Material
1318 RenderState As RenderState
1319 Transform As Transform
1320 Lights[ELM(8)] As Light
1321
1322Public /* Constructor */
1323 Sub RenderingContext()
1324 Dim hrc As HGLRC
1325 hrc=wglGetCurrentContext()
1326 If hrc Then
1327 wglMakeCurrent(NULL,NULL)
1328 wglDeleteContext(hrc)
1329 End If
1330
1331 Lights[0].Light(GL_LIGHT0)
1332 Lights[1].Light(GL_LIGHT1)
1333 Lights[2].Light(GL_LIGHT2)
1334 Lights[3].Light(GL_LIGHT3)
1335 Lights[4].Light(GL_LIGHT4)
1336 Lights[5].Light(GL_LIGHT5)
1337 Lights[6].Light(GL_LIGHT6)
1338 Lights[7].Light(GL_LIGHT7)
1339 End Sub
1340 Sub RenderingContext(hdc As HDC, ByRef pfd As PIXELFORMATDESCRIPTOR)
1341 RenderingContext()
1342
1343 Dim pf As Long
1344 pf=ChoosePixelFormat(hdc,pfd)
1345 If pf=0 Then
1346 MessageBox(NULL,"Choose Pixel Format failed","error",MB_OK)
1347 Exit Sub
1348 End If
1349 If SetPixelFormat(hdc,pf,pfd)=FALSE Then
1350 MessageBox(NULL,"Set Pixel Format failed","error",MB_OK)
1351 Exit Sub
1352 End If
1353
1354 Dim hrc As HGLRC
1355 hrc=wglCreateContext(hdc)
1356 wglMakeCurrent(hdc,hrc)
1357 End Sub
1358 Sub RenderingContext(hdc As HDC, ByRef ctype As ColorType, ByRef btype As BufferType)
1359 RenderingContext()
1360
1361 Dim pfd As PIXELFORMATDESCRIPTOR
1362 pfd.nSize=SizeOf(PIXELFORMATDESCRIPTOR) As Word
1363 pfd.nVersion=GL_VERSION_1_1
1364 If btype=BufferType.DoubleBuffer As Long Then
1365 pfd.dwFlags or=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
1366 Else
1367 pfd.dwFlags or=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL
1368 End If
1369 If ctype=ColorType.RgbColor As Long Then
1370 pfd.iPixelType=PFD_TYPE_RGBA
1371 Else
1372 pfd.iPixelType=PFD_TYPE_COLORINDEX
1373 End If
1374 pfd.cColorBits=24
1375 pfd.cRedBits=0
1376 pfd.cRedShift=0
1377 pfd.cGreenBits=0
1378 pfd.cGreenShift=0
1379 pfd.cBlueBits=0
1380 pfd.cBlueShift=0
1381 pfd.cAlphaBits=0
1382 pfd.cAlphaShift=0
1383 pfd.cAccumBits=0
1384 pfd.cAccumRedBits=0
1385 pfd.cAccumGreenBits=0
1386 pfd.cAccumBlueBits=0
1387 pfd.cAccumAlphaBits=0
1388 pfd.cDepthBits=32
1389 pfd.cStencilBits=0
1390 pfd.cAuxBuffers=0
1391 pfd.iLayerType=PFD_MAIN_PLANE
1392 pfd.bReserved=0
1393 pfd.dwLayerMask=0
1394 pfd.dwVisibleMask=0
1395 pfd.dwDamageMask=0
1396 RenderingContext(hdc,pfd)
1397 End Sub
1398 Sub RenderingContext(hdc As HDC)
1399 RenderingContext(hdc As HDC, ColorType.RgbColor, BufferType.DoubleBuffer)
1400 End Sub
1401
1402Public /* Destructor */
1403 Sub ~RenderingContext()
1404 Dim hrc As HGLRC
1405 hrc=wglGetCurrentContext()
1406 wglMakeCurrent(NULL,NULL)
1407 wglDeleteContext(hrc)
1408 End Sub
1409
1410Public /* Method */
1411 Sub Begin(mode As GLenum)
1412 glBegin(mode)
1413 End Sub
1414 Sub Begin(mode As PrimitiveMode)
1415 glBegin(mode)
1416 End Sub
1417 Sub Clear(mask As GLbitfield)
1418 glClear(mask)
1419 End Sub
1420 Sub Clear(mask As ClearBuffer)
1421 glClear(mask)
1422 End Sub
1423
1424 Sub ClearAccum(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1425 glClearAccum(red, green, blue, alpha)
1426 End Sub
1427 Sub ClearAccum(color As Color4f)
1428 glClearAccum(color.R, color.G, color.B, color.A)
1429 End Sub
1430 Sub ClearColor(red As GLclampf, green As GLclampf, blue As GLclampf, alpha As GLclampf)
1431 glClearColor(red, green, blue, alpha)
1432 End Sub
1433 Sub ClearColor(color As Color4f)
1434 glClearColor(color.R, color.G, color.B, color.A)
1435 End Sub
1436 Sub ClearDepth(depth As GLclampd)
1437 glClearDepth(depth)
1438 End Sub
1439 Sub ClearIndex(c As GLfloat)
1440 glClearIndex(c)
1441 End Sub
1442 Sub ClearStencil(s As GLint)
1443 glClearStencil(s)
1444 End Sub
1445
1446 Sub Color(red As GLdouble, green As GLdouble, blue As GLdouble)
1447 glColor3d(red,green,blue)
1448 End Sub
1449 Sub Color(red As GLdouble, green As GLdouble, blue As GLdouble, alpha As GLdouble)
1450 glColor4d(red,green,blue,alpha)
1451 End Sub
1452
1453 Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat)
1454 glColor3f(red,green,blue)
1455 End Sub
1456 Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1457 glColor4f(red,green,blue,alpha)
1458 End Sub
1459
1460 Sub DrawPrimiteve()
1461 End Sub
1462
1463 Sub End()
1464 glEnd()
1465 End Sub
1466
1467 Sub Finish()
1468 glFinish()
1469 End Sub
1470 Sub Flush()
1471 glFlush()
1472 End Sub
1473
1474 Function GenerateTexures() As GLint
1475 glGenTextures()
1476 End Function
1477
1478 Sub MatrixMode(mode As GLenum)
1479 glMatrixMode(mode)
1480 End Sub
1481
1482 Sub Present()
1483 SwapBuffers(wglGetCurrentDC())
1484 End Sub
1485 Sub Present(hdc As HDC)
1486 SwapBuffers(hdc)
1487 End Sub
1488
1489 Sub PopMatrix()
1490 glPopMatrix()
1491 End Sub
1492
1493 Sub PushMatrix()
1494 glPushMatrix()
1495 End Sub
1496
1497 Sub Vertex(x As GLdouble, y As GLdouble)
1498 glVertex2d(x,y)
1499 End Sub
1500 Sub Vertex(x As GLdouble, y As GLdouble, z As GLdouble)
1501 glVertex3d(x,y,z)
1502 End Sub
1503 Sub Vertex(x As GLdouble, y As GLdouble, z As GLdouble, w As GLdouble)
1504 glVertex4d(x,y,z,w)
1505 End Sub
1506 Sub Vertex(x As GLfloat, y As GLfloat)
1507 glVertex2f(x,y)
1508 End Sub
1509 Sub Vertex(x As GLfloat, y As GLfloat, z As GLfloat)
1510 glVertex3f(x,y,z)
1511 End Sub
1512 Sub Vertex(x As GLfloat, y As GLfloat, z As GLfloat, w As GLfloat)
1513 glVertex4f(x,y,z,w)
1514 End Sub
1515
1516 Sub Viewport(x As GLint, y As GLint, width As GLsizei, height As GLsizei)
1517 glViewport(x, y, width, height)
1518 End Sub
1519End Class
1520
1521
1522
1523#endif
Note: See TracBrowser for help on using the repository browser.