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