b29e7c914d4e3c91f93fedef2bedc595.ppt
- Количество слайдов: 46
A presentation on Direct. X® Alex Brill Emil Elazar Noam Monheit 1
Contents l What is Direct. X? l l l How Direct. X really works? l l l Architecture Direct 3 D in Details Direct. X Alternatives l l Historical Problem and it’s Solution Terminology Brief Components Description Direct. X Versions History Open. GL Advantages & Disadvantages or: “Why Direct. X”? Installation + SDK Demo + Code Examples 2
(What is Direct. X? (1 l The Problem: l l Dos vs. Windows 3. 1 overhead. The PC architecture was never designed as a gaming platform. Machine can be VERY different from another. The will: l l Windows a desirable platform for game development. Fast, low-level libraries to allow the developer maintain creative freedom over his games. Shift the burden of hardware support from the game developer to the hardware manufacture. Coexist peacefully with other Windows components. 3
(What is Direct. X? (2 l The Solution: Direct. X l Direct access to Hardware… l A common standard which all games and multimedia applications could follow – a common interface with whatever hardware is installed in the PC. l Provides real-time multimedia and gaming services to programs: graphics, sound, music, input (mouse/ keyboard / joystick/ etc), networking, and movie playback. l Done by three Microsoft employees—Craig Eisler, Alex St. John, and Eric Engstrom. 4
(What’s Direct. X? (3 l There are two parts to Direct. X; the 'runtime' and the 'SDK' (Software Development Kit). Both are free; the runtime is what players need to have on their computers in order to play a game, and the SDK is what a programmer needs to create games that use Direct. X. l Windows XP comes with the Direct. X 8 runtime automatically installed; it's a 4 MB download if players don't have it. l The SDK, is over 100 MB to download, and it contains all the headers and libraries you need, plus documentation, samples, tutorials, and tools. Players don't need the SDK, only the runtime. l Most games for Windows nowadays use Direct. X in some form or another; it is also the technology which powers Microsoft's XBox. 5
(What is Direct. X? (4 6
(Terminology (1 l API (application program interface)- Set of routines, protocols, and tools for building software applications. Saves the programmer from dealing with implementation. l Driver- Program that controls a device. Acts like a translator between the device and programs that use the device. Each device has its own set of specialized commands that only its driver knows. In contrast, most programs access devices by using generic commands. The driver, therefore, accepts generic commands from a program and then translates them into specialized commands for the device. 7
(Terminology (2 l Sound Card- Enables the computer to output sound through speakers connected to the board, record sound input from a microphone connected to the computer, and manipulate sound stored on a disk. l Video Adapter- A board that plugs into a PC to give it display capabilities. Modern video adapters contain memory, so that the computer's RAM is not used for storing displays. In addition, most adapters have their own graphics coprocessor for performing graphics calculations. These adapters are often called graphics accelerators. 8
(Terminology (3 l Graphics Accelerator- Type of video adapter that contains its own processor to boost performance levels. l l These processors are specialized for computing graphical transformations, so they achieve better results than the general-purpose CPU used by the computer. In addition, they free up the computer's CPU to execute other commands while the graphics accelerator is handling graphics computations. Other characteristics that differentiate graphics accelerators: l memory : Amount of memory determines resolution and colors amount. Two types of memory-DRAM or video RAM (VRAM), which enables the video circuitry and the processor simultaneously access the memory. l bus : 1995: PCI bus, nowadays; PCIExpress bus. l register width: The wider the register, the more data the processor can manipulate with each instruction. 64 -bit accelerators are already becoming common, and we can expect 128 -bit accelerators in the near future. 9
(Terminology (4 l GDI- Graphical Device Interface, a Windows standard for representing graphical objects and transmitting them to output devices, such as monitors and printers. l HEL, HAL, COM and more to be discussed later… 10
Direct. X Components l Direct. X Graphics l l l Direct. Input Direct. Play Direct. Audio l l Direct. Draw Direct 3 D Direct. Sound Direct. Music Direct. Show Direct. Setup 11
(Direct. X Components (1 l Direct. X Graphics l Direct. Draw- A software interface that provides direct access to display devices while maintaining compatibility with the GDI and for transferring video processing from a PC's CPU to the video adapter. The standard was first developed by Intel and called the Display Control Interface (DCI) and later supported by Microsoft. When the CPU is not busy, the GDI updates the video display. If the CPU is busy, the DCI driver allows an application to send update information directly to the video adapter. l Direct 3 D- An API for manipulating and displaying three-dimensional objects. Developed by Microsoft, Direct 3 D provides programmers with a way to develop 3 -D programs that can use whatever graphics acceleration device is installed in the machine. Virtually all 3 -D accelerator cards for PCs support Direct 3 D. Another 3 -D standard offering similar functionality is Open. GL. 12
(Direct. X Components (2 l Direct. Input- Enables an application to retrieve data from input devices even when the application is in the background. Also provides full support for any type of input device, as well as force feedback. l Direct. Play- A media-independent networking API that provides networking services at the transport protocol and session protocol levels. Direct. Play sessions can be run on TCP/IP networks, IPX networks, and over directly connected modems and serial cables. 13
(Direct. X Components (3 l Direct. X Audio l Direct. Sound- Enables the playing of sounds with very low latency and gives applications a high level of control over hardware resources. l Direct. Music- In combination with Direct. Sound, Direct. Music provides a complete solution for playing music and sound effects in games and other applications. 14
(Direct. X Components (4 l Direct. Show- An architecture for streaming media on a Windows platform. It provides highquality capture and playback of multimedia streams. Screeen Saver, Camera. . l Direct. Setup- Extremely simple library of functions for installing Direct. X on a machine. It also provides a way to check the version of Direct. X that is present. 15
Versions (1) l For each new version of Direct. X, Microsoft updated the technology such that the new dll's can communicate with the hardware faster and more efficiently with minimum latency. l They’re trying to support the latest features of graphics and sound cards that come on the market. l The architecture is updated so as to suit the needs of the day while maintaining backward compatibility. 16
(Versions (2 l Direct. X 1. 0 l l Direct. X 6 l l 2 independent SDK's (Direct. X SDK and Direct. X Media SDK). Direct. X 7 l l released on late 1995. Direct. Show- the significant part of Media SDK, merged into the Direct. X API and Direct. X Media deprecated. Direct. X 8 l l l Direct. Draw and Direct 3 D merged into a single Direct. X Graphics API for graphics programming. Direct. Sound and Direct Music merged together as Direct. X Audio for sound programming. Programmable Pixel Shader and Vertex Shader introduced. 17
Versions (3) l Direct. X 9 l l HLSL (High Level Shader Language), a powerful new programming model that offers the easiest to use graphics creation toolset for developers introduced. Direct. X 10– Part of Windows Vista. l l No backward compatibly except via a software layer. Much faster DLL’s Departure from driver model of Direct. X 9. 0, with the addition of a scheduler and memory virtualization system. Direct. X 10 will forego the current Direct. X practice of using "capability bits" to indicate which features are active on the current hardware. Instead, Direct. X 10 will define a minimum standard of hardware capabilities which must be supported for a display system to be "Direct. X 10 compatible". 18
Versions (4) l Which version of Direct. X do various versions of Windows come with? 95 None 95 B DX 3(Supports up to DX 8) NT DX 2 NT w/SP 4 DX 3 98 DX 5 98 SE DX 6 ME DX 7. 1 2000 DX 7. 1 XP DX 8. 1 19
Screenshots Wolfenstein (3 D Realms 1992 –> no HAL): 20
Direct. X in details 21
Direct. X – COM objects Direct. X is a set of APIs, available as COM objects. Component Object Model (COM) is a Microsoft platform for software componentry introduced by Microsoft in 1993. It is used to enable cross-application communication and dynamic object creation in any programming language that supports the technology. l All Direct. X Interfaces inherit from IUnknown and are COM compliant. l IUn. Known: l l l Add. Ref() Release() Query. Interface() Reference counting 22
Backward Compatibility (1) l COM allows Microsoft release an enhanced set of Direct. X components that are completely compatible with earlier versions of Direct. X. l With COM’s independence of a programming language, developers are free to choose whatever COM compliant language and development environment they wish. l With COM’s programming model, the programmer is assured that even if the user upgrades or changes hardware configuration and Direct. X drivers, the software will work without reconfiguration. 23
Backward Compatibility (2) l For example, even though Direct. Draw was erased from the Direct. X API components after Direct. X 7 even in Direct. X 9, you can access the old interfaces through a Direct. Draw 7 call. l This backward compatibility plays a significant role in Direct. X's position as a leading API, as it helps the applications written in older versions to still work smoothly in the newer versions. 24
? How it really works Direct. X provides the interface to access the advanced features of the display adapter, which are not provided in the standard Windows GDI graphics interface. l It accesses the hardware abstraction layer in Windows directly. l When Direct. X was introduced, display adapter vendors were quick to develop Direct. X drivers that would expose low-level functions of their hardware to the application. l 25
Architecture l Each chip manufacturer, board producer, or OEM implements a HAL which implements only device-dependent code and performs no emulation. l The HAL is implemented using 32 -bit code with Microsoft Windows XP, Microsoft Windows NT, and Windows 2000. Windows 98 and Windows Millennium Edition (Windows Me) use a combination of 16 -bit and 32 -bit code. l The HAL can be part of the display driver or a separate dynamiclink library (DLL) that communicates with the display driver through a private interface that the driver's creator defines. l HAL is based around the hardware support, and is very fast but might not support everything 26
Architecture When Direct. X is initialized, it checks the hardware to see if the hardware supports certain capabilities. If the hardware does support a certain capability, then the HAL will be used to access that hardware function; otherwise, the HEL will be used to emulate the capability through software. l HEL bypasses the hardware and implements its own functionality. l HEL uses no hardware acceleration. It uses the CPU, software, and normal system RAM. It is usually MUCH slower, but much less problematic l 27
Architecture 28
3 D - Graphics l Rendering - the process of generating an image from a model, by means of a software program. 29
3 D - Graphics l l l The Application is your game and is where you do any scene management and any tessellation of mesh etc. You then feed the graphics card with vertices and other data. The graphic card processes the vertices by transforming and lighting them using the matrices supplied by the application. The card then culls any invisible polygons and clips to the viewport. This transformed data is then rasterized and passes through the pixel operations The data is displayed. 30
3 D - Graphics 31
…Some terms Rasterisation - The task of taking a twodimensional image described in a vector format and converting it into pixels or dots for output on a video display or printer. l A tessellation (tiling) of the plane is a collection of plane figures that fill the plane with no overlaps and no gaps. l A shader is a program used to determine the final surface properties of an object or image. l 32
Programmable Pipeline One of the most important new features in Direct. X Graphics is the addition of a programmable pipeline. l l It provides an assembly language interface to the transformation and lighting hardware (vertex shader) and the pixel pipeline (pixel shader). l This programmable pipeline gives the developer a lot more freedom to do things, which have never been seen in real time applications before. l The shader code is loaded into the graphics card memory and plugged directly into the graphics pipeline. Shader code is in assembly however nowadays there a number of higher level 'C' type languages that can be compiled down to the assembly and making them much easier to program. l Microsoft have HLSL (High-Level Shading Language) for use with Direct. X and Open. GL has the GLSL (Open. GL Shading Language). 33
Programmable Pipeline l When you push vertices through the pipeline, they need to be transformed and lit. l This processing stage is known as T&L. l Hardware vertex processing means this is done in hardware, if hardware supports it; l Software vertex processing is done in software. l The general practice is to try creating a Hardware T&L device. If that fails try Mixed, and if that fails try Software. (If software fails, give up and exit with an error). 34
Direct. X - Conclusion l Direct. X gives multimedia applications greater access to advanced features of high-performance hardware such as 3 D graphics acceleration chips and sound cards. l It controls 2 D graphics acceleration; l Support for input devices: joysticks / joy-pads, keyboards, mice, controls sound mixing and sound output on a vast range of audio hardware, controls networking and multiplayer gaming, and control over various multimedia streaming formats. 35
(Direct. X Alternative (1 Open Graphics Library is a specification defining a cross-language crossplatform API for writing applications that produce 3 D computer graphics (2 D computer graphics as well). The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. 36
(Direct. X Alternative (2 l The Open. GL specification is overseen by the Open. GL Architecture Review Board (ARB), which was formed in 1992. The ARB consists of a set of companies with a vested interest in creating a consistent and widely available API. 37
Direct. X Alternative (3) Open. GL- platform Independent; supported on Windows, Mac, Linux, and several other UNIX variants. l Direct 3 D- only Windows. l Open. GL- function oriented interface. l Direct 3 D- object oriented interface. l 38
Direct. X Alternative (4) l Direct 3 D- updated very frequently (once a year) and supports the latest card features (Microsoft). l Open. GL- takes some time to reach a new standard (open-standard and a community product, Silicon Graphics). l Performance : Equal performance!! 39
? Where do I start l If you're worried about which one to learn, and which one the pros use, the answer is that more often than not they'll use both. l Apart from Direct 3 D, all the Direct. X components can be used alongside Open. GL. If you want to use Direct. Input for joystick input and Open. GL for your graphics, that's fine. 40
Games(1) l The 3 D engine of the game Battlefield 1942 sits solidly on a Direct. X 7 foundation. 41
Games(2) l Unreal Tournament 2003 uses a number of Direct. X 8 shader effects. As a result, the game's graphics look much better than that of older games, and the in-game world seems more alive. 42
(Games(3 l Far. Cry can be considered the first game that makes consistent use of shaders. Thanks to Direct. X 9, the surfaces look very realistic and react to changes in lighting. 43
Further Reading - Web Resources General International Game Developers Assoc. - www. igda. org l Gama. Sutra - www. gamasutra. com l Game Developer - www. gamedev. net l Direct X MSDN - www. msdn. com/directx l Newsgroup - microsoft. public. win 32. programmer. directx. managed l The Z Buffer - www. thezbuffer. com l Tom Miller (main coder/designer) - blogs. msdn. com/tmiller l 44
Further Reading - Direct. X Books 45
The End 46
b29e7c914d4e3c91f93fedef2bedc595.ppt