J2ME

Document Sample
J2ME Powered By Docstoc
					    A presentation on
        DirectX®


    Alex Brill
    Emil Elazar
    Noam Monheit



1
Contents
    What is DirectX?
        Historical Problem and it’s Solution
        Terminology
        Brief Components Description
        DirectX Versions History
    How DirectX really works?
        Architecture
        Direct3D in Details
    DirectX Alternatives
        OpenGL
        Advantages & Disadvantages or: ―Why DirectX‖?
    Installation + SDK
    Demo + Code Examples


                                                         2
What is DirectX? (1)
    The Problem:
        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:
        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 DirectX? (2)

    The Solution: DirectX

        Direct access to Hardware…

        A common standard which all games and multimedia
         applications could follow – a common interface with
         whatever hardware is installed in the PC.

        Provides real-time multimedia and gaming services to
         programs: graphics, sound, music, input (mouse / keyboard
         / joystick / etc), networking, and movie playback.

        Done by three Microsoft employees—Craig Eisler, Alex St.
         John, and Eric Engstrom.


                                                                     4
What’s DirectX? (3)
    There are two parts to DirectX; 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 DirectX.

    Windows XP comes with the DirectX 8 runtime automatically
     installed; it's a 4 MB download if players don't have it.

    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.

    Most games for Windows nowadays use DirectX in some form or
     another; it is also the technology which powers Microsoft's XBox.


                                                                           5
What is DirectX? (4)




                       6
Terminology (1)
    API (application program interface)- Set of routines,
     protocols, and tools for building software applications.
     Saves the programmer from dealing with
     implementation.

    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)
    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.

    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)
    Graphics Accelerator- Type of video adapter that contains its
     own processor to boost performance levels.
         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:
       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.
       bus : 1995: PCI bus, nowadays; PCIExpress bus.
       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)

    GDI- Graphical Device Interface, a
     Windows standard for representing
     graphical objects and transmitting them
     to output devices, such as monitors and
     printers.

    HEL, HAL, COM and more to be
     discussed later…

                                               10
DirectX Components
    DirectX Graphics
        DirectDraw
        Direct3D
    DirectInput
    DirectPlay
    DirectAudio
        DirectSound
        DirectMusic
    DirectShow
    DirectSetup


                        11
DirectX Components (1)
   DirectX Graphics
       DirectDraw- 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.


       Direct3D- An API for manipulating and displaying three-dimensional
        objects. Developed by Microsoft, Direct3D 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 Direct3D.
        Another 3-D standard offering similar functionality is OpenGL.



                                                                                      12
DirectX Components (2)
    DirectInput- 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 for force feedback.


    DirectPlay- A media-independent networking API that
     provides networking services at the transport protocol
     and session protocol levels. DirectPlay sessions can
     be run on TCP/IP networks, IPX networks, and over
     directly connected modems and serial cables.

                                                                13
DirectX Components (3)

    DirectX Audio
        DirectSound- Enables the playing of
         sounds with very low latency and gives
         applications a high level of control over
         hardware resources.
        DirectMusic- In combination with
         DirectSound, DirectMusic provides a
         complete solution for playing music and
         sound effects in games and other
         applications.

                                                     14
DirectX Components (4)

    DirectShow- An architecture for streaming
     media on a Windows platform. It provides
     high-quality capture and playback of
     multimedia streams. Screeen Saver, Camera..

    DirectSetup- Extremely simple library of
     functions for installing DirectX on a machine.
     It also provides a way to check the version of
     DirectX that is present.

                                                      15
Versions (1)
    For each new version of DirectX, Microsoft
     updated the technology such that the new dll's
     can communicate with the hardware faster and
     more efficiently with minimum latency.

    They’re trying to support the latest features of
     graphics and sound cards that come on the
     market.

    The architecture is updated so as to suit the
     needs of the day while maintaining backward
     compatibility.
                                                        16
Versions (2)
    DirectX 1.0
        released on late 1995.
    DirectX 6
        2 independent SDK's (DirectX SDK and DirectX Media SDK).
    DirectX 7
        DirectShow- the significant part of Media SDK, merged into
         the DirectX API and DirectX Media deprecated.
    DirectX 8
        DirectDraw and Direct3D merged into a single DirectX
         Graphics API for graphics programming.
        DirectSound and Direct Music merged together as DirectX
         Audio for sound programming.
        Programmable Pixel Shader and Vertex Shader introduced.



                                                                      17
Versions (3)
    DirectX 9
        HLSL (High Level Shader Language), a powerful new
         programming model that offers the easiest to use graphics
         creation toolset for developers introduced.

    DirectX10– Part of Windows Vista.
        No backward compatibly except via a software layer.
        Much faster DLL’s
        Departure from driver model of DirectX 9.0, with the addition
         of a scheduler and memory virtualization system.
        DirectX 10 will forego the current DirectX practice of using
         "capability bits" to indicate which features are active on the
         current hardware. Instead, DirectX 10 will define a minimum
         standard of hardware capabilities which must be supported for
         a display system to be "DirectX 10 compatible".


                                                                          18
Versions (4)
    Which version of DirectX do various versions of
     Windows come with?

     95              None
     95B             DX 3(Supports up to DX8)
     NT              DX2
     NT w/SP 4       DX3
     98              DX5
     98SE            DX6
     ME              DX7.1
     2000            DX7.1
     XP              DX8.1



                                                       19
Screenshots
  Wolfenstein (3D Realms 1992 –> no HAL):




                                            20
DirectX in details




                     21
DirectX – COM objects
  DirectX 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.
  All DirectX Interfaces inherit from IUnknown and are
   COM compliant.
  IUnKnown:
           AddRef()
           Release()
           QueryInterface()
    Reference counting

                                                          22
Backward Compatibility (1)
    COM allows Microsoft release an enhanced set of
     DirectX components that are completely compatible
     with earlier versions of DirectX.

    With COM’s independence of a programming
     language, developers are free to choose whatever
     COM compliant language and development
     environment they wish.

    With COM’s programming model, the programmer is
     assured that even if the user upgrades or changes
     hardware configuration and DirectX drivers, the
     software will work without reconfiguration.

                                                         23
Backward Compatibility (2)
    For example, even though DirectDraw was erased
     from the DirectX API components after DirectX 7
     even in DirectX9, you can access the old interfaces
     through a DirectDraw7 call.

    This backward compatibility plays a significant role
     in DirectX'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?
  DirectX provides the interface to access the
   advanced features of the display adapter,
   which are not provided in the standard
   Windows GDI graphics interface.
  It accesses the hardware abstraction layer in
   Windows directly.
  When DirectX was introduced, display adapter
   vendors were quick to develop DirectX drivers
   that would expose low-level functions of
   their hardware to the application.

                                                   25
Architecture

    Each chip manufacturer, board producer, or OEM implements a
     HAL which implements only device-dependent code and performs
     no emulation.

    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.

    The HAL can be part of the display driver or a separate dynamic-
     link library (DLL) that communicates with the display driver
     through a private interface that the driver's creator defines.

    HAL is based around the hardware support, and is very fast but
     might not support everything


                                                                        26
Architecture
    When DirectX 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.
    HEL bypasses the hardware and implements its own
     functionality.
    HEL uses no hardware acceleration. It uses the CPU,
     software, and normal system RAM. It is usually MUCH
     slower, but much less problematic



                                                                 27
Architecture




               28
3D - Graphics

    Rendering - the process of generating
     an image from a model, by means of a
     software program .




                                             29
3D - Graphics
    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
3D - Graphics




                31
Some terms…
  Rasterisation - The task of taking a two-
   dimensional image described in a vector
   format and converting it into pixels or dots for
   output on a video display or printer.
  A tessellation (tiling) of
   the plane is a collection
   of plane figures that fill the
   plane with no overlaps and no gaps.
  A shader is a program used to determine the
   final surface properties of an object or image.

                                                      32
Programmable Pipeline
    One of the most important new features in
     DirectX Graphics is the addition of a
     programmable pipeline.

    It provides an assembly language interface to the transformation and
     lighting hardware (vertex shader) and the pixel pipeline (pixel shader).

    This programmable pipeline gives the developer a lot more freedom to
     do things, which have never been seen in real time applications before.

    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 are a number of higher level 'C' type languages that can
     be compiled down to the assembly and making them much easier to
     program.

    Microsoft have HLSL (High-Level Shading Language) for use with
     DirectX and OpenGL has the GLSL (OpenGL Shading Language).

                                                                                33
Programmable Pipeline
    When you push vertices through the pipeline, they need
     to be transformed and lit.

    This processing stage is known as T&L.

    Hardware vertex processing means this is done in
     hardware, if hardware supports it;

    Software vertex processing is done in software.

    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
DirectX - Conclusion
    DirectX gives multimedia applications greater access
     to advanced features of high-performance hardware
     such as 3D graphics acceleration chips and sound
     cards.

    It controls 2D graphics acceleration;

    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
DirectX Alternative (1)

                  Open Graphics Library is a
                  specification defining a
                  cross-language cross-
   platform API for writing applications that
   produce 3D computer graphics (2D
   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
DirectX Alternative (2)

    The OpenGL specification is overseen
     by the OpenGL 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
DirectX Alternative (3)

    OpenGL- platform Independent; supported on
     Windows, Mac, Linux, and several other UNIX
     variants.
    Direct3D- only Windows.

    OpenGL- function oriented interface.
    Direct3D- object oriented interface.



                                                   38
DirectX Alternative (4)


  Direct3D- updated very frequently (once
   a year) and supports the latest card
   features (Microsoft).
  OpenGL- takes some time to reach a new
   standard (open-standard and a
   community product, Silicon Graphics).

    Performance : Equal performance!!

                                             39
Where do I start?

  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.
  Apart from Direct3D, all the DirectX
   components can be used alongside
   OpenGL. If you want to use DirectInput
   for joystick input and OpenGL for your
   graphics, that's fine.

                                                40
Games(1)
    The 3D engine of the
     game Battlefield 1942
     sits solidly on a
     DirectX 7 foundation.




                             41
Games(2)
    Unreal Tournament
     2003 uses a number of
     DirectX 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)
    FarCry can be
     considered the first
     game that makes
     consistent use of
     shaders. Thanks to
     DirectX 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
 GamaSutra - www.gamasutra.com
 Game Developer - www.gamedev.net


Direct X
 MSDN - www.msdn.com/directx
 Newsgroup -
  microsoft.public.win32.programmer.directx.managed
 The Z Buffer - www.thezbuffer.com
 Tom Miller (main coder/designer) - blogs.msdn.com/tmiller




                                                              44
Further Reading - DirectX Books




                                  45
The End




          46

				
DOCUMENT INFO