You are previewing Windows Graphics Programming Win32 GDI and DirectDraw®.
O'Reilly logo
Windows Graphics Programming Win32 GDI and DirectDraw®

Book Description

The world's most complete guide to Windows graphics programming!

  • Win32 GDI and DirectDraw: Accurate, under the hood, and in depth

  • Beyond the API: Internals, restrictions, performance, and real-life problems

  • Complete: Pixel, lines, curves, filled area, bitmap, image processing, fonts, text, metafile, printing, and more

  • Up to date: Windows 2000 and Windows 98 graphics enhancements

  • CD-ROM: Exclusive and professional quality generic C++ classes, reusable functions, demonstration programs, kernel mode drivers, GDI exploration tools, and more!

  • Hewlett-Packard Professional Books

    To deliver high-performance Windows applications, you need an in-depth understanding of the Win32 GDI and DirectDraw—but until now, it's been virtually impossible to discover what's going on "behind" Microsoft's API calls. This book rips away the veil, giving experienced Windows programmers all the information and techniques they need to maximize performance, efficiency, and reliability! You'll discover how to make the most of Microsoft's Windows graphics APIs—including the important new graphics capabilities built into Windows 2000. Coverage includes:

  • Uncovering the Windows system architecture and graphics system internal data structure

  • Building graphics API "spies" that show what's going on "under the hood"

  • Detecting GDI resource leaks and other powerful troubleshooting techniques

  • Expert techniques for working with the Win32 GDI and DirectDraw APIs

  • Device context, coordinate space and transformation, pixels, lines, curves, and area fills

  • Bitmaps, image processing, fonts, text, enhanced metafiles, printing, and more

  • Windows Graphics Programming delivers extensive code, practical techniques, and unprecedented insight—plus an exclusive CD-ROM containing original system-level tools, kernel mode drivers, sample code, and generic C++ classes for Windows graphics programming without MFC. If you want to build Windows graphics applications that deliver breakthrough performance and reliability, you'll find this book indispensable.

    Table of Contents

    1. Copyright
      1. Dedication
    2. Preface
      1. WHAT IS THIS BOOK ABOUT?
      2. HOW IS THIS BOOK ORGANIZED?
      3. HOW SHOULD YOU READ THIS BOOK?
      4. WHAT IS ON THE CD?
      5. WHAT IS THE FUTURE OF THIS BOOK?
      6. ACKNOWLEDGMENTS
    3. 1. Basic Techniques and Knowledge
      1. 1.1. BASIC WINDOWS PROGRAMMING IN C/C++
        1. Hello World Version 1: Starting Your Browser
        2. Hello World Version 2: Drawing Directly to Desktop
        3. Hello World Version 3: Creating a Full-Screen Window
        4. Hello World Version 4: Drawing with DirectDraw
      2. 1.2. ASSEMBLY LANGUAGE
      3. 1.3. PROGRAM DEVELOPMENT ENVIRONMENT
        1. Development and Testing Systems
        2. Compilers
        3. Microsoft Platform Software Development Kit
        4. Microsoft Driver Development Kit
        5. Microsoft Development Network Library
      4. 1.4. WIN32 EXECUTABLE FILE FORMAT
        1. Import Directory
        2. Export Directory
      5. 1.5. ARCHITECTURE OF MICROSOFT WINDOWS OS
        1. Hardware Abstraction Layer
        2. MicroKernel
        3. Device Drivers
        4. Window Management and Graphics System
        5. Executive
        6. System Services: Native API
        7. System Processes
        8. Services
        9. Environment Subsystems
      6. 1.6. SUMMARY
        1. Further Reading
        2. Sample Programs
    4. 2. Windows Graphics System Architecture
      1. 2.1. WINDOWS GRAPHICS SYSTEM COMPONENTS
        1. Multimedia
        2. Video for Windows
        3. Still Image
        4. OpenGL
        5. Windows Media
        6. OS Kernel Mode Components
        7. Kernel Mode Drivers
      2. 2.2. GDI ARCHITECTURE
        1. Exported Functions from GDI32.DLL
        2. GDI Function Areas
        3. GDI System Service Calls
        4. From Win32 GDI API to GDI Engine System Service Calls
      3. 2.3. DIRECTX ARCHITECTURE
        1. DirectX Components
        2. DirectDraw Architecture
      4. 2.4. PRINTING ARCHITECTURE
        1. The Win32 Spooler Client DLL
        2. Spooler System Service Process
        3. Spooler Router
        4. Print Provider
        5. Print Processor
        6. Language Monitor and Port Monitor
        7. A Peek into the Spooler Process
      5. 2.5. GRAPHICS ENGINE
        1. Graphics Engine System Services
        2. Graphics Render Engine
        3. Graphics Engine Data Structures
        4. Transform to Primitives
        5. Font Drivers
      6. 2.6. DISPLAY DRIVERS
        1. Video Port Driver and Video Miniport Driver
        2. Display Driver Function Areas
        3. Display Driver Initialization
        4. Surface Drawing Calls, Hooking, and Punting
        5. Other Driver Features
        6. Display Driver Support for DirectDraw/Direct3D
      7. 2.7. PRINTER DRIVERS
        1. Microsoft Printer Driver Frameworks
        2. Printer Driver Graphics DLL
        3. An HTML Printer Driver
      8. 2.8. SUMMARY
        1. Further Reading
        2. Sample Programs
    5. 3. GDI/DirectDraw Internal Data Structures
      1. 3.1. HANDLES AND OBJECT-ORIENTED PROGRAMMING
        1. Class and Object
        2. Encapsulation and Information Hiding
        3. Pointer vs. Handle
        4. Identity Map
        5. Table-based Mapping
        6. A Handle Is Not Enough
      2. 3.2. DECODING GDI OBJECT HANDLES
        1. Stock Object Handles Are Constants
        2. HGDIOBJ Is Not a Pointer
        3. Process GDI Handle Limit Is Around 12,000
        4. Systemwide GDI Handle Limit Is 16,384
        5. Part of HGDIOBJ Is an Index
        6. Part of HGDIOBJ Is a GDI Object Type
      3. 3.3. LOCATING THE GDI OBJECT HANDLE TABLE
      4. 3.4. DECODING THE GDI OBJECT HANDLE TABLE
        1. pKernel Points to Paged Pool
        2. nCount Is Partly a Selection Count
        3. nProcess Makes GDI Handles Process-Bound
        4. nUpper: More Checking for Handles
        5. nType: Internal Object Type
        6. pUser Points to User Mode Data Structure
      5. 3.5. USER MODE DATA STRUCTURE OF GDI OBJECTS
        1. User Mode Brush Data: Solid Brush Optimization
        2. User Mode Region Data: Rectangular Region Optimization
        3. User Mode Font Data: Width Table
        4. User Mode Device Context Data: Keeping the Settings
      6. 3.6. ACCESSING KERNEL MODE ADDRESS SPACE
      7. 3.7. WINDBG AND THE GDI DEBUGGER EXTENSION
      8. 3.8. GDI KERNEL MODE DATA STRUCTURE
        1. GDI Object Handle Table in the GDI Engine
        2. GDI Object Types in the GDI Engine
        3. Device Context in the GDI Engine
        4. GDI Engine PDEV Structure
        5. GDI Engine Surfaces
        6. Device-Dependent Bitmaps in the GDI Engine
        7. DIB Sections in the GDI Engine
        8. Brushes in the GDI Engine
        9. Pens in the GDI Engine
        10. Palettes in the GDI Engine
        11. Regions in the GDI Engine
        12. Paths in the GDI Engine
        13. Fonts in the GDI Engine
        14. Other GDI Objects in the GDI Engine
      9. 3.9. DIRECTDRAW DATA STRUCTURE
      10. 3.10. SUMMARY
        1. Further Reading
        2. Sample Programs
    6. 4. Spying in the Windows Graphics System
      1. 4.1. SPYING ON WIN32 API CALLS
        1. Making of a Spy
        2. Injecting Spying DLL
        3. Hooking into API Calling Chain
        4. Information Gathering
        5. Data Dumping
        6. Spy Control Program
      2. 4.2. SPYING ON WIN32 GDI
        1. The GDI API Definition File
        2. The GDI Data Decoder
        3. Complete API Spying
      3. 4.3. SPYING ON DIRECTDRAW COM INTERFACES
        1. Virtual Function Table
        2. The DirectDraw API Definition
        3. Virtual Function Table Hacking
      4. 4.4. SPYING ON GDI SYSTEM CALLS
      5. 4.5. SPYING ON THE DDI INTERFACE
      6. 4.6. SUMMARY
        1. Further Reading
        2. Sample Programs
    7. 5. Graphics Device Abstraction
      1. 5.1. MODERN VIDEO DISPLAY CARD
        1. Frame Buffer
        2. Pixel Format
        3. Double Buffering, z-Buffering, and Texture
        4. Hardware Acceleration
        5. Display Device and Settings Enumeration
      2. 5.2. DEVICE CONTEXT
        1. Device Context Creation
        2. Querying a Device's Capabilities
        3. Attributes in Device Context
        4. Device Context Associated with a Window
        5. Displaying in a Multiple Window Environment
        6. Getting a Device Context Associated with a Window
        7. Common Device Context
        8. Class Device Context
        9. Private Device Context
        10. Parent Device Context
        11. Other Device Contexts
        12. Information Context
        13. Memory Device Context
        14. Metafile Device Context
      3. 5.3. FORMALIZING DEVICE CONTEXT
      4. 5.4. SAMPLE PROGRAM: GENERIC FRAME WINDOW
        1. Toolbar Class
        2. Status Window Class
        3. Canvas Window Class
        4. Frame Window Class
        5. Test Program
      5. 5.5. SAMPLE PROGRAM: PAINTING AND DEVICE CONTEXT
        1. A Window's Update Region
        2. WM_PAINT Message
        3. Visualize Window Painting Messages
      6. 5.6. SUMMARY
        1. Further Reading
        2. Sample Programs
    8. 6. Coordinate Spaces and Transformation
      1. 6.1. THE PHYSICAL DEVICE COORDINATE SPACE
      2. 6.2. THE DEVICE COORDINATE SPACE
      3. 6.3. THE PAGE COORDINATE SPACE AND MAPPING MODES
        1. MM_TEXT Mapping Mode
        2. MM_LOENGLISH, MM_HIENGLISH Mapping Modes
        3. MM_LOMETRIC and MM_HIMETRIC Mapping Modes
        4. MM_TWIPS Mapping Mode
        5. MM_ISOTROPIC Mapping Modes
        6. MM_ANISOTROPIC Mapping Mode
        7. Window and Viewport Origins
        8. Other Window and Viewport Functions
      4. 6.4. THE WORLD COORDINATE SPACE
        1. Affine Transformations
        2. The WIN32 API for World Transformations
        3. Using World Transformation
      5. 6.5. USING COORDINATE SPACES
        1. GDI Implementation: Mapping and Transformation
      6. 6.6. SAMPLE PROGRAM: SCROLLING AND ZOOM
        1. Game Board Based on KScrollCanvas Class
      7. 6.7. SUMMARY
        1. Further Reading
        2. Sample Programs
    9. 7. Pixels
      1. 7.1. GDI OBJECTS, HANDLES, AND HANDLE TABLE
        1. GDI Object Storage
        2. The GDI Object Table
        3. The GDI Object Handle
        4. The GDI Object API
        5. GDI Object Leakage Detection
      2. 7.2. CLIPPING
        1. Clipping Pipeline
        2. Simple Regions
        3. Clipping Region
        4. The Meta Region
        5. Five Regions in a Device Context
        6. Visualizing Device Context Regions
      3. 7.3. COLOR
        1. The RGB Color Space
        2. The HLS Color Space
        3. Indexed Color and Palette
        4. Beyond the Basics
      4. 7.4. DRAWING PIXELS
      5. 7.5. SAMPLE PROGRAM: MANDELBROT SET
      6. 7.6. SUMMARY
        1. Further Reading
        2. Sample Programs
    10. 8. Lines and Curves
      1. 8.1. BINARY RASTER OPERATIONS
      2. 8.2. BACKGROUND MODE AND BACKGROUND COLOR
      3. 8.3. PENS
        1. Logical Pen Objects
        2. Stock Pens
        3. Simple Pens
        4. Extended Pens
          1. Cosmetic Pens
          2. Geometric Pens
        5. Query Logical Pens
        6. A Wrapper Class for GDI Pen Objects
      4. 8.4. LINES
      5. 8.5. BEZIER CURVES
        1. PolyDraw
        2. Alternative Bezier Curve Definition: Pass All Points
      6. 8.6. ARCS
        1. Specifying Arc Using Degrees: AngleArc
        2. Drawing Arcs with Inside Frame Pens
        3. Convert Arcs to Bezier Curves
      7. 8.7. PATHS
        1. Path Construction
        2. Querying Path Data
        3. Transform Path Object
        4. Drawing Using a Path
        5. Converting Path to Region
      8. 8.8. SAMPLE: DRAWING YOUR OWN STYLED-LINES
      9. 8.9. SUMMARY
        1. Further Reading
        2. Sample Program
    11. 9. Areas
      1. 9.1. BRUSHES
        1. Logical Brush Objects
        2. Stock Brushes
        3. Custom Brushes
          1. Solid Brushes
          2. Hatch Brushes
          3. Bitmap Brushes
        4. System Color Brushes
        5. LOGBRUSH Structure
      2. 9.2. RECTANGLES
        1. Rectangle as a Data Structure
        2. Drawing Rectangles
          1. Rectangle
          2. FillRect
          3. FrameRect
          4. InvertRect
          5. DrawFocusRect
        3. Drawing Edges and Controls
      3. 9.3. ELLIPSES, CHORDS, PIES, AND ROUNDED RECTANGLES
      4. 9.4. POLYGONS
        1. Polygon Fill Mode
      5. 9.5. CLOSED PATHS
      6. 9.6. REGIONS
        1. Region Object Creation
        2. Operations on Region Objects
          1. Querying a Region
          2. Set Operations on Regions
          3. Transforming Region Data
        3. Painting Using Regions
      7. 9.7. GRADIENT FILLS
        1. Gradient Fill of Rectangles
        2. Gradient Fills to Make 3D Buttons
      8. 9.8. AREA FILLS IN REALITY
        1. Semitransparent Fill
        2. Portable Gradient Fill in HLS Color Space
        3. Radial Gradient Fill
        4. Texture and Bitmap Fills
        5. Pattern Fills
      9. 9.9. SUMMARY
        1. Further Reading
        2. Sample Program
    12. 10. Bitmap Basics
      1. 10.1. DEVICE-INDEPENDENT BITMAP FORMATS
        1. BMP File Format
          1. Bitmap File Header
          2. Bitmap Information Header
          3. Bit Masks
          4. Color Table
          5. Pixel Array
        2. Packed Device-Independent Bitmap
        3. Divided Device-Independent Bitmap
      2. 10.2. A DIB CLASS
      3. 10.3. DISPLAYING A DIB
        1. StretchDIBits
        2. Source Rectangle
        3. Destination Rectangle and Stretch Modes
        4. Color Format Conversion
        5. Raster Operation
        6. StretchDIBits Sample
        7. SetDIBitsToDevice
      4. 10.4. MEMORY DEVICE CONTEXTS
      5. 10.5. DEVICE-DEPENDENT BITMAPS
        1. CreateBitmap
        2. CreateBitmapIndirect
        3. GetObject on DDB
        4. CreateCompatibleBitmap and CreateDiscardableBitmap
        5. CreateDIBitmap
        6. LoadBitmap
        7. Copying Bitmaps between DIBs and DDBs
        8. Access Raw DDB Pixel Array
      6. 10.6. USING DDBS
        1. Displaying DDBs
          1. Screen Scrambler
          2. Various Ways of Displaying DDBs
          3. Window/Screen Capturing
          4. DDB Color Conversion
        2. Using Bitmaps in Menus
        3. Using a Bitmap as Window Background
      7. 10.7. DIB SECTION
        1. CreateDIBSection
        2. A Class for the DIB Section
        3. GetObjectType/GetObject on DIB Sections
        4. GetDIBColorTable/SetDIBColorTable
        5. Using DIB Sections: Device-Independent Rendering
        6. Using DIB Sections: High-Resolution Rendering
      8. 10.8. SUMMARY
        1. Further Reading
        2. Sample Programs
    13. 11. Advanced Bitmap Graphics
      1. 11.1. TERNARY RASTER OPERATIONS
        1. Raster Operation Encoding
        2. Ternary Raster Operation Chart
        3. Commonly Used Raster Operations
          1. BLACKNESS, WHITENESS
          2. Pattern-Only ROPs: PATCOPY, R3_NOTCOPYPEN
          3. Source-Only ROPs: SRCCOPY, NOTSRCCOPY
          4. Destination-Only ROPs: R3_NOP, DSTINVERT
          5. Destination-Free ROPs: MERGECOPY
          6. Source-Free ROPs
          7. Pattern-Free ROPs
          8. Other Raster Operations
      2. 11.2. TRANSPARENT BITMAPS
        1. Parallelogram Bit-Block Transfer: PlgBlt
        2. Quaternary Raster Operations: MaskBlt
          1. Simulating MaskBlt
        3. Color Keying: TransparentBlt
          1. Simulating TransparentBlt
      3. 11.3. TRANSPARENCY WITHOUT A MASK BITMAP
        1. Masking Using Geometric Shapes
        2. Masking Using Clipping
        3. Prefabricating Image
      4. 11.4. ALPHA BLENDING
        1. Simple Constant Alpha Blending
        2. Fade In, Fade Out of Bitmaps
        3. Layered Window
        4. Alpha Channel: AirBrush
        5. Simulating Alpha Blending
      5. 11.5. SUMMARY
        1. Further Reading
        2. Sample Program
    14. 12. Image Processing Using Windows Bitmaps
      1. 12.1. GENERIC PIXEL ACCESS
      2. 12.2. BITMAP AFFINE TRANSFORMATION
      3. 12.3. FAST SPECIALIZED BITMAP TRANSFORMER
      4. 12.4. BITMAP COLOR TRANSFORMATION
        1. Converting Bitmaps to Grayscale
        2. Gamma Correction
      5. 12.5. BITMAP PIXEL TRANSFORMATION
        1. Generic Pixel Transformation Class
        2. Generic Channel-Splitting Class
        3. Sample Channel Splitting
        4. Histogram
      6. 12.6. BITMAP SPATIAL FILTERS
        1. Smoothing and Sharpening Filters
        2. Edge-Detection and Embossing Filters
        3. Morphological Filters
      7. 12.7. SUMMARY
        1. Further Reading
        2. Sample Program
    15. 13. Palettes
      1. 13.1. SYSTEM PALETTE
        1. Display Settings
        2. Querying the System Palette
        3. Static Colors
      2. 13.2. THE LOGICAL PALETTE
        1. The Default Palette
        2. The Halftone Palette
        3. Creating a Customized Palette
      3. 13.3. PALETTE MESSAGES
        1. The WM_QUERYNEWPALETTE
        2. WM_PALETTEISCHANGING
        3. WM_PALETTECHANGED
        4. A Test Program
      4. 13.4. PALETTE AND BITMAPS
        1. The Device-Dependent Bitmap and Palette
        2. Device-Independent Bitmaps and Palette
        3. A Palette Index in a DIB Color Table
        4. The DIB Section and Palette
      5. 13.5. COLOR QUANTIZATION
      6. 13.6. BITMAP COLOR-DEPTH REDUCTION
      7. 13.7. SUMMARY
        1. Further Reading
        2. Sample Program
    16. 14. Fonts
      1. 14.1. WHAT'S A FONT?
        1. Character Set and Code Page
        2. Glyph
          1. Relationship between Glyph and Character
          2. Glyph Design Elements
        3. Font
        4. Typestyle and Font Family
      2. 14.2. BITMAP FONTS
      3. 14.3. VECTOR FONTS
      4. 14.4. TRUETYPE FONTS
        1. TrueType Font File Format
        2. Font Header (“head” Table)
        3. Maximum Profile (“maxp” Table)
        4. Character-to-Glyph Index Mapping (“cmap” Table)
        5. Index to Location (“loca” Table)
        6. Glyph Data (“glyf” Table)
        7. Glyph Instructions
        8. Horizontal Metrics (“hhea” and “htmx” Tables)
        9. Kerning (“kern” Table)
        10. OS/2 and Window Metrics (“OS/2” Table)
        11. Other Tables
        12. TrueType Collections
      5. 14.5. FONT INSTALLATION AND EMBEDDING
        1. Font Resource File
        2. Install Public Fonts
        3. Install Private or Multiple Master OpenType Fonts
        4. Install Fonts from Memory Image
        5. Font Embedding
        6. System Font Lists
      6. 14.6. SUMMARY
        1. Future Reading
        2. Sample Programs
    17. 15. Text
      1. 15.1. LOGICAL FONTS
        1. Windows Typography Terminology
        2. Stock Fonts
        3. Creating Logical Fonts
        4. Logical to Physical Font Mapping
        5. PANOSE Typeface Matching
      2. 15.2. QUERYING LOGICAL FONT
        1. Metrics for Bitmap and Vector Fonts
        2. Metrics for TrueType/OpenType Fonts
        3. Explore LOGFONT and Font Metrics
        4. Font Metrics Accuracy
          1. Logical Coordinate Space Resolution vs. Accuracy
          2. Font Point Size vs. Accuracy
      3. 15.3. SIMPLE TEXT DRAWING
        1. Text Alignment
        2. Right-to-Left Layout and Reading
        3. Character Extra and Break Extra
        4. Character Width
      4. 15.4. ADVANCED TEXT DRAWING
        1. Character-to-Glyph Mapping
        2. Kerning
        3. Character Placement
        4. Extended Text Drawing
        5. Uniscribe
        6. Accessing Glyph
          1. Glyph Bitmap
          2. Glyph Outline
      5. 15.5. TEXT FORMATTING
        1. Tabbed Text Drawing
        2. Simple Paragraph Formatting
        3. Device-Independent Text Formatting
      6. 15.6. TEXT EFFECTS
        1. Coloring Text
        2. Text Styles
        3. Text Geometry
        4. Text as Bitmap
          1. Display Text Using Glyph Bitmaps
          2. Converting Text to Bitmap
          3. Embossing and Engraving on Bitmap Background
        5. Text as Curve
          1. Using a GDI Path for Text
          2. Transforming Path Data
          3. 3D Text
        6. Text as Region
      7. 15.7. SUMMARY
        1. Further Reading
        2. Sample Program
    18. 16. Metafile
      1. 16.1. METAFILE BASICS
        1. Creating an Enhanced Metafile
        2. Playing an Enhanced Metafile
        3. Querying an Enhanced Metafile
        4. Exchanging an Enhanced Metafile
          1. Saving Drawings to an EMF File
          2. Loading an EMF from a Resource
          3. Putting an EMF on Static Control
          4. Exchanging with the Clipboard
      2. 16.2. INSIDE AN ENHANCED METAFILE
        1. EMF Records
        2. Classifying EMF Record Types
        3. Decoding EMF Records
        4. Simple GDI Objects in an EMF
        5. Bitmaps in an EMF
        6. Regions in an EMF
        7. Paths in an EMF
        8. Palettes in an EMF
        9. Coordinate Spaces in an EMF
        10. Draw Commands in an EMF
          1. Texts in an EMF
        11. EMF Device Independence
      3. 16.3. ENUMERATING AN EMF
        1. C++ Class for EMF Enumerating
        2. Slow Motion in an EMF Playback
        3. Tracing an EMF Playback
        4. Changing an EMF Dynamically
        5. Deriving an EMF from an EMF
          1. EMF Playback Details
          2. Undocumented EMF Record Types
          3. GDIComment
      4. 16.4. AN EMF AS A PROGRAMMING TOOL
        1. An EMF Decompiler
        2. Capture an EMF Spool File
      5. 16.5. SUMMARY
        1. Further Reading
        2. Sample Programs
    19. 17. Printing
      1. 17.1. UNDERSTANDING THE SPOOLER
        1. Printing Process
        2. Printer Control Language
          1. Text-Based Printer Control Language
          2. Raster-Based Printer Control Language
          3. Page Description Language
        3. Printing Directly to a Port
        4. Printing through the Spooler
        5. EMF Print Processor
        6. Enumerating Printers
        7. Querying a Printer
        8. Set Up a Printer Driver
      2. 17.2. BASIC PRINTING USING GDI
        1. Printing Common Dialog Boxes
        2. Creating Printer Device Context
        3. Querying Printer Device Context
        4. Outline of a Print Job
      3. 17.3. DESIGN FOR PRINTING
        1. Uniform Logical Coordinate Space
        2. Paper Simulation
        3. Multipage, Multicolumn Display
        4. Multipage Printing
        5. Generic Printing Class
      4. 17.4. DRAWING ON PRINTER DEVICE CONTEXT
        1. Coordinate Space Units
        2. Text
        3. Bitmap
        4. JPEG Image Printing
      5. 17.5. SUMMARY
        1. Further Reading
        2. Sample Programs
    20. 18. DirectDraw and Direct3D Immediate Mode
      1. 18.1. COMPONENT OBJECT MODEL (COM)
        1. COM Interface
        2. COM Class
        3. Creating a COM Object
        4. HRESULT
        5. DirectX and COM
      2. 18.2. DIRECTDRAW BASICS
        1. IDirectDraw7 Interface
        2. IDirectDrawSurface7 Interface
        3. Drawing on a DirectDraw Surface
          1. Hardware-Accelerated Drawing
          2. GDI Drawing
          3. Direct Pixel Access
        4. Color Matching
        5. IDirectDrawClipper Interface
        6. Simple DirectDraw Window
      3. 18.3. BUILDING A DIRECTDRAW GRAPHICS LIBRARY
        1. Pixel Drawing
        2. Line Drawing
        3. Area Fill
        4. Clipping
        5. Off-Screen Surface
        6. Transparency through Color Keying
        7. Font and Text
        8. Not Quite a Game
      4. 18.4. DIRECT3D IMMEDIATE MODE
        1. Creating a Direct3D Immediate Mode Environment
        2. Handling Window Resizing
        3. Two-Step Rendering
        4. Putting Direct3D into a Window
        5. Texture Surface
        6. A Direct3D Immediate Mode Sample
      5. 18.5. SUMMARY
        1. Further Reading
        2. Sample Programs