Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
96 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:


 the Source

 The Application

 Cleaning Up

 Printable version


  The Series

 The Basics
 First Steps to

 Building Worlds
 With X Files


Compiling The Source

Get the source here.

In our first example, we will take a look at the basic functionality provided by the framework and at one of the most simplified programs I can think of to use it. We will see a texture thrown at the back of a window and a timer, which shows the frames per seconds. This little program will work windowed and fullscreen. Press Alt-F4 to switch between these modes. F1 will show you the about box. F2 will give you a selection of useable drivers and ESC will shutdown the app.

First let's talk about the files you need to compile the program. The best place to copy the files is in your Direct3D Immediate Mode source file Directory of the DirectX 7 SDK, which has to be installed. On my computer that would be for tex1: D:\mssdk\samples\Multimedia\D3DIM\src\tex7_1.

There are only four program files:

  • tex1.cpp: the main file
  • winmain.rc: the resource file (Menu, Accelerator, Icon information etc.)
  • resource.h: header of winmain.rc
  • directx.ico: the icon you can see if the program is minimized or if maximized in the left corner of the title of the window.

If you'd like to compile everything, you have to link it with the following *.lib files:
ddraw.lib dxguid.lib ..\..\lib\d3dframe.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib winmm.lib

d3dframe.lib is the static library which holds the Direct3D 7 Framework. You can find the Framework source in the D3Dframe directory in D:\mssdk\samples\Multimedia\D3DIM\src\D3DFrame. We will walk now through a high-level view of the Framework to understand and use the Direct3D 7 Framework. The Framework consists of seven *.cpp files. These files encapsulate the basic functionality you need to start programming a Direct3D game.

  • d3dapp.cpp exposes the application interface used for samples
  • d3dframe.cpp provides the framework that the application interface (in tex1.cpp) uses "under the covers"
  • d3denum.cpp contains enumeration support for drivers, devices, and modes
  • d3dtextr.cpp supplies texture support
  • d3dfile.cpp furnishes x-file support
  • d3dmath.cpp delivers math utility functions
  • d3dutil.cpp is a catchall for whatever miscellaneous useful functions remain

The d3dApp.cpp module contains the class CD3DApplication. This class publishes the interface for sample programs, in the file D3Dapp.h. It provides seven functions:

virtual HRESULT OneTimeSceneInit() { return S_OK; } virtual HRESULT InitDeviceObjects() { return S_OK; } virtual HRESULT DeleteDeviceObjects() { return S_OK; } virtual HRESULT Render() { return S_OK; } virtual HRESULT FrameMove( FLOAT ) { return S_OK; } virtual HRESULT RestoreSurfaces() { return S_OK; } virtual HRESULT FinalCleanup() { return S_OK; }

These are the functions we'll use in tex1.cpp to create our D3D app. They could be called the "public interface" for the Direct3D IM Framework. Now, let's dive into the source.

Next : The Application Class