Direct Draw Programming
The next thing I started to do is start to experiment with a bit of Direct X coding. I have started with Direct Draw preferring to get an idea of the hard way to do things before starting to use Direct 3D. I have used a set of Data Structures to hold the 3D objects based loosely on the Structures used in the C++ section above. I have modified quite extensively the Direct Draw Example 1 provided with Direct X 6.0. I have also borrowed bits of code from the Flip 2D example also provided with Direct X 6.0. I have already grown to love the Flat memory model. The Flat memory model is a memory model unlike any other C++ model. Instead of having small areas for code, stack and so forth, you can now just do what you like with memory and let Windows 95 sort out the rest.To Download the executable click here.
My latest Direct Draw coding has been rewriting various areas of the code used in the previous program. I have now implemented a new Class that contains all the Direct Draw specific code. Instead of forcing myself to use 8-bit colour I set up a system where I use colour masks instead. This means the code now works in 8-bit, 16-bit, 24-bit or 32-bit colour. There is a loss of detail in certain modes, especially 8-bit, but the code is now totally system independent ... I hope ( It works on an AMD K6-2 300 with an S3 Savage 3D or an ATI Rage Pro AGP as well as a Pentium 200 running an ATI Rage PCI).td->SetRenderType(DDZBuffer + DDGouraud);
The above is the current definition but for flat shading you need only change it to -
td->SetRenderType(DDZBuffer);
for fogging to -
td->SetRenderType(DDZBuffer + DDFog);
and for texture mapping to -
td->SetRenderType(DDZBuffer + DDTexture);
The keys are as follow -
A - Forward, Z - Back, Left Shift - Move Left, Right Shift - Move Right, S - Move Up, C - Move Down
Use the mouse to look a round.
Again it is a Visual C++ 5.0 workspace so to download the workspace click here.
To download the executable click here.