nearlogic.com

a programmer’s blog

Adding the Third Dimension

I’ve been looking through my code to find something worth posting. And I think I’ll start with OpenGL in Classic VB (6.0). This is not often done, but is easy to do, and works very well. All that is needed to start typing OpenGL code is this type library by Patrice Scribe. If you are new to OpenGL, you can download this ‘template’ project that demonstrates how to create OpenGL windows in a Picturebox control. You can use this to create multiple Rendering Contexts in a single desktop application, or use a single control to create a fullscreen OpenGL program.

I have also added a couple other classes that I use regularly in my 3D work. One is a coordinate class that can be used to keep track of an objects position, orientation and motion. The other is a very basic color class that can convert between VB colors and OpenGL colors.

This sample project will create two OpenGL windows, and display a double-helix in the top. Both have axes drawn at the origin. You can use the mouse to rotate about the origin with the left mouse button. Holding down the right button, and moving the mouse up and down will zoom in and out.

I’ll dig up some more code later that use these classes, and others, in some interesting ways. OpenGL is very powerful, but it is also somewhat basic…. it takes time to build a good foundation before you start to create a complex graphical app.

No comments yet. Be the first.

Leave a reply

Banner