1 / 27

Introduction to DirectX Programming

Introduction to DirectX Programming. Dongho Kim February 12, 2002. What is DirectX. 2D/3D graphics / multimedia API Made and maintained by Microsoft Designed for Game and Multimedia Programming Works only on MS Windows platform 95/98/ME/2000/XP Old version for Windows NT.

tessa
Download Presentation

Introduction to DirectX Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction toDirectX Programming Dongho Kim February 12, 2002

  2. What is DirectX • 2D/3D graphics / multimedia API • Made and maintained by Microsoft • Designed for Game and Multimedia Programming • Works only on MS Windows platform • 95/98/ME/2000/XP • Old version for Windows NT © 2001 Dongho Kim, GWU Institute for Computer Graphics

  3. Versions of DirectX • First introduction in 1996 • Goal: Easy game programming under MS Windows • Current versions • DirectX 8.1 : Windows 95/98/ME/2000 (2001) • Built-in in Windows XP • DirectX 3 : Windows NT 4.0 • DirectX 9 : under beta test © 2001 Dongho Kim, GWU Institute for Computer Graphics

  4. Versions of DirectX (cont.) • Backward Compatible • Applications complied with older version should work with newer version © 2001 Dongho Kim, GWU Institute for Computer Graphics

  5. Components of DirectX • Direct3D • DirectDraw: integrated into Direct3D in DX 8 • DirectShow: integrated into Direct3D in DX 8 • DirectSound / DirectMusic • DirectInput • DirectPlay • DirectSetup © 2001 Dongho Kim, GWU Institute for Computer Graphics

  6. Comparison ofDirectX and OpenGL (1) • DirectX • Controlled by Microsoft; frequent updates • Many features for game programming • Sound, input, media stream, … • Non-core functionality such as file format reader (image and 3D model) • OpenGL • Controlled by OpenGL ARB; only a few updates • General purpose 2D/3D graphics API; 2D is weak © 2001 Dongho Kim, GWU Institute for Computer Graphics

  7. Comparison ofDirectX and OpenGL (2) • DirectX • Only Microsoft Windows platform; MMX, 3DNow • Rather difficult to learn • not many documentation; stick to MS documentations • OpenGL • Platform independent (Windows, Linux, Unix, Apple, …) • Rather easy to learn; many 3rd party documentations © 2001 Dongho Kim, GWU Institute for Computer Graphics

  8. DirectX 8.1 SDK • Installation © 2001 Dongho Kim, GWU Institute for Computer Graphics

  9. Using DirectX SDK (1) http://www.microsoft.com/directx • Include and Lib directories • Documentation • Samples • Utilities • Paths are included in Visual C++ automatically (DX8) © 2001 Dongho Kim, GWU Institute for Computer Graphics

  10. Using DirectX SDK (2) • Direct3DX library • Similar to GLU in OpenGL • Collection of useful functionalities • Math, Mesh, Shader, … • Interfaces starting with “ID3DX” • Functions starting with “D3DX” © 2001 Dongho Kim, GWU Institute for Computer Graphics

  11. Using DirectX SDK (3) • “Common” directory (DX8) • C++ source code • Not part of DirectX, but contains useful source codes • DirectX initialization, window creation, … • Most of the samples link with this part © 2001 Dongho Kim, GWU Institute for Computer Graphics

  12. Demo: DirectX 8.1 Samples • Most of the features are shown • Start your own project from a sample in DirectX SDK © 2001 Dongho Kim, GWU Institute for Computer Graphics

  13. COM(Component Object Model) • DirectX libraries are implemented as COM • COM object is a black box performing one or more tasks • Similar to C++ objects • Implemented as DLL • Stricter encapsulation • Not explicitly loaded • Supports many programming languages © 2001 Dongho Kim, GWU Institute for Computer Graphics

  14. Programming with COM • May be complex • But it is not so difficult • We do not make COM objects • We simply use COM objects • Interface is used to access the the functionality of COM objects • Class names start with I • Start from the samples with “Common” files © 2001 Dongho Kim, GWU Institute for Computer Graphics

  15. Example of COM instantiation IDirect3DDevice8 *g_pd3dDevice = NULL; ... if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, 3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ))) return E_FAIL; © 2001 Dongho Kim, GWU Institute for Computer Graphics

  16. Recommendations on how to start DirectX programming • Some knowledge on Windows Programming is required • Start with Newest version, DirectX 8.1 • Start from the SAMPLES in the SDK • Most of the examples are written without MFC • Mostly performance issues in games • Only some of them are written with MFC © 2001 Dongho Kim, GWU Institute for Computer Graphics

  17. Lecture from now on • Focus on Direct3D • Follow the tutorials in DX8.1 SDK • Tutorials do not use “Common” files, though • Samples using “Common” files © 2001 Dongho Kim, GWU Institute for Computer Graphics

  18. Tutorial 1: CreateDevice © 2001 Dongho Kim, GWU Institute for Computer Graphics

  19. Tutorial 2: Vertices © 2001 Dongho Kim, GWU Institute for Computer Graphics

  20. Tutorial 3: Matrices © 2001 Dongho Kim, GWU Institute for Computer Graphics

  21. Tutorial 4: Lights © 2001 Dongho Kim, GWU Institute for Computer Graphics

  22. Tutorial 5: Textures © 2001 Dongho Kim, GWU Institute for Computer Graphics

  23. Tutorial 6: Meshes © 2001 Dongho Kim, GWU Institute for Computer Graphics

  24. Sample: Billboard © 2001 Dongho Kim, GWU Institute for Computer Graphics

  25. Extras in SDK • X file exporter • 3D Studio MAX version 3 / 4 • Maya version 2.5 / 3.0 / 4.0 © 2001 Dongho Kim, GWU Institute for Computer Graphics

  26. Next week • Advanced features • Programmable shader • Vertex shader / Vertex program • Pixel shader / register combiner • Multi-texturing / Multi-pass texturing • Game specific topics • joystick, frame rate control, etc… © 2001 Dongho Kim, GWU Institute for Computer Graphics

  27. Bookmarks • http://www.microsoft.com/directx • microsoft.public.win32.programmer.directx • microsoft.public.directx • OpenGL vs DirectX comparison • http://www.xmission.com/~legalize/d3d-vs-opengl.html © 2001 Dongho Kim, GWU Institute for Computer Graphics

More Related