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