Please support our sponsor:
DirectX4VB.Com - All You Need For Multimedia Visual Basic Programming

Main Site Links Resources Tutorials
News VB Gaming Code Downloads DirectX 7
Contact Webmaster VB Programming Product Reviews DirectX 8
  General Multimedia Articles DirectX 9
      Miscellaneous

 

Retained Mode: Putting it all together
By: Jack Hoxley
Written: June 2000

Download: RM_Complete.Zip (103kb)


There is one inherant problem with reading lots of tutorials - you can learn every aspect of a subject, yet still not be able to create a proper program. This feature is less of a tutorial and more of a guide. In it I will show you how to use your retained mode knowledge to create a simple program.

The program in particular will be a logo program. The idea behind it is to create a titlescreen type effect that stands out from the crowd. It will use the following features:

  1. Enumeration - to select hardware or software
  2. Loading in a primative to hold our logo
  3. Loading and using a texture as our logo
  4. Using rotation and movement to modify our primative
  5. Using dramatic lighting to enhance the graphics of our logo screen.

Why use retained mode for this? Retained mode is simple; this project will take half as much time to create than if I had written it for immediate mode. As well as this, retained mode isn't really appropriate for games (the other possible project) any more - If I were to write a game it would be in immediate mode.

The first part that the user sees is an options dialog; this is quite common in games, it allows the user to select various options to suit their computer setup. Mine looks like this:

This is a screen shot from my Pentium 166, which only supports software rendering; normally Hardware would also appear in the combo box; and be the default selection. Then there is detail settings. This is nothing to do with code; when I built the objects in 3D Studio Max I made two identical versions; one with a high poygon count; the other with a low polygon count, this is taken to the extreme here, as you can very easily tell the difference in the models - normally the difference would be very subtle. The third combo box deals with the resolution. The higher the resolution the lower the frame rate, and the higher the resolution the better quality the image is. The code automatically picks out resolutions between 600x400 and 1024x768 - as we dont want any of the weird low resolutions. It also stops any 8bit colour modes coming through - as some graphics cards have problems rendering in 8bit colour (and it looks really bad any way).

The next two screen shots are from the actual program itself:

The first picture is the low-detail version; and you can quite easily see that the torus's (donuts) are more angular, whereas the lower picture is the high-detail version and quite clearly looks better, and has noticably smooth curves. The colour is different on each one because the light changes - it fades through the colours. This can only be understood/seen by running the program.

The actual movement of the logo is done through rotation. It consistes of a central object with the logo as a texture, and it has 4 torus's rotating around it. All four torus's are identical, and come from the same file (keeps down file size), but each one is slightly bigger than the previous one. They work in pairs, the first and third, and the second and fourth. The first pair rotates vertically, and the second pair rotates horizontally. This creates an interesting effect, similiar to those little models you find on peoples desks...

You can downlaod the program from the top of the page, or from the downloads page. Please note the notice on the options dialog - Clone Software exists, so you cannot copy the name.

DirectX 4 VB © 2000 Jack Hoxley. All rights reserved.
Reproduction of this site and it's contents, in whole or in part, is prohibited,
except where explicitly stated otherwise.
Design by Mateo
Contact Webmaster
This site is hosted by Exhedra Solutions, Inc., the parent company of RentACoder.com and PlanetSourceCode.com