source: Include/abgl.ab@ 117

Last change on this file since 117 was 117, checked in by NoWest, 17 years ago

Vector関連のクラスで原因不明のバグが発生中。。。

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