Logo
Produkte
Planisphere
Constellation Editor
Dir2Mht (en)
Anleitungen
VB & OpenGL (en)
Other VB stuff (en)
Andere
Spenden
Kontakt

 

VB & OpenGL OpenGL


[Èesky]

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.randyridge.com/Tao/), 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).

Magic triangle

Knot (Stencil Buffer)

KnotMore complex example than previous. Using mathematical functions is generated 3D object. In next step it is rendered as solid body, but in small window we can see its wireframed model. Source code VB6, VB.NET (Tao), VB.NET (Tao_control).

Tunnel

TunnelThis example show us working with textures - loading texture from external file, modelling of 3D object, generating texture coordinates, rendering texture on object's surface etc. Source code VB6.

Saturn

SaturnVB6 source code for simulation this beautiful planet. Rings are provided with transparency so they look very realistic.

MetaBalls

MetaballsCool effect, but little difficult to understand, how it works. There are many mathematical computations, but final rendering is quite easy. As in VB there is no way to use pointers, we lose a bit of power. I recommend to test it on powerfull machines (1.5 GHz+) only. Source code VB6.

Planisphere

PlanisphereHandy tool for newbies in astronomy. It is written in VB6 using OpenGL. This is compiled version only, without source code. Additional information you can find here.

 

OpenGL

astronomy.cz
CESNET

 
Copyright © 2003-2004, Jan Tosovsky, Deutsche Übersetzung von h.c. greier