source: trunk/Include/abgl.ab@ 435

Last change on this file since 435 was 300, checked in by dai, 17 years ago

trunkディレクトリを作成。bin、Include、TestCaseをtrunkに移動した。
標準ライブラリのビルドバッチを追加。

File size: 52.4 KB
Line 
1#ifndef _INC_ABGL
2#define _INC_ABGL
3
4#require <GL/gl.sbp>
5#require <GL/glu.sbp>
6
7Enum VertexFormatsf
8 PositionOnly
9 PositionColoered
10End Enum
11
12Enum VertexFormatsd
13 PositionOnly
14 PositionColoered
15End Enum
16
17NameSpace CustomVertexf
18 Type PositionOnly
19 x As GLfloat
20 y As GLfloat
21 z As GLfloat
22 Public
23 End Type
24
25 Type PositionColoered
26 Public
27 x As GLfloat
28 y As GLfloat
29 z As GLfloat
30 r As GLfloat
31 g As GLfloat
32 b As GLfloat
33 a As GLfloat
34 End Type
35End NameSpace
36
37NameSpace CustomVertexd
38 Type PositionOnly
39 Public
40 x As GLdouble
41 y As GLdouble
42 z As GLdouble
43 End Type
44
45 Type PositionColoered
46 Public
47 x As GLdouble
48 y As GLdouble
49 z As GLdouble
50 r As GLdouble
51 g As GLdouble
52 b As GLdouble
53 a As GLdouble
54 End Type
55End NameSpace
56
57Class VertexBuffer
58Public
59 Sub VertexBuffer()
60 End Sub
61 Sub ~VertexBuffer()
62 End Sub
63
64Public
65 Function Size() As GLuint
66 Return 0
67 End Function
68 Function Lock() As VoidPtr
69 Return NULL
70 End Function
71 Sub Unlock()
72 End Sub
73End Class
74
75Type XY_FLOAT
76 x As GLfloat
77 y As GLfloat
78End Type
79
80Type XY_DOUBLE
81 x As GLdouble
82 y As GLdouble
83End Type
84
85Class Vector2f
86Public /* constructor */
87 Sub Vector2f()
88 This.X=0.0 As GLfloat
89 This.Y=0.0 As GLfloat
90 End Sub
91 Sub Vector2f(x As GLfloat, y As GLfloat)
92 This.X=x
93 This.Y=y
94 End Sub
95 Sub Vector2f(Vec As Vector2d)
96 This.X=Vec.X As GLfloat
97 This.Y=Vec.Y As GLfloat
98 End Sub
99
100Public /* destructor */
101 Sub ~Vector2f()
102 End Sub
103
104Public /* property */
105 Function X() As GLfloat
106 Return xy.x
107 End Function
108 Function Y() As GLfloat
109 Return xy.y
110 End Function
111 Sub X(x As GLfloat)
112 xy.x=x
113 End Sub
114 Sub Y(y As GLfloat)
115 xy.y=y
116 End Sub
117
118Public /* operator */
119 Sub Operator = (ByRef SrcVec As Vector2f)
120 This.X=SrcVec.X
121 This.Y=SrcVec.Y
122 End Sub
123 Function Operator + (SrcVec As Vector2f) As Vector2f
124 Return Add(This,SrcVec)
125 End Function
126 Function Operator - (SrcVec As Vector2f) As Vector2f
127 Return Substract(This,SrcVec)
128 End Function
129/* Function Operator * (SrcVec As Vector2f) As GLfloat
130 Return Dot(This,SrcVec)
131 End Function*/
132 Function Operator * (Src As GLint) As Vector2f
133 Dim ret As Vector2f(This.X*Src,This.Y*Src)
134 Return ret
135 End Function
136 Function Operator * (Src As GLfloat) As Vector2f
137 Dim ret As Vector2f(This.X*Src,This.Y*Src)
138 Return ret
139 End Function
140 Function Operator * (Src As GLdouble) As Vector2f
141 Dim ret As Vector2f(This.X*Src As GLfloat,This.Y*Src As GLfloat)
142 Return ret
143 End Function
144 Function Operator / (Src As GLint) As Vector2f
145 Dim ret As Vector2f(This.X/Src,This.Y/Src)
146 Return ret
147 End Function
148 Function Operator / (Src As GLfloat) As Vector2f
149 Dim ret As Vector2f(This.X/Src,This.Y/Src)
150 Return ret
151 End Function
152 Function Operator / (Src As GLdouble) As Vector2f
153 Dim ret As Vector2f(This.X/Src,This.Y/Src)
154 Return ret
155 End Function
156
157 Function Operator == (Vec As Vector2f) As Boolean
158 If This.X=Vec.X and This.Y=Vec.Y Then
159 Return True
160 Else
161 Return False
162 End If
163 End Function
164
165Public /* method */
166 Function Add(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As Vector2f
167 Dim ret As Vector2f(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y)
168 Return ret
169 End Function
170 Function Distance(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As GLfloat
171 Dim ret As Vector2f
172 ret=SrcVec1-SrcVec2
173 Return ret.Magnitude
174 End Function
175 Function Dot(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As GLfloat
176 Return (SrcVec1.X*SrcVec2.X)+(SrcVec1.Y*SrcVec2.Y)
177 End Function
178 Function Empty() As Vector2f
179 Return New Vector2f()
180 End Function
181 Function Magnitude() As GLfloat
182 Return Math.Sqrt(This.X^2+This.Y^2) As GLfloat
183 End Function
184 Sub Normalize()
185 Dim ret As Vector2f(This.X/This.Magnitude,This.Y/This.Magnitude)
186 This = ret
187 End Sub
188 Function NormalizedVector() As Vector2f
189 Dim ret As Vector2f(This.X/This.Magnitude,This.Y/This.Magnitude)
190 Return ret
191 End Function
192 Function Substract(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As Vector2f
193 Dim ret As Vector2f(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y)
194 Return ret
195 End Function
196 Sub Reverse()
197 Dim ret As Vector2f(-This.X,-This.Y)
198 This = ret
199 End Sub
200 Function ReversedVector() As Vector2f
201 Dim ret As Vector2f(-This.X,-This.Y)
202 Return ret
203 End Function
204
205Public /* Object Class Override */
206 Override Function Equals( object As Object ) As Boolean
207 If This.GetHashCode() = object.GetHashCode() Then
208 Return True
209 Else
210 Return False
211 End If
212 End Function
213 Override Function ToString() As String
214 Return GetType().Name
215 End Function
216
217Protected /* Data */
218 xy As XY_FLOAT
219End Class
220
221Class Vector2d
222Public /* constructor */
223 Sub Vector2d()
224 This.X=0.0 As GLdouble
225 This.Y=0.0 As GLdouble
226 End Sub
227 Sub Vector2d(x As GLdouble, y As GLdouble)
228 xy.x=x
229 xy.y=y
230 End Sub
231 Sub Vector2d(Vec As Vector2f)
232 This.X=Vec.X As GLdouble
233 This.Y=Vec.Y As GLdouble
234 End Sub
235
236Public /* destructor */
237 Sub ~Vector2d()
238 End Sub
239
240Public /* property */
241 Function X() As GLdouble
242 Return xy.x
243 End Function
244 Function Y() As GLdouble
245 Return xy.y
246 End Function
247 Sub X(x As GLdouble)
248 xy.x=x
249 End Sub
250 Sub Y(y As GLdouble)
251 xy.y=y
252 End Sub
253
254Public /* operator */
255 Sub Operator = (ByRef SrcVec As Vector2d)
256 This.X=SrcVec.X
257 This.Y=SrcVec.Y
258 End Sub
259 Function Operator + (SrcVec As Vector2d) As Vector2d
260 Return Add(This,SrcVec)
261 End Function
262 Function Operator - (SrcVec As Vector2d) As Vector2d
263 Return Substract(This,SrcVec)
264 End Function
265/* Function Operator * (SrcVec As Vector2d) As GLdouble
266 Return Dot(This,SrcVec)
267 End Function*/
268 Function Operator * (Src As GLint) As Vector2d
269 Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
270 Return ret
271 End Function
272 Function Operator * (Src As GLfloat) As Vector2d
273 Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
274 Return ret
275 End Function
276 Function Operator * (Src As GLdouble) As Vector2d
277 Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
278 Return ret
279 End Function
280 Function Operator / (Src As GLint) As Vector2d
281 Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
282 Return ret
283 End Function
284 Function Operator / (Src As GLfloat) As Vector2d
285 Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
286 Return ret
287 End Function
288 Function Operator / (Src As GLdouble) As Vector2d
289 Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
290 Return ret
291 End Function
292
293 Function Operator == (Vec As Vector2d) As Boolean
294 If This.X=Vec.X and This.Y=Vec.Y Then
295 Return True
296 Else
297 Return False
298 End If
299 End Function
300
301
302Public /* method */
303 Function Add(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As Vector2d
304 Dim ret As Vector2d(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y)
305 Return ret
306 End Function
307 Function Distance(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As GLdouble
308 Dim ret As Vector2d
309 ret=SrcVec1-SrcVec2
310 Return ret.Magnitude
311 End Function
312 Function Dot(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As GLdouble
313 Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y
314 End Function
315 Function Empty() As Vector2d
316 Return New Vector2d()
317 End Function
318 Function Magnitude() As GLdouble
319 Return Math.Sqrt(This.X^2+This.Y^2) As GLdouble
320 End Function
321 Sub Normalize()
322 Dim ret As Vector2d(This.X/This.Magnitude,This.Y/This.Magnitude)
323 This = ret
324 End Sub
325 Function NormalizedVector() As Vector2d
326 Dim ret As Vector2d(This.X/This.Magnitude,This.Y/This.Magnitude)
327 Return ret
328 End Function
329 Function Substract(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As Vector2d
330 Dim ret As Vector2d(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y)
331 Return ret
332 End Function
333 Sub Reverse()
334 Dim ret As Vector2d(-This.X,-This.Y)
335 This = ret
336 End Sub
337 Function ReversedVector() As Vector2d
338 Dim ret As Vector2d(-This.X,-This.Y)
339 Return ret
340 End Function
341
342Public /* Object Class Override */
343 Override Function Equals( object As Object ) As Boolean
344 If This.GetHashCode() = object.GetHashCode() Then
345 Return True
346 Else
347 Return False
348 End If
349 End Function
350 Override Function ToString() As String
351 Return GetType().Name
352 End Function
353
354Public /* Data */
355 xz As XY_DOUBLE
356End Class
357
358
359Type XYZ_FLOAT
360 x As GLfloat
361 y As GLfloat
362 z As GLfloat
363End Type
364
365Type XYZ_DOUBLE
366 x As GLdouble
367 y As GLdouble
368 z As GLdouble
369End Type
370
371Class Vector3f
372Public /* constructor */
373 Sub Vector3f()
374 This.X=0.0 As GLfloat
375 This.Y=0.0 As GLfloat
376 This.Z=0.0 As GLfloat
377 End Sub
378 Sub Vector3f(x As GLfloat, y As GLfloat, z As GLfloat)
379 xyz.x=x
380 xyz.y=y
381 xyz.z=z
382 End Sub
383 Sub Vector3f(Vec As Vector3d)
384 This.X=Vec.X As GLfloat
385 This.Y=Vec.Y As GLfloat
386 This.Z=Vec.Z As GLfloat
387 End Sub
388
389Public /* destructor */
390 Sub ~Vector3f()
391 End Sub
392
393Public /* property */
394 Function X() As GLfloat
395 Return xyz.x
396 End Function
397 Function Y() As GLfloat
398 Return xyz.y
399 End Function
400 Function Z() As GLfloat
401 Return xyz.z
402 End Function
403 Sub X(x As GLfloat)
404 xyz.x=x
405 End Sub
406 Sub Y(y As GLfloat)
407 xyz.y=y
408 End Sub
409 Sub Z(z As GLfloat)
410 xyz.z=z
411 End Sub
412
413Public /* operator */
414 Sub Operator = (ByRef SrcVec As Vector3f)
415 This.X=SrcVec.X
416 This.Y=SrcVec.Y
417 End Sub
418 Function Operator + (SrcVec As Vector3f) As Vector3f
419 Return Add(This,SrcVec)
420 End Function
421 Function Operator - (SrcVec As Vector3f) As Vector3f
422 Return Substract(This,SrcVec)
423 End Function
424/* Function Operator * (SrcVec As Vector3f) As GLfloat
425 Return Dot(This,SrcVec)
426 End Function*/
427 Function Operator ^ (SrcVec As Vector3f) As Vector3f
428 Return Cross(This,SrcVec)
429 End Function
430
431 Function Operator * (Src As GLint) As Vector3f
432 Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
433 Return ret
434 End Function
435 Function Operator * (Src As GLfloat) As Vector3f
436 Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
437 Return ret
438 End Function
439 Function Operator * (Src As GLdouble) As Vector3f
440 Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
441 Return ret
442 End Function
443 Function Operator / (Src As GLint) As Vector3f
444 Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
445 Return ret
446 End Function
447 Function Operator / (Src As GLfloat) As Vector3f
448 Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
449 Return ret
450 End Function
451 Function Operator / (Src As GLdouble) As Vector3f
452 Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
453 Return ret
454 End Function
455
456 Function Operator == (Vec As Vector3f) As Boolean
457 If This.X=Vec.X and This.Y=Vec.Y and This.Z=Vec.Z Then
458 Return True
459 Else
460 Return False
461 End If
462 End Function
463
464Public /* method */
465 Function Add(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
466 Dim ret As Vector3f(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y,SrcVec1.Z+SrcVec2.Z)
467 Return ret
468 End Function
469 Function Cross(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
470 Dim ret As Vector3f(SrcVec1.Y*SrcVec2.Z-SrcVec1.Z*SrcVec2.Y,SrcVec1.Z*SrcVec2.X-SrcVec1.X*SrcVec2.Z,SrcVec1.X*SrcVec2.Y-SrcVec1.Y*SrcVec2.X)
471 Return ret
472 End Function
473 Function Distance(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As GLfloat
474 Dim ret As Vector3f
475 ret=SrcVec1-SrcVec2
476 Return ret.Magnitude
477 End Function
478 Function Dot(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As GLfloat
479 Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y+SrcVec1.Z*SrcVec2.Z
480 End Function
481 Function Empty() As Vector3f
482 Return New Vector3f()
483 End Function
484 Function Magnitude() As GLfloat
485 Return Math.Sqrt(This.X^2+This.Y^2+This.Z^2) As GLfloat
486 End Function
487 Sub Normalize()
488 Dim ret As Vector3f(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude)
489 This = ret
490 End Sub
491 Function NormalizedVector() As Vector3f
492 Dim ret As Vector3f(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude)
493 Return ret
494 End Function
495 Function Substract(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
496 Dim ret As Vector3f(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
497 Return ret
498 End Function
499 Sub Reverse()
500 Dim ret As Vector3f(-This.X,-This.Y,-This.Z)
501 This = ret
502 End Sub
503 Function ReversedVector() As Vector3f
504 Dim ret As Vector3f(-This.X,-This.Y,-This.Z)
505 Return ret
506 End Function
507
508Public /* Object Class Override */
509 Override Function Equals( object As Object ) As Boolean
510 If This.GetHashCode() = object.GetHashCode() Then
511 Return True
512 Else
513 Return False
514 End If
515 End Function
516 Override Function ToString() As String
517 Return GetType().Name
518 End Function
519
520Public /* Data */
521 xyz As XYZ_FLOAT
522End Class
523
524Class Vector3d
525Public /* constructor */
526 Sub Vector3d()
527 This.X=0.0 As GLdouble
528 This.Y=0.0 As GLdouble
529 This.Z=0.0 As GLdouble
530 End Sub
531 Sub Vector3d(x As GLdouble, y As GLdouble, z As GLdouble)
532 xyz.x=x
533 xyz.y=y
534 xyz.z=z
535 End Sub
536 Sub Vector3d(Vec As Vector3f)
537 This.X=Vec.X As GLdouble
538 This.Y=Vec.Y As GLdouble
539 This.Z=Vec.Z As GLdouble
540 End Sub
541
542Public /* destructor */
543 Sub ~Vector3d()
544 End Sub
545
546
547Public /* property */
548 Function X() As GLdouble
549 Return xyz.x
550 End Function
551 Function Y() As GLdouble
552 Return xyz.y
553 End Function
554 Function Z() As GLdouble
555 Return xyz.z
556 End Function
557 Sub X(x As GLdouble)
558 xyz.x=x
559 End Sub
560 Sub Y(y As GLdouble)
561 xyz.y=y
562 End Sub
563 Sub Z(z As GLdouble)
564 xyz.z=z
565 End Sub
566
567
568Public /* operator */
569 Sub Operator = (ByRef SrcVec As Vector3d)
570 This.X=SrcVec.X
571 This.Y=SrcVec.Y
572 End Sub
573 Function Operator + (SrcVec As Vector3d) As Vector3d
574 Return Add(This,SrcVec)
575 End Function
576 Function Operator - (SrcVec As Vector3d) As Vector3d
577 Return Substract(This,SrcVec)
578 End Function
579/* Function Operator * (SrcVec As Vector3d) As GLdouble
580 Return Dot(This,SrcVec)
581 End Function*/
582 Function Operator ^ (SrcVec As Vector3d) As Vector3d
583 Return Cross(This,SrcVec)
584 End Function
585
586 Function Operator * (Src As GLint) As Vector3d
587 Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
588 Return ret
589 End Function
590 Function Operator * (Src As GLfloat) As Vector3d
591 Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
592 Return ret
593 End Function
594 Function Operator * (Src As GLdouble) As Vector3d
595 Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
596 Return ret
597 End Function
598 Function Operator / (Src As GLint) As Vector3d
599 Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
600 Return ret
601 End Function
602 Function Operator / (Src As GLfloat) As Vector3d
603 Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
604 Return ret
605 End Function
606 Function Operator / (Src As GLdouble) As Vector3d
607 Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
608 Return ret
609 End Function
610
611 Function Operator == (Vec As Vector3d) As Boolean
612 If This.X=Vec.X and This.Y=Vec.Y and This.Z=Vec.Z Then
613 Return True
614 Else
615 Return False
616 End If
617 End Function
618
619
620Public /* method */
621 Function Add(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
622 Dim ret As Vector3d(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y,SrcVec1.Z+SrcVec2.Z)
623 Return ret
624 End Function
625 Function Cross(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
626 Dim ret As Vector3d(SrcVec1.Y*SrcVec2.Z-SrcVec1.Z*SrcVec2.Y,SrcVec1.Z*SrcVec2.X-SrcVec1.X*SrcVec2.Z,SrcVec1.X*SrcVec2.Y-SrcVec1.Y*SrcVec2.X)
627 Return ret
628 End Function
629 Function Distance(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As GLdouble
630 Dim ret As Vector3d
631 ret=SrcVec1-SrcVec2
632 Return ret.Magnitude
633 End Function
634 Function Dot(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As GLdouble
635 Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y+SrcVec1.Z*SrcVec2.Z
636 End Function
637 Function Empty() As Vector3d
638 Dim ret As Vector3d()
639 Return ret
640 End Function
641 Function Magnitude() As GLdouble
642 Return Math.Sqrt(This.X^2+This.Y^2+This.Z^2) As GLdouble
643 End Function
644 Sub Normalize()
645 Dim ret As Vector3d(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude)
646 This = ret
647 End Sub
648 Function NormalizedVector() As Vector3d
649 Dim ret As Vector3d(This.X/This.Magnitude,This.Y/This.Magnitude,This.Z/This.Magnitude)
650 Return ret
651 End Function
652 Function Substract(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
653 Dim ret As Vector3d(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
654 Return ret
655 End Function
656 Sub Reverse()
657 Dim ret As Vector3d(-This.X,-This.Y,-This.Z)
658 This = ret
659 End Sub
660 Function ReversedVector() As Vector3d
661 Dim ret As Vector3d(-This.X,-This.Y,-This.Z)
662 Return ret
663 End Function
664
665Public /* Object Class Override */
666 Override Function Equals( object As Object ) As Boolean
667 If This.GetHashCode() = object.GetHashCode() Then
668 Return True
669 Else
670 Return False
671 End If
672 End Function
673 Override Function ToString() As String
674 Return GetType().Name
675 End Function
676
677Public /* Data */
678 xyz As XYZ_DOUBLE
679End Class
680
681NameSpace Matrix
682 Class Matrix3x3f
683 End Class
684
685 Class Matrix3x3d
686 End Class
687
688 Class Matrix4x4f
689 End Class
690
691 Class Matrix4x4d
692 End Class
693End NameSpace
694
695Type RGB_FLOAT
696 r As GLfloat
697 g As GLfloat
698 b As GLfloat
699End Type
700
701Type RGB_DOUBLE
702 r As GLdouble
703 g As GLdouble
704 b As GLdouble
705End Type
706
707Class Color3f
708Public /* constructor */
709 Sub Color3f(r As GLfloat, g As GLfloat, b As GLfloat)
710 rgb.r = r
711 rgb.g = g
712 rgb.b = b
713 End Sub
714 Sub Color3f(color As Color3d)
715 rgba.r = color.R As GLfloat
716 rgba.g = color.G As GLfloat
717 rgba.b = color.B As GLfloat
718 End Sub
719
720Public /* destructor */
721 Sub ~Color3f()
722 End Sub
723
724Public /* property */
725 Function R() As GLfloat
726 Return rgb.r
727 End Function
728 Function G() As GLfloat
729 Return rgb.g
730 End Function
731 Function B() As GLfloat
732 Return rgb.b
733 End Function
734 Sub R(r As GLfloat)
735 rgb.r = r
736 End Sub
737 Sub G(g As GLfloat)
738 rgb.g = g
739 End Sub
740 Sub B(b As GLfloat)
741 rgb.b = b
742 End Sub
743
744Public /* operator */
745 Sub operator = (c As Color3f)
746 This.R=c.R
747 This.G=c.G
748 This.B=c.B
749 End Sub
750
751Public /* method */
752 ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした
753 ' Drawwing\Color.abをさらに参考にしました。
754 Function GetHue() As GLfloat
755 Dim max As GLfloat, min As GLfloat, d As GLfloat
756 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
757 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
758 d = max - min
759 If rgb.g = max Then
760 Return ((rgb.b - rgb.r) As Double / d * 60.0 + 120.0) As GLfloat
761 ElseIf rgb.b = max Then
762 Return ((rgb.r - rgb.g) As Double / d * 60.0 + 240.0) As GLfloat
763 ElseIf rgb.g < rgb.b Then
764 Return ((rgb.g - rgb.b) As Double / d * 60.0 + 360.0) As GLfloat
765 Else
766 Return ((rgb.g - rgb.b) As Double / d * 60.0) As GLfloat
767 EndIf
768 End Function
769
770 Function GetSaturation() As GLfloat
771 Dim max As GLfloat, min As GLfloat
772 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
773 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
774 Return (max - min) / max
775 End Function
776
777 Function GetVolue() As GLfloat
778 Dim max As GLfloat
779 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
780 Return max
781 End Function
782
783Public /* static method */
784 Static Function FromRGB(r As GLubyte, g As GLubyte, b As GLubyte) As Color3f
785 Dim ret As Color3f((r As GLfloat)/255.0 As GLfloat,(g As GLfloat)/255.0 As GLfloat,(b As GLfloat)/255.0 As GLfloat)
786 Return ret
787 End Function
788 Static Function FromCOLORREF(c As COLORREF) As Color3f
789 Dim ret As Color3f((c and &hff) As GLfloat/255,(c>>8 and &hff) As GLfloat/255,(c>>16 and &hff) As GLfloat/255)
790 Return ret
791 End Function
792 Static Function FromHSV(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f
793 Dim r As GLfloat
794 Dim g As GLfloat
795 Dim b As GLfloat
796 If h<0 Then h+=360.0
797 If h>360.0 Then h-=360.0
798 Select Case (h/60) As Long
799 Case 0
800 r=v
801 g=v*(1-s*(1-(h/60-(h/60) As Long)))
802 b=v*(1-s)
803 Case 1
804 r=v*(1-s*(h/60-(h/60) As Long))
805 g=v
806 b=v*(1-s)
807 Case 2
808 r=v*(1-s)
809 g=v
810 b=v*(1-s*(1-(h/60-(h/60) As Long)))
811 Case 3
812 r=v*(1-s)
813 g=v*(1-s*(h/60-(h/60) As Long))
814 b=v
815 Case 4
816 r=v*(1-s*(1-(h/60-(h/60) As Long)))
817 g=v*(1-s)
818 b=v
819 Case 5
820 r=v
821 g=v*(1-s)
822 b=v*(1-s*(h/60-(h/60) As Long))
823 Case 6
824 r=v
825 g=v*(1-s*(1-(h/60-(h/60) As Long)))
826 b=v*(1-s)
827 End Select
828
829 Dim ret As Color3f(r,g,b)
830 Return ret
831 End Function
832
833Public
834 rgb As RGB_FLOAT
835End Class
836
837Class Color3d
838Public /* constructor */
839 Sub Color3d(r As GLdouble, g As GLdouble, b As GLdouble)
840 rgb.r = r
841 rgb.g = g
842 rgb.b = b
843 End Sub
844 Sub Color3d(color As Color3f)
845 rgba.r = color.R As GLdouble
846 rgba.g = color.G As GLdouble
847 rgba.b = color.B As GLdouble
848 End Sub
849
850Public /* destructor */
851 Sub ~Color3d()
852 End Sub
853
854Public /* property */
855 Function R() As GLdouble
856 Return rgb.r
857 End Function
858 Function G() As GLdouble
859 Return rgb.g
860 End Function
861 Function B() As GLdouble
862 Return rgb.b
863 End Function
864 Sub R(r As GLdouble)
865 rgb.r = r
866 End Sub
867 Sub G(g As GLdouble)
868 rgb.g = g
869 End Sub
870 Sub B(b As GLdouble)
871 rgb.b = b
872 End Sub
873
874Public /* method */
875 ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした
876 ' Drawwing\Color.abをさらに参考にしました。
877 Function GetHue() As GLdouble
878 Dim max As GLdouble, min As GLdouble, d As GLdouble
879 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
880 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
881 d = max - min
882 If rgb.g = max Then
883 Return ((rgb.b - rgb.r) As Double / d * 60.0 + 120.0) As GLfloat
884 ElseIf rgb.b = max Then
885 Return ((rgb.r - rgb.g) As Double / d * 60.0 + 240.0) As GLfloat
886 ElseIf rgb.g < rgb.b Then
887 Return ((rgb.g - rgb.b) As Double / d * 60.0 + 360.0) As GLfloat
888 Else
889 Return ((rgb.g - rgb.b) As Double / d * 60.0) As GLfloat
890 EndIf
891 End Function
892
893 Function GetSaturation() As GLdouble
894 Dim max As GLdouble, min As GLdouble
895 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
896 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
897 Return (max - min) / max
898 End Function
899
900 Function GetVolue() As GLdouble
901 Dim max As GLdouble
902 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
903 Return max
904 End Function
905
906Public /* static method */
907 Static Function FromRGB(r As GLubyte, g As GLubyte, b As GLubyte) As Color3d
908 Dim ret As Color3d(r/255,g/255,b/255)
909 Return ret
910 End Function
911 Static Function FromCOLORREF(c As COLORREF) As Color3d
912 Dim ret As Color3d((c and &hff)/255,(c>>8 and &hff)/255,(c>>16 and &hff)/255)
913 Return ret
914 End Function
915 Static Function FromHSV(h As GLdouble, s As GLdouble, v As GLdouble) As Color3d
916 Dim r As GLdouble
917 Dim g As GLdouble
918 Dim b As GLfloat
919 If h<0 Then h+=360.0
920 If h>360.0 Then h-=360.0
921 Select Case (h/60) As Long
922 Case 0
923 r=v
924 g=v*(1-s*(1-(h/60-(h/60) As Long)))
925 b=v*(1-s)
926 Case 1
927 r=v*(1-s*(h/60-(h/60) As Long))
928 g=v
929 b=v*(1-s)
930 Case 2
931 r=v*(1-s)
932 g=v
933 b=v*(1-s*(1-(h/60-(h/60) As Long)))
934 Case 3
935 r=v*(1-s)
936 g=v*(1-s*(h/60-(h/60) As Long))
937 b=v
938 Case 4
939 r=v*(1-s*(1-(h/60-(h/60) As Long)))
940 g=v*(1-s)
941 b=v
942 Case 5
943 r=v
944 g=v*(1-s)
945 b=v*(1-s*(h/60-(h/60) As Long))
946 Case 6
947 r=v
948 g=v*(1-s*(1-(h/60-(h/60) As Long)))
949 b=v*(1-s)
950 End Select
951
952 Dim ret As Color3d(r,g,b)
953 Return ret
954 End Function
955Public
956 rgb As RGB_DOUBLE
957End Class
958
959Type RGBA_FLOAT
960 r As GLfloat
961 g As GLfloat
962 b As GLfloat
963 a As GLfloat
964End Type
965
966Type RGBA_DOUBLE
967 r As GLdouble
968 g As GLdouble
969 b As GLdouble
970 a As GLdouble
971End Type
972
973Class Color4f
974Public /* constructor */
975 Sub Color4f(r As GLfloat, g As GLfloat, b As GLfloat, a As GLfloat)
976 rgba.r = r
977 rgba.g = g
978 rgba.b = b
979 rgba.a = a
980 End Sub
981 Sub Color4f(color As Color4d)
982 rgba.r = color.R As GLfloat
983 rgba.g = color.G As GLfloat
984 rgba.b = color.B As GLfloat
985 rgba.a = color.A As GLfloat
986 End Sub
987
988Public /* destructor */
989 Sub ~Color4f()
990 End Sub
991
992Public /* property */
993 Function R() As GLfloat
994 Return rgba.r
995 End Function
996 Function G() As GLfloat
997 Return rgba.g
998 End Function
999 Function B() As GLfloat
1000 Return rgba.b
1001 End Function
1002 Function A() As GLfloat
1003 Return rgba.a
1004 End Function
1005 Sub R(r As GLfloat)
1006 rgba.r = r
1007 End Sub
1008 Sub G(g As GLfloat)
1009 rgba.g = g
1010 End Sub
1011 Sub B(b As GLfloat)
1012 rgba.b = b
1013 End Sub
1014 Sub A(a As GLfloat)
1015 rgba.a = a
1016 End Sub
1017
1018Public /* operator */
1019 Sub operator = (ByRef c As Color4f)
1020 This.R=c.R
1021 This.G=c.G
1022 This.B=c.B
1023 This.A=c.A
1024 End Sub
1025
1026Public /* method */
1027 ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした
1028 ' Drawwing\Color.abをさらに参考にしました。
1029 Function GetHue() As GLfloat
1030 Dim max As GLfloat, min As GLfloat, d As GLfloat
1031 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
1032 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
1033 d = max - min
1034 If rgb.g = max Then
1035 Return ((rgb.b - rgb.r) As Double / d * 60.0 + 120.0) As GLfloat
1036 ElseIf rgb.b = max Then
1037 Return ((rgb.r - rgb.g) As Double / d * 60.0 + 240.0) As GLfloat
1038 ElseIf rgb.g < rgb.b Then
1039 Return ((rgb.g - rgb.b) As Double / d * 60.0 + 360.0) As GLfloat
1040 Else
1041 Return ((rgb.g - rgb.b) As Double / d * 60.0) As GLfloat
1042 EndIf
1043 End Function
1044
1045 Function GetSaturation() As GLfloat
1046 Dim max As GLfloat, min As GLfloat
1047 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
1048 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
1049 Return (max - min) / max
1050 End Function
1051
1052 Function GetVolue() As GLfloat
1053 Dim max As GLfloat
1054 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
1055 Return max
1056 End Function
1057
1058Public /* static method */
1059 Static Function FromRGB(r As GLubyte, g As GLubyte, b As GLubyte) As Color4f
1060 Dim ret As Color4f(r/255,g/255,b/255,1.0)
1061 Return ret
1062 End Function
1063 Static Function FromArgb(a As GLubyte, r As GLubyte, g As GLubyte, b As GLubyte) As Color4f
1064 Dim ret As Color4f(r/255,g/255,b/255,a/255)
1065 Return ret
1066 End Function
1067 Static Function FromCOLORREF(c As COLORREF) As Color4f
1068 Dim ret As Color4f((c and &hff)/255,(c>>8 and &hff)/255,(c>>16 and &hff)/255,1.0)
1069 Return ret
1070 End Function
1071 Static Function FromHSV(h As GLfloat, s As GLfloat, v As GLfloat, a As GLfloat) As Color4f
1072 Dim r As GLfloat
1073 Dim g As GLfloat
1074 Dim b As GLfloat
1075 If h<0 Then h+=360.0
1076 If h>360.0 Then h-=360.0
1077 Select Case (h/60) As Long
1078 Case 0
1079 r=v
1080 g=v*(1-s*(1-(h/60-(h/60) As Long)))
1081 b=v*(1-s)
1082 Case 1
1083 r=v*(1-s*(h/60-(h/60) As Long))
1084 g=v
1085 b=v*(1-s)
1086 Case 2
1087 r=v*(1-s)
1088 g=v
1089 b=v*(1-s*(1-(h/60-(h/60) As Long)))
1090 Case 3
1091 r=v*(1-s)
1092 g=v*(1-s*(h/60-(h/60) As Long))
1093 b=v
1094 Case 4
1095 r=v*(1-s*(1-(h/60-(h/60) As Long)))
1096 g=v*(1-s)
1097 b=v
1098 Case 5
1099 r=v
1100 g=v*(1-s)
1101 b=v*(1-s*(h/60-(h/60) As Long))
1102 Case 6
1103 r=v
1104 g=v*(1-s*(1-(h/60-(h/60) As Long)))
1105 b=v*(1-s)
1106 End Select
1107
1108 Dim ret As Color4f(r,g,b,a)
1109 Return ret
1110 End Function
1111
1112Public
1113 rgba As RGBA_FLOAT
1114End Class
1115
1116Class Color4d
1117
1118Public /* constructor */
1119 Sub Color4d(r As GLdouble, g As GLdouble, b As GLdouble, a As GLdouble)
1120 rgba.r = r
1121 rgba.g = g
1122 rgba.b = b
1123 rgba.a = a
1124 End Sub
1125 Sub Color4d(color As Color4f)
1126 rgba.r = color.R As GLdouble
1127 rgba.g = color.G As GLdouble
1128 rgba.b = color.B As GLdouble
1129 rgba.a = color.A As GLdouble
1130 End Sub
1131
1132Public /* destructor */
1133 Sub ~Color4d()
1134 End Sub
1135
1136Public /* property */
1137 Function R() As GLdouble
1138 Return rgba.r
1139 End Function
1140 Function G() As GLdouble
1141 Return rgba.g
1142 End Function
1143 Function B() As GLdouble
1144 Return rgba.b
1145 End Function
1146 Function A() As GLdouble
1147 Return rgba.a
1148 End Function
1149 Sub R(r As GLdouble)
1150 rgba.r = r
1151 End Sub
1152 Sub G(g As GLdouble)
1153 rgba.g = g
1154 End Sub
1155 Sub B(b As GLdouble)
1156 rgba.b = b
1157 End Sub
1158 Sub A(a As GLdouble)
1159 rgba.a = a
1160 End Sub
1161
1162Public /* operator */
1163 Sub operator = (ByRef c As Color4d)
1164 This.R=c.R
1165 This.G=c.G
1166 This.B=c.B
1167 This.A=c.A
1168 End Sub
1169
1170Public /* method */
1171 ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした
1172 ' Drawwing\Color.abをさらに参考にしました。
1173 Function GetHue() As GLfloat
1174 Dim max As GLfloat, min As GLfloat, d As GLfloat
1175 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
1176 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
1177 d = max - min
1178 If rgb.g = max Then
1179 Return ((rgb.b - rgb.r) As Double / d * 60.0 + 120.0) As GLdouble
1180 ElseIf rgb.b = max Then
1181 Return ((rgb.r - rgb.g) As Double / d * 60.0 + 240.0) As GLdouble
1182 ElseIf rgb.g < rgb.b Then
1183 Return ((rgb.g - rgb.b) As Double / d * 60.0 + 360.0) As GLdouble
1184 Else
1185 Return ((rgb.g - rgb.b) As Double / d * 60.0) As GLdouble
1186 EndIf
1187 End Function
1188
1189 Function GetSaturation() As GLdouble
1190 Dim max As GLdouble, min As GLdouble
1191 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
1192 min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
1193 Return (max - min) / max
1194 End Function
1195
1196 Function GetVolue() As GLdouble
1197 Dim max As GLdouble
1198 max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
1199 Return max
1200 End Function
1201
1202Public /* static method */
1203 Static Function FromRGB(r As GLubyte, g As GLubyte, b As GLubyte) As Color4d
1204 Dim ret As Color4d(r/255,g/255,b/255,1.0)
1205 Return ret
1206 End Function
1207 Static Function FromArgb(a As GLubyte, r As GLubyte, g As GLubyte, b As GLubyte) As Color4d
1208 Dim ret As Color4d(r/255,g/255,b/255,a/255)
1209 Return ret
1210 End Function
1211 Static Function FromCOLORREF(c As COLORREF) As Color4d
1212 Dim ret As Color4d((c and &hff)/255,(c>>8 and &hff)/255,(c>>16 and &hff)/255,1.0)
1213 Return ret
1214 End Function
1215 Static Function FromHSV(h As GLdouble, s As GLdouble, v As GLdouble, a As GLdouble) As Color4d
1216 Dim r As GLdouble
1217 Dim g As GLdouble
1218 Dim b As GLdouble
1219 Dim a As GLdouble
1220 If h<0 Then h+=360.0
1221 If h>360.0 Then h-=360.0
1222 Select Case (h/60) As Long
1223 Case 0
1224 r=v
1225 g=v*(1-s*(1-(h/60-(h/60) As Long)))
1226 b=v*(1-s)
1227 Case 1
1228 r=v*(1-s*(h/60-(h/60) As Long))
1229 g=v
1230 b=v*(1-s)
1231 Case 2
1232 r=v*(1-s)
1233 g=v
1234 b=v*(1-s*(1-(h/60-(h/60) As Long)))
1235 Case 3
1236 r=v*(1-s)
1237 g=v*(1-s*(h/60-(h/60) As Long))
1238 b=v
1239 Case 4
1240 r=v*(1-s*(1-(h/60-(h/60) As Long)))
1241 g=v*(1-s)
1242 b=v
1243 Case 5
1244 r=v
1245 g=v*(1-s)
1246 b=v*(1-s*(h/60-(h/60) As Long))
1247 Case 6
1248 r=v
1249 g=v*(1-s*(1-(h/60-(h/60) As Long)))
1250 b=v*(1-s)
1251 End Select
1252
1253 Dim ret As Color4f(r,g,b,a)
1254 Return ret
1255 End Function
1256
1257Public
1258 rgba As RGBA_DOUBLE
1259End Class
1260
1261
1262Class Light
1263Private
1264 Const Number As GLenum
1265
1266Public
1267 Sub Enabled(enabled As GLboolean)
1268 If enabled Then
1269 glEnable(Number)
1270 Else
1271 glDisable(Number)
1272 End If
1273 End Sub
1274 Function Enabled() As GLboolean
1275 Dim lighting As GLboolean
1276 glGetBooleanv(Number,VarPtr(lighting))
1277 Return lighting
1278 End Function
1279
1280Public /* constructor */
1281 Sub Light(num As GLenum)
1282 Number=num
1283 End Sub
1284
1285Public
1286 Sub SetAmbient(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1287 Dim amb[3] As GLfloat
1288 amb[0]=red
1289 amb[1]=green
1290 amb[2]=blue
1291 amb[3]=alpha
1292 glLightfv(Number,GL_AMBIENT,amb)
1293 End Sub
1294 Sub SetAmbient(ByRef color As Color4f)
1295 Dim amb[3] As GLfloat
1296 amb[0]=color.R
1297 amb[1]=color.G
1298 amb[2]=color.B
1299 amb[3]=color.A
1300 glLightfv(Number,GL_AMBIENT,amb)
1301 End Sub
1302 Sub SetAmbient(amb As *GLfloat)
1303 glLightfv(Number,GL_AMBIENT,amb)
1304 End Sub
1305
1306 Sub SetDiffuse(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1307 Dim dif[3] As GLfloat
1308 dif[0]=red
1309 dif[1]=green
1310 dif[2]=blue
1311 dif[3]=alpha
1312 glLightfv(Number,GL_DIFFUSE,dif)
1313 End Sub
1314 Sub SetDiffuse(ByRef color As Color4f)
1315 Dim dif[3] As GLfloat
1316 amb[0]=color.R
1317 amb[1]=color.G
1318 amb[2]=color.B
1319 amb[3]=color.A
1320 glLightfv(Number,GL_DIFFUSE,dif)
1321 End Sub
1322 Sub SetDiffuse(dif As *GLfloat)
1323 glLightfv(Number,GL_DIFFUSE,dif)
1324 End Sub
1325
1326 Sub SetSpecular(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1327 Dim spc[3] As GLfloat
1328 spc[0]=red
1329 spc[1]=green
1330 spc[2]=blue
1331 spc[3]=alpha
1332 glLightfv(Number,GL_SPECULAR,spc)
1333 End Sub
1334 Sub SetSpecular(ByRef color As Color4f)
1335 Dim spc[3] As GLfloat
1336 amb[0]=color.R
1337 amb[1]=color.G
1338 amb[2]=color.B
1339 amb[3]=color.A
1340 glLightfv(Number,GL_SPECULAR,spc)
1341 End Sub
1342 Sub SetSpecular(spc As *GLfloat)
1343 glLightfv(Number,GL_SPECULAR,spc)
1344 End Sub
1345
1346 Sub SetPosition(pos As *GLfloat)
1347 glLightfv(Number,GL_POSITION,pos)
1348 End Sub
1349End Class
1350
1351Class LightsCollection
1352Public
1353 Function Item() As Light
1354 Return
1355 End Function
1356End Class
1357
1358Class MaterialManager
1359Public
1360 Sub Ambient(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1361 Dim face As GLenum
1362 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
1363 Dim amb[3] As GLfloat
1364 amb[0]=red
1365 amb[1]=green
1366 amb[2]=blue
1367 amb[3]=alpha
1368 glMaterialfv(face,GL_AMBIENT,amb)
1369 End Sub
1370 Sub Ambient(ByRef color As Color4f)
1371 Dim face As GLenum
1372 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
1373 Dim amb[3] As GLfloat
1374 amb[0]=color.R
1375 amb[1]=color.G
1376 amb[2]=color.B
1377 amb[3]=color.A
1378 glMaterialfv(face,GL_AMBIENT,amb)
1379 End Sub
1380 Sub Ambient(amb As *GLfloat)
1381 glMaterialfv(face,GL_AMBIENT,amb)
1382 End Sub
1383
1384 Sub Diffuse(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1385 Dim face As GLenum
1386 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
1387 Dim dif[3] As GLfloat
1388 dif[0]=red
1389 dif[1]=green
1390 dif[2]=blue
1391 dif[3]=alpha
1392 glMaterialfv(face,GL_DIFFUSE,dif)
1393 End Sub
1394 Sub Diffuse(ByRef color As Color4f)
1395 Dim face As GLenum
1396 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
1397 Dim dif[3] As GLfloat
1398 dif[0]=color.R
1399 dif[1]=color.G
1400 dif[2]=color.B
1401 dif[3]=color.A
1402 glMaterialfv(face,GL_DIFFUSE,dif)
1403 End Sub
1404 Sub Diffuse(dif As *GLfloat)
1405 glMaterialfv(face,GL_DIFFUSE,dif)
1406 End Sub
1407
1408 Sub Specular(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1409 Dim face As GLenum
1410 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
1411 Dim spc[3] As GLfloat
1412 spc[0]=red
1413 spc[1]=green
1414 spc[2]=blue
1415 spc[3]=alpha
1416 glMaterialfv(face,GL_SPECULAR,spc)
1417 End Sub
1418 Sub Specular(ByRef color As Color4f)
1419 Dim face As GLenum
1420 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
1421 Dim spc[3] As GLfloat
1422 spc[0]=color.R
1423 spc[1]=color.G
1424 spc[2]=color.B
1425 spc[3]=color.A
1426 glMaterialfv(face,GL_SPECULAR,spc)
1427 End Sub
1428 Sub Specular(spc As *GLfloat)
1429 glMaterialfv(face,GL_SPECULAR,spc)
1430 End Sub
1431
1432 Sub Shininess(shin As GLfloat)
1433 Dim face As GLenum
1434 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
1435 glMaterialf(face,GL_SHININESS,shin)
1436 End Sub
1437
1438 Sub Emission(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
1439 Dim face As GLenum
1440 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
1441 Dim ems[3] As GLfloat
1442 ems[0]=red
1443 ems[1]=green
1444 ems[2]=blue
1445 ems[3]=alpha
1446 glMaterialfv(face,GL_EMISSION,ems)
1447 End Sub
1448End Class
1449
1450Class ModelViewMatrix
1451Public
1452 Sub LoadIdentity()
1453 Dim mode As GLenum
1454 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode) As *Long)
1455 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1456 glLoadIdentity()
1457 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1458 End Sub
1459 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)
1460 Dim mode As GLenum
1461 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1462 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1463 gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz)
1464 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1465 End Sub
1466 Sub RotateX(angle As GLdouble)
1467 Dim mode As GLenum
1468 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode) As *Long)
1469 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1470 glRotated(angle, 1.0 As GLdouble, 0.0 As GLdouble, 0.0 As GLdouble)
1471 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1472 End Sub
1473 Sub RotateX(angle As GLfloat)
1474 Dim mode As GLenum
1475 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1476 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1477 glRotatef(angle, 1.0 As GLfloat, 0.0 As GLfloat, 0.0 As GLfloat)
1478 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1479 End Sub
1480 Sub RotateY(angle As GLdouble)
1481 Dim mode As GLenum
1482 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode) As *Long)
1483 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1484 glRotated(angle, 0.0 As GLdouble, 1.0 As GLdouble, 0.0 As GLdouble)
1485 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1486 End Sub
1487 Sub RotateY(angle As GLfloat)
1488 Dim mode As GLenum
1489 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1490 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1491 glRotatef(angle, 0.0 As GLfloat, 1.0 As GLfloat, 0.0 As GLfloat)
1492 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1493 End Sub
1494 Sub RotateZ(angle As GLdouble)
1495 Dim mode As GLenum
1496 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1497 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1498 glRotated(angle, 0.0 As GLdouble, 0.0 As GLdouble, 1.0 As GLdouble)
1499 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1500 End Sub
1501 Sub RotateZ(angle As GLfloat)
1502 Dim mode As GLenum
1503 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1504 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1505 glRotatef(angle, 0.0 As GLfloat, 0.0 As GLfloat, 1.0 As GLfloat)
1506 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1507 End Sub
1508 Sub Scale(x As GLdouble, y As GLdouble, z As GLdouble)
1509 Dim mode As GLenum
1510 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1511 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1512 glScaled(x, y, z)
1513 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1514 End Sub
1515 Sub Scale(x As GLfloat, y As GLfloat, z As GLfloat)
1516 Dim mode As GLenum
1517 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1518 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1519 glScalef(x, y, z)
1520 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1521 End Sub
1522 Sub Translate(x As GLdouble, y As GLdouble, z As GLdouble)
1523 Dim mode As GLenum
1524 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode) As *GLint)
1525 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1526 glTranslated(x, y, z)
1527 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1528 End Sub
1529 Sub Translate(x As GLfloat, y As GLfloat, z As GLfloat)
1530 Dim mode As GLenum
1531 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode) As *Long)
1532 If mode<>GL_MODELVIEW Then glMatrixMode(GL_MODELVIEW)
1533 glTranslatef(x, y, z)
1534 If mode<>GL_MODELVIEW Then glMatrixMode(mode)
1535 End Sub
1536End Class
1537
1538Class ProjectionMatrix
1539Public
1540 Sub LoadIdentity()
1541 Dim mode As GLenum
1542 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode) As *Long)
1543 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
1544 glLoadIdentity()
1545 If mode<>GL_PROJECTION Then glMatrixMode(mode)
1546 End Sub
1547 Sub Ortho2D(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble)
1548 Dim mode As GLenum
1549 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode) As *Long)
1550 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
1551 gluOrtho2D(left, right, bottom, top)
1552 If mode<>GL_PROJECTION Then glMatrixMode(mode)
1553 End Sub
1554 Sub Ortho3D(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble, zNear As GLdouble, zFar As GLdouble)
1555 Dim mode As GLenum
1556 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1557 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
1558 glOrtho(left, right, bottom, top, zNear, zFar)
1559 If mode<>GL_PROJECTION Then glMatrixMode(mode)
1560 End Sub
1561 Sub Frustum(left As GLdouble, right As GLdouble, bottom As GLdouble, top As GLdouble, zNear As GLdouble, zFar As GLdouble)
1562 Dim mode As GLenum
1563 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode))
1564 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
1565 glFrustum(left, right, bottom, top, zNear, zFar)
1566 If mode<>GL_PROJECTION Then glMatrixMode(mode)
1567 End Sub
1568 Sub Perspective(fovy As GLdouble, aspect As GLdouble, zNear As GLdouble, zFar As GLdouble)
1569 Dim mode As GLenum
1570 glGetIntegerv(GL_MATRIX_MODE,VarPtr(mode) As *Long)
1571 If mode<>GL_PROJECTION Then glMatrixMode(GL_PROJECTION)
1572 gluPerspective(fovy, aspect, zNear, zFar)
1573 If mode<>GL_PROJECTION Then glMatrixMode(mode)
1574 End Sub
1575End Class
1576
1577Class TransformMatrix
1578Public
1579 Projection As ProjectionMatrix
1580 ModelView As ModelViewMatrix
1581
1582Public
1583 Sub Transform()
1584 Projection=New ProjectionMatrix
1585 ModelView=New ModelViewMatrix
1586 End Sub
1587End Class
1588
1589Class LightModelManager
1590Public
1591 Function Ambient () As Color4f
1592 Dim amb As Color4f
1593 glGetFloatv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb.rgba))
1594 Return amb
1595 End Function
1596 Sub Ambient(amb As Color4f)
1597 glLightModelfv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb.rgba))
1598 End Sub
1599
1600 Function LocalView() As GLboolean
1601 Dim local As GLboolean
1602 glGetBooleanv(GL_LIGHT_MODEL_LOCAL_VIEW,VarPtr(local))
1603 Return local
1604 End Function
1605 Sub LocalView(enable As GLboolean)
1606 If enable Then
1607 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEW,GL_TRUE)
1608 Else
1609 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEW,GL_FALSE)
1610 End If
1611 End Sub
1612
1613 Function TwoSide() As GLboolean
1614 Dim local As GLboolean
1615 glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE,VarPtr(local))
1616 Return local
1617 End Function
1618 Sub TwoSide(enable As GLboolean)
1619 If enable Then
1620 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE)
1621 Else
1622 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE)
1623 End If
1624 End Sub
1625End Class
1626
1627Class RenderStateManager
1628Public /* Composiotion */
1629 LightModel As LightModelManager
1630
1631Public
1632 Sub RenderStateManager()
1633 LightModel = New LightModelManager()
1634 End Sub
1635 Function AlphaTestEnable() As GLboolean
1636 Dim alpha As GLboolean
1637 glGetBooleanv(GL_ALPHA_TEST,VarPtr(alpha))
1638 Return alpha
1639 End Function
1640 Sub AlphaTestEnable(enable As GLboolean)
1641 If enable Then
1642 glEnable(GL_ALPHA_TEST)
1643 Else
1644 glDisable(GL_ALPHA_TEST)
1645 End If
1646 End Sub
1647
1648 Function AlphaFunction() As GLenum
1649 Dim func As GLenum
1650 glGetIntegerv(GL_ALPHA_TEST_FUNC,VarPtr(func))
1651 Return func
1652 End Function
1653 Sub AlphaFunction(func As GLenum)
1654 Dim ref As GLclampf
1655 glGetFloatv(GL_ALPHA_TEST_REF,VarPtr(ref))
1656 glAlphaFunc(func,ref)
1657 End Sub
1658
1659 Function BlendEnable() As GLboolean
1660 Dim blend As GLboolean
1661 glGetBooleanv(GL_BLEND,VarPtr(blend))
1662 Return blend
1663 End Function
1664 Sub BlendEnable(enable As GLboolean)
1665 If enable Then
1666 glEnable(GL_BLEND)
1667 Else
1668 glDisable(GL_BLEND)
1669 End If
1670 End Sub
1671
1672 Function BlendDestinationFactor() As GLenum
1673 Dim dfactor As GLenum
1674 glGetIntegerv(GL_BLEND_DST,VarPtr(dfactor))
1675 Return dfactor
1676 End Function
1677 Sub BlendDestinationFactor(dfactor As GLenum)
1678 Dim sfactor As GLenum
1679 glGetIntegerv(GL_BLEND_SRC,VarPtr(sfactor))
1680 glBlendFunc(sfactor,dfactor)
1681 End Sub
1682
1683 Function BlendSourceFactor() As GLenum
1684 Dim sfactor As GLenum
1685 glGetIntegerv(GL_BLEND_SRC,VarPtr(sfactor))
1686 Return sfactor
1687 End Function
1688 Sub BlendSourceFactor(sfactor As GLenum)
1689 Dim dfactor As GLenum
1690 glGetIntegerv(GL_BLEND_DST,VarPtr(dfactor))
1691 glBlendFunc(sfactor,dfactor)
1692 End Sub
1693
1694 Function CullFaceEnable() As GLboolean
1695 Dim cull As GLboolean
1696 glGetBooleanv(GL_CULL_FACE,VarPtr(cull))
1697 Return cull
1698 End Function
1699 Sub CullFaceEnable(enable As GLboolean)
1700 If enable Then
1701 glEnable(GL_CULL_FACE)
1702 Else
1703 glDisable(GL_CULL_FACE)
1704 End If
1705 End Sub
1706
1707 Function CullFaceMode () As GLenum
1708 Dim mode As GLenum
1709 glGetIntegerv(GL_CULL_FACE_MODE,VarPtr(mode))
1710 Return mode
1711 End Function
1712 Sub CullFaceMode(mode As GLenum)
1713 glCullFace(mode)
1714 End Sub
1715
1716 Function DepthTestEnable () As GLboolean
1717 Dim depth As GLboolean
1718 glGetBooleanv(GL_DEPTH_TEST,VarPtr(depth))
1719 Return depth
1720 End Function
1721 Sub DepthTestEnable(enable As GLboolean)
1722 If enable Then
1723 glEnable(GL_DEPTH_TEST)
1724 Else
1725 glDisable(GL_DEPTH_TEST)
1726 End If
1727 End Sub
1728
1729 Function DepthFunction () As GLenum
1730 Dim func As GLenum
1731 glGetIntegerv(GL_DEPTH_FUNC,VarPtr(func))
1732 Return func
1733 End Function
1734 Sub DepthFunction(func As GLenum)
1735 glDepthFunc(func)
1736 End Sub
1737
1738 Function DepthBufferWritable() As GLboolean
1739 Dim writable As GLboolean
1740 glGetBooleanv(GL_DEPTH_WRITEMASK,VarPtr(writable))
1741 Return writable
1742 End Function
1743 Sub DepthBufferWritable(enable As GLboolean)
1744 If enable Then
1745 glDepthMask(GL_DEPTH_WRITEMASK)
1746 Else
1747 glDepthMask(GL_DEPTH_WRITEMASK)
1748 End If
1749 End Sub
1750
1751 Function DitherEnable() As GLboolean
1752 Dim dither As GLboolean
1753 glGetBooleanv(GL_DITHER,VarPtr(dither))
1754 Return dither
1755 End Function
1756 Sub DitherEnable(enable As GLboolean)
1757 If enable Then
1758 glEnable(GL_DITHER)
1759 Else
1760 glDisable(GL_DITHER)
1761 End If
1762 End Sub
1763
1764 Function FogEnable () As GLboolean
1765 Dim fog As GLboolean
1766 glGetBooleanv(GL_FOG,VarPtr(fog))
1767 Return fog
1768 End Function
1769 Sub FogEnable(enable As GLboolean)
1770 If enable Then
1771 glEnable(GL_FOG)
1772 Else
1773 glDisable(GL_FOG)
1774 End If
1775 End Sub
1776
1777 Function FogMode() As GLenum
1778 Dim mode As GLenum
1779 glGetIntegerv(GL_FOG_MODE,VarPtr(mode))
1780 Return mode
1781 End Function
1782 Sub FogMode(mode As GLenum)
1783 glFogi(GL_FOG_MODE,mode)
1784 End Sub
1785
1786 Function FogColor() As Color4f
1787 Dim ret As Color4f
1788 glGetFloatv(GL_FOG_COLOR,VarPtr(ret.rgba))
1789 Return ret
1790 End Function
1791 Sub FogColor(fcolor As Color4f)
1792 glFogfv(GL_FOG_COLOR,VarPtr(fcolor.rgba))
1793 End Sub
1794
1795 Function FogDensity() As GLfloat
1796 Dim density As GLfloat
1797 glGetFloatv(GL_FOG_DENSITY,density)
1798 Return density
1799 End Function
1800 Sub FogDensity(density As GLfloat)
1801 glFogf(GL_FOG_DENSITY,density)
1802 End Sub
1803
1804 Function FogStart() As GLfloat
1805 Dim fstrat As GLfloat
1806 glGetFloatv(GL_FOG_START,fstrat)
1807 Return fstrat
1808 End Function
1809 Sub FogStart(fstrat As GLfloat)
1810 glFogf(GL_FOG_START,fstrat)
1811 End Sub
1812
1813 Function FogEnd() As GLfloat
1814 Dim fend As GLfloat
1815 glGetFloatv(GL_FOG_END,fend)
1816 Return fend
1817 End Function
1818 Sub FogEnd(fend As GLfloat)
1819 glFogf(GL_FOG_END,fend)
1820 End Sub
1821
1822 Function Lighting() As GLboolean
1823 Dim lighting As GLboolean
1824 glGetBooleanv(GL_LIGHTING,VarPtr(lighting))
1825 Return lighting
1826 End Function
1827 Sub Lighting(enable As GLboolean)
1828 If enable Then
1829 glEnable(GL_LIGHTING)
1830 Else
1831 glDisable(GL_LIGHTING)
1832 End If
1833 End Sub
1834
1835 Function LineSmoothEnable() As GLboolean
1836 Dim smooth As GLboolean
1837 glGetBooleanv(GL_LINE_SMOOTH,VarPtr(smooth))
1838 Return smooth
1839 End Function
1840 Sub LineSmoothEnable(enable As GLboolean)
1841 If enable Then
1842 glEnable(GL_LINE_SMOOTH)
1843 Else
1844 glDisable(GL_LINE_SMOOTH)
1845 End If
1846 End Sub
1847
1848 Function LogicOpEnable() As GLboolean
1849 Dim logic As GLboolean
1850 glGetBooleanv(GL_COLOR_LOGIC_OP,VarPtr(logic))
1851 Return logic
1852 End Function
1853 Sub LogicOpEnable(enable As GLboolean)
1854 If enable Then
1855 glEnable(GL_COLOR_LOGIC_OP)
1856 Else
1857 glDisable(GL_COLOR_LOGIC_OP)
1858 End If
1859 End Sub
1860
1861 Function LogicOpCode() As GLenum
1862 Dim code As GLenum
1863 glGetFloatv(GL_COLOR_LOGIC_OP_MODE,code)
1864 Return code
1865 End Function
1866 Sub LogicOpCode(code As GLenum)
1867 glLogicOp(code)
1868 End Sub
1869
1870 Function PointSmoothEnable() As GLboolean
1871 Dim smooth As GLboolean
1872 glGetBooleanv(GL_POINT_SMOOTH,VarPtr(smooth))
1873 Return smooth
1874 End Function
1875 Sub PointSmoothEnable(enable As GLboolean)
1876 If enable Then
1877 glEnable(GL_POINT_SMOOTH)
1878 Else
1879 glDisable(GL_POINT_SMOOTH)
1880 End If
1881 End Sub
1882
1883 Function PolygonSmoothEnable() As GLboolean
1884 Dim smooth As GLboolean
1885 glGetBooleanv(GL_POLYGON_SMOOTH,VarPtr(smooth))
1886 Return smooth
1887 End Function
1888 Sub PolygonSmoothEnable(enable As GLboolean)
1889 If enable Then
1890 glEnable(GL_POLYGON_SMOOTH)
1891 Else
1892 glDisable(GL_POLYGON_SMOOTH)
1893 End If
1894 End Sub
1895
1896 Function ReferenceAlpha() As GLclampf
1897 Dim ref As GLclampf
1898 glGetFloatv(GL_ALPHA_TEST_REF,VarPtr(ref))
1899 Return ref
1900 End Function
1901 Sub ReferenceAlpha(ref As GLclampf)
1902 Dim func As GLenum
1903 glGetIntegerv(GL_ALPHA_TEST_FUNC,VarPtr(func))
1904 glAlphaFunc(func,ref)
1905 End Sub
1906
1907 Function ShadeModel() As GLenum
1908 Dim mode As GLenum
1909 glGetIntegerv(GL_SHADE_MODEL,VarPtr(mode))
1910 Return mode
1911 End Function
1912 Sub ShadeModel(mode As GLenum)
1913 glShadeModel(mode)
1914 End Sub
1915End Class
1916
1917
1918Enum ColorType
1919 RgbColor=0
1920 RgbaColor=0
1921 IndexColor
1922End Enum
1923
1924Enum BufferType
1925 SingleBuffer=0
1926 DoubleBuffer
1927End Enum
1928
1929Enum ClearBuffer
1930 DepthBufferBit = &H00000100
1931 AccumBufferBit = &H00000200
1932 StencilBufferBit = &H00000400
1933 ColorBufferBit = &H00004000
1934End Enum
1935
1936Enum PrimitiveMode
1937 Points = &H0000
1938 Lines = &H0001
1939 LineLoop = &H0002
1940 LineStrip = &H0003
1941 Triangles = &H0004
1942 TriangleStrip = &H0005
1943 TriangleFan = &H0006
1944 Quads = &H0007
1945 QuadStrip = &H0008
1946 Polygon = &H0009
1947End Enum
1948
1949Class RenderingContext
1950Public /* Composiotion */
1951 Material As MaterialManager
1952 RenderState As RenderStateManager
1953 Transform As TransformMatrix
1954 Lights As LightsCollection
1955
1956Public /* Constructor */
1957 Sub RenderingContext()
1958 Dim hrc As HGLRC
1959 hrc=wglGetCurrentContext()
1960 If hrc Then
1961 wglMakeCurrent(NULL,NULL)
1962 wglDeleteContext(hrc)
1963 End If
1964
1965 Material = New MaterialManager()
1966 RenderState = New RenderStateManager()
1967 Transform = New TransformMatrix()
1968 Lights = New LightsCollection()
1969 End Sub
1970 Sub RenderingContext(hdc As HDC, ByRef pfd As PIXELFORMATDESCRIPTOR)
1971 RenderingContext()
1972
1973 Dim pf As Long
1974 pf=ChoosePixelFormat(hdc,pfd)
1975 If pf=0 Then
1976 MessageBox(NULL,"Choose Pixel Format failed","error",MB_OK)
1977 Exit Sub
1978 End If
1979 If SetPixelFormat(hdc,pf,pfd)=FALSE Then
1980 MessageBox(NULL,"Set Pixel Format failed","error",MB_OK)
1981 Exit Sub
1982 End If
1983
1984 Dim hrc As HGLRC
1985 hrc=wglCreateContext(hdc)
1986 wglMakeCurrent(hdc,hrc)
1987 End Sub
1988 Sub RenderingContext(hdc As HDC, ctype As ColorType, btype As BufferType)
1989 RenderingContext()
1990
1991 Dim pfd As PIXELFORMATDESCRIPTOR
1992 pfd.nSize=SizeOf(PIXELFORMATDESCRIPTOR) As Word
1993 pfd.nVersion=GL_VERSION_1_1
1994 If btype=BufferType.DoubleBuffer Then
1995 pfd.dwFlags or=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
1996 Else
1997 pfd.dwFlags or=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL
1998 End If
1999 If ctype=ColorType.RgbColor Then
2000 pfd.iPixelType=PFD_TYPE_RGBA
2001 Else
2002 pfd.iPixelType=PFD_TYPE_COLORINDEX
2003 End If
2004 pfd.cColorBits=24
2005 pfd.cRedBits=0
2006 pfd.cRedShift=0
2007 pfd.cGreenBits=0
2008 pfd.cGreenShift=0
2009 pfd.cBlueBits=0
2010 pfd.cBlueShift=0
2011 pfd.cAlphaBits=0
2012 pfd.cAlphaShift=0
2013 pfd.cAccumBits=0
2014 pfd.cAccumRedBits=0
2015 pfd.cAccumGreenBits=0
2016 pfd.cAccumBlueBits=0
2017 pfd.cAccumAlphaBits=0
2018 pfd.cDepthBits=32
2019 pfd.cStencilBits=0
2020 pfd.cAuxBuffers=0
2021 pfd.iLayerType=PFD_MAIN_PLANE
2022 pfd.bReserved=0
2023 pfd.dwLayerMask=0
2024 pfd.dwVisibleMask=0
2025 pfd.dwDamageMask=0
2026 RenderingContext(hdc,pfd)
2027 End Sub
2028 Sub RenderingContext(hdc As HDC)
2029 RenderingContext(hdc As HDC, ColorType.RgbColor, BufferType.DoubleBuffer)
2030 End Sub
2031
2032Public /* Destructor */
2033 Sub ~RenderingContext()
2034 Dim hrc As HGLRC
2035 hrc=wglGetCurrentContext()
2036 wglMakeCurrent(NULL,NULL)
2037 wglDeleteContext(hrc)
2038 End Sub
2039
2040Public /* Method */
2041 Sub Begin(mode As GLenum)
2042 glBegin(mode)
2043 End Sub
2044 Sub Begin(mode As PrimitiveMode)
2045 glBegin(mode)
2046 End Sub
2047 Sub Clear(mask As GLbitfield)
2048 glClear(mask)
2049 End Sub
2050 Sub Clear(mask As ClearBuffer)
2051 glClear(mask)
2052 End Sub
2053
2054 Sub ClearAccum(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
2055 glClearAccum(red, green, blue, alpha)
2056 End Sub
2057 Sub ClearAccum(color As Color4f)
2058 glClearAccum(color.R, color.G, color.B, color.A)
2059 End Sub
2060 Sub ClearColor(red As GLclampf, green As GLclampf, blue As GLclampf, alpha As GLclampf)
2061 glClearColor(red, green, blue, alpha)
2062 End Sub
2063 Sub ClearColor(color As Color4f)
2064 glClearColor(color.R, color.G, color.B, color.A)
2065 End Sub
2066 Sub ClearDepth(depth As GLclampd)
2067 glClearDepth(depth)
2068 End Sub
2069 Sub ClearIndex(c As GLfloat)
2070 glClearIndex(c)
2071 End Sub
2072 Sub ClearStencil(s As GLint)
2073 glClearStencil(s)
2074 End Sub
2075
2076 Sub Color(red As GLdouble, green As GLdouble, blue As GLdouble)
2077 glColor3d(red,green,blue)
2078 End Sub
2079 Sub Color(red As GLdouble, green As GLdouble, blue As GLdouble, alpha As GLdouble)
2080 glColor4d(red,green,blue,alpha)
2081 End Sub
2082 Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat)
2083 glColor3f(red,green,blue)
2084 End Sub
2085 Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
2086 glColor4f(red,green,blue,alpha)
2087 End Sub
2088 Sub Color(c As Color3f)
2089 glColor3fv(VarPtr(c.rgb) As *Single)
2090 End Sub
2091 Sub Color(c As Color4f)
2092 glColor4fv(VarPtr(c.rgba) As *Single)
2093 End Sub
2094 Sub Color(c As Color3d)
2095 glColor3dv(VarPtr(c.rgb) As *Double)
2096 End Sub
2097 Sub Color(c As Color4d)
2098 glColor4dv(VarPtr(c.rgba) As *Double)
2099 End Sub
2100
2101 Sub DrawPrimiteve()
2102 End Sub
2103
2104 Sub End()
2105 glEnd()
2106 End Sub
2107
2108 Sub Finish()
2109 glFinish()
2110 End Sub
2111 Sub Flush()
2112 glFlush()
2113 End Sub
2114
2115 Function GenerateTexures() As GLint
2116 glGenTextures()
2117 End Function
2118
2119 Sub MatrixMode(mode As GLenum)
2120 glMatrixMode(mode)
2121 End Sub
2122
2123 Sub Present()
2124 SwapBuffers(wglGetCurrentDC())
2125 End Sub
2126 Sub Present(hdc As HDC)
2127 SwapBuffers(hdc)
2128 End Sub
2129
2130 Sub PopMatrix()
2131 glPopMatrix()
2132 End Sub
2133
2134 Sub PushMatrix()
2135 glPushMatrix()
2136 End Sub
2137
2138 Sub Vertex(x As GLdouble, y As GLdouble)
2139 glVertex2d(x,y)
2140 End Sub
2141 Sub Vertex(x As GLdouble, y As GLdouble, z As GLdouble)
2142 glVertex3d(x,y,z)
2143 End Sub
2144 Sub Vertex(x As GLdouble, y As GLdouble, z As GLdouble, w As GLdouble)
2145 glVertex4d(x,y,z,w)
2146 End Sub
2147 Sub Vertex(x As GLfloat, y As GLfloat)
2148 glVertex2f(x,y)
2149 End Sub
2150 Sub Vertex(x As GLfloat, y As GLfloat, z As GLfloat)
2151 glVertex3f(x,y,z)
2152 End Sub
2153 Sub Vertex(x As GLfloat, y As GLfloat, z As GLfloat, w As GLfloat)
2154 glVertex4f(x,y,z,w)
2155 End Sub
2156
2157 Sub Viewport(x As GLint, y As GLint, width As GLsizei, height As GLsizei)
2158 glViewport(x, y, width, height)
2159 End Sub
2160End Class
2161
2162#endif
Note: See TracBrowser for help on using the repository browser.