|
VB
& OpenGL
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Introduction |
||
Everybody who writes code dealing with graphics in Windows environment is sometimes confused by its power. One of solutions is rendering graphics directly, not via Windows functions. There are two technologies for this purpose - OpenGL or DirectX. Both of them can deal with 3D objects, shade them, texture them and much more. I don't want compare both these technologies, every of them has group of pleased users. By my opinion, OpenGL is more intuitive and in addition, no extra libraries are necessary - these basic (opengl32.dll, glu32.dll, glut32.dll) are shipped with operating system since Windows 95 OSR2 and contain functions corresponding to OpenGL 1.1 specification. If graphic card support newer version of OpenGL, proper libraries are updated in process of driver's installation. In Internet there are no many examples how to deal with OpenGL in Visual Basic, so I am bringing here several ones to show you, that is not such complicated as it may seems. I have seen many source codes for VB, which were converted from C, C++ or Delphi only, without utilize posibilities which VB offers. I hope that my programs are better. Visual Basic 6.0 It is not very comfortable to declare every function, which is need to use in program. Fortunately, there is better way how to do it - using OpenGL type library by Patrice Scribe. You can download it from http://home.pacific.net.hk/~edx/tlb.htm. This library supports OpenGL 1.2 specification. Copy it into system folder and then register it: Menu Start>Run... and into text box type: regsvr32 "C:\Windows\System\vbogl.tlb" where path may vary. In VB you must add this library into references: menu Project>References... and in list of items check VB OpenGL API 1.2 (ANSI). Visual Basic .NET Like VB6, VB.NET can simplify declaring functions too. There are several libraries for this purpose. Probably best-known is CsGL. It is used in many examples, but its development was stopped. It was replaced by Tao library (http://www.taoframework.com/), which implements OpenGL 1.5 and many other extensions. Copy it to system folder, add reference and you can write the first program. Tao can be used like control too. It bring us simplification in initialization etc., but we loose a bit of power. And now several examples:
|
||
| Magic triangle | ||
It is simple example showing us basic skeleton for working with OpenGL. What cool effect and what easy! Source code VB6, VB.NET (Tao), VB.NET (Tao_control).
|
||
| Knot (Stencil Buffer) | ||
|
||
| Tunnel | ||
|
||
| Saturn | ||
|
||
| MetaBalls | ||
|
||
| Planisphere | ||
|
||
| Couple of nice examples for VB6 utilising modern technologies can be found here: http://www.pauldahuach.com.ar/program_en.htm | ||