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