You are on page 1of 19

DirectX

Hannu Järvinen
Kati Niiranen

T-111.5350 Multimedia Programming


Table of contents
 Introduction
 History of DirectX
 DirectX components
 DirectX Graphics – DirectDraw
 DirectX Graphics - Direct3D
 DirectInput
 DirectPlay
 DirectSound - DirectSound3D
 DirectMusic
 DirectSetup
 DirectX Media
 DirectX Media Objects
 Future of DirectX
 Any questions?
Introduction
 Collection of APIs
 Multimedia and gaming purposes
 Developed by Microsoft
 Used on Microsoft platforms (Windows,
Xbox, Xbox 360)
History of DirectX
 Programmers continued to make games
to DOS
 Microsoft wanted games for Windows
-> DirectX development was started
 Became very popular among game
developers
 Version 9.0 in use, version 10 will be
published with Windows Vista
DirectX components
 First only DirectDraw, DirectSound,
DirectInput, and DirectPlay in Games SDK
 Nowadays 9 components
 DirectX Graphics - DirectDraw
 DirectX Graphics - Direct3D
 DirectInput
 DirectPlay
 DirectSound - DirectSound3D
 DirectMusic
 DirectSetup
 DirectX Media
 DirectX Media Objects
DirectX Graphics - DirectDraw

 2D API
 Full screen /windowed mode
 Direct manipulation of display memory
 Not a high-level API for graphics
DirectX Graphics - Direct3D

 3D API
 First version with DirectX 2.0
 Full screen /windowed mode
 New versions support the latest
technology available on 3D graphics
cards
 Competitor to OpenGL
Direct3D (DirectX 9.0) Code Sample
void loadTexture( void )
{
D3DXCreateTextureFromFile(
g_pd3dDevice, "woodfloor.bmp",
&g_pTexture );

g_pd3dDevice->SetSamplerState(0,
D3DSAMP_MINFILTER,
D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0,
D3DSAMP_MAGFILTER,
D3DTEXF_LINEAR);
}

Example source: http://www.codesampler.com/dx9src/dx9src_3.htm#dx9_texture


DirectInput

 Collects input from the user


 Keyboard, mouse, joystick etc..
 XInput
 New XInput API introduced with Xbox 360
 For next generation controllers
 Much easier to use than DirectInput
DirectInput Keyboard Handling Code Sample
Imports Microsoft.DirectX
Imports Microsoft.DirectX.DirectInput.CooperativeLevelFlags
Imports Microsoft.DirectX.DirectInput

Public Class Form1


Inherits System.Windows.Forms.Form

Dim KB As New DirectInput.Device(DirectInput.SystemGuid.Keyboard)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


KB.SetCooperativeLevel(Me, Background Or NonExclusive)
Me.Show()
KB.Acquire()
End Sub

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)


Handles MyBase.Closing
KB.Dispose()
KB = Nothing
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick


Dim State As DirectInput.KeyboardState
State = KB.GetCurrentKeyboardState
If State.Item(Key.Escape) Then Me.Close()
If State.Item(Key.A) Then Label1.Text &= "a"
If State.Item(Key.B) Then Label1.Text &= "b"
If State.Item(Key.C) Then Label1.Text &= "c"
End Sub
End Class

Example Source: http://gpwiki.org/index.php/DirectX:DirectInput:Tutorials:VBNET:DX9:Keyboard_Handling


DirectPlay

 For network communication of games


 Three primary interfaces
 IDirectPlay8Server
 IDirectPlay8Client
 IDirectPlay8Peer
 Will not be used after Windows XP
 Replaced by Xbox Live technology
DirectSound - DirectSound3D

 Enables application to produce sounds


 Provides also effects such as echo,
reverb, and flange
 DirectSound3D first came in 1996 with
DirectX 3
 DirectSound3D plays sounds in 3D
DirectMusic

 Higher-level than DirectSound


 Support for dynamic soundtracks
 DirectMusic first came in 1999 with
DirectX 6.1
DirectSetup

 Not a real API


 Very simple library of functions
 For installing DirectX
 Supports checking the existing version
number of DirectX
DirectShow
 Was used for media streaming applications
 Was first part of the DirectX Media
component
 Later DirectX Media was deprecated and
DirectShow was adopted by DirectX
 In 2005 DirectShow was removed from
DirectX and placed as a part of Microsoft
Platform SDK
DirectX Media Objects

 DMOs are COM-based multimedia and


data-streaming components
 Like DirectShow filters but simpler
 Take input data to produce output data
which are multimedia framework
components
Future of DirectX
 Version 10 coming with Windows Vista
 Components will keep changing
 DirectInput replaced with XInput
 DirectSound replaced with XACT
 DirectShow replaced with Media Foundation
 Etc..
 DirectMusic will probably not be changed
Any questions?
References
 "An Introduction to DirectX":
http://people.msoe.edu/~barnicks/courses/cs384/papers9899/veldhuizen.pdf
 "Games Programming with Java and Java 3D":
http://fivedots.coe.psu.ac.th/~ad/jg/intro/
 "The Direct3D 10 system":
http://doi.acm.org/10.1145/1141911.1141947
 "What 3D API for Java should I use and why?":
http://doi.acm.org/10.1145/258734.258905
 "A multi-Api course in computer graphics":
http://portal.acm.org/citation.cfm?id=378669&coll=ACM&dl=ACM&CFID=24391
61&CFTOKEN=22276391
 Official DirectX documentation (Microsoft):
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/dnanchor/html/anch_DirectX.asp
 DirectX From Wikipedia, the free encyclopedia:
http://en.wikipedia.org/wiki/DirectX

You might also like