Platform SDK: DirectX

Creating DirectX Objects

[C++]

This topic pertains only to applications written in Visual Basic.

[Visual Basic]

Every DirectX for Visual Basic application must have a DirectX7 object. This is the parent object whose methods are used to create the principal objects for each DirectX component. DirectX7 also has many other methods, such as methods to perform calculations for Direct3D.

The DirectX7 object is obtained simply by declaration as a new object, as in the following example:

Public gObjDX As New DirectX7

To create a DirectX component such as DirectSound, you must first declare a variable for the object, and then set it to a created object by calling the appropriate DirectX7 creation method, as in the following example:

Public gObjDSound As DirectSound
Set gObjDSound = DirectX7.DirectSoundCreate

The following objects representing the principal components of DirectX are created by using methods of DirectX7:

Component Objects DirectX7 Creation Method
Direct3D Retained Mode Direct3DRM Direct3DRMCreate
DirectDraw DirectDraw7 DirectDrawCreate
DirectInput DirectInput DirectInputCreate
DirectMusic DirectMusicComposer DirectMusicComposerCreate
  DirectMusicLoader DirectMusicLoaderCreate
DirectMusicPerformance DirectMusicPerformanceCreate
DirectPlay DirectPlay4 DirectPlayCreate
  DirectPlayLobby DirectPlayLobbyCreate
DirectSound DirectSound DirectSoundCreate
  DirectSoundCapture DirectSoundCaptureCreate

The other principal DirectX component, Direct3D Immediate Mode, is represented by a Direct3D7 object that must be obtained by calling the DirectDraw7.GetDirect3D method.