Recent from talks
Nothing was collected or created yet.
DirectDraw
View on WikipediaThis article needs additional citations for verification. (January 2009) |
DirectDraw (ddraw.dll) is an API that used to be a part of Microsoft's DirectX API. DirectDraw is used to accelerate rendering of 2D graphics in applications. DirectDraw also allows applications to run fullscreen or embedded in a window such as most other MS Windows applications. DirectDraw uses hardware acceleration if it is available on the client's computer. DirectDraw allows direct access to video memory, hardware overlays, hardware blitters, and page flipping. Its video memory manager can manipulate video memory with ease, taking full advantage of the blitting and color decompression capabilities of different types of display adapters.
Because DirectDraw is a 2D API, it contains commands for 2D rendering and although it does not support 3D hardware acceleration, versions through to 7.0 of DirectDraw are tightly coupled to their respective version of Direct3D. In order to utilize 3D acceleration in Direct3D 7.0 and below, DirectDraw must be used in order to create an IDirect3D interface with the help of IDirectDraw7->QueryInterface, from which comes an IDirect3DDevice, and from there the remainder of the Direct3D API can be accessed and utilized. DirectDraw provides Textures (through Surfaces), Clippers, Palettes and Pixel Formats to Direct3D as well as the final presentation pass to display rendered images to the screen.
DirectDraw was introduced for Windows Mobile in Windows Mobile 5.0, replacing the graphics component of GAPI, which was then deprecated.[1]
With the release of DirectX version 8.0, DirectDraw was merged into a new package called DirectX Graphics, which extended Direct3D with a few DirectDraw API additions. DirectDraw can still be used by programmers, and it can be compiled in 64-bit, but they must use older DirectX interfaces (DirectX 7 and below).
Drivers from NVIDIA, AMD and Intel provide hardware accelerated support for many of DirectDraw's fundamental features. However, due to changes in Windows Desktop Manager (DWM) in recent Windows versions, features such as Overlays are no longer supported at all.
In June 2010, DirectDraw was removed from the DirectX SDK package,[2] but in 2012, the DirectX SDK was merged into the Windows Platform SDK, and DirectDraw was included once again.
Replacement
[edit]There has been a deterioration of Windows compatibility with old games that rely upon DirectDraw, with Command & Conquer, Warcraft 2, and Theme Hospital among those affected. In newer Windows versions, some games will refuse to run under a 32-bit bit depth (Dangerous Waters for example), others showing a black screen or glitching when switched out. Re-implementation of DirectDraw has been observed to fix these compatibility problems. Commonly used replacements include:
- WineD3D from Wine, which translates into OpenGL.[3]
- cnc-ddraw and ts-ddraw from CnCNet, a Command & Conquer multiplayer network. Translates into GDI, OpenGL (with GLSL support), or Direct3D 9.[4]
- DDrawCompat, a wrapper for the vanilla ddraw that corrects problematic calls.[5] ddwrapper is an earlier, unrelated wrapper that does the same thing.[6]
See also
[edit]References
[edit]- ^ Saffitz, Michael (13 August 2007). "Have you migrated to DirectDraw yet?". Windows Mobile Team Blog. Retrieved 23 April 2019.
- ^ "DirectX 8 Graphics and Video: A Fresh Start". gamedev.net. 2000-11-30. Archived from the original on 2007-06-04. Retrieved 2019-04-23.
- ^ Dossena, Federico. "WineD3D For Windows". Federico Dossena. Retrieved 23 April 2019.
- ^ CnCNet (21 April 2019). "cnc-ddraw: GDI, OpenGL and Direct3D 9 re-implementation of the DirectDraw API for classic games for better compatibility with Windows XP, Vista, 7, 8, 10 and Wine". GitHub. Retrieved 23 April 2019.
- ^ narzoul (21 April 2019). "DDrawCompat: DirectDraw compatibility and performance enhancements for Windows Vista, 7, 8 and 10". GitHub. Retrieved 23 April 2019.
- ^ Aqrit. "ddwrapper". bitpatch.com.
External links
[edit]DirectDraw
View on GrokipediaIntroduction
Overview
DirectDraw, implemented in the ddraw.dll library, is a Component Object Model (COM)-based application programming interface (API) within the DirectX suite, specifically designed to accelerate 2D graphics rendering for applications and games on Microsoft Windows operating systems.[1][2].aspx) The API enables efficient handling of graphics operations by supporting both fullscreen and windowed rendering modes, direct access to video memory for faster data manipulation, hardware-accelerated overlays for video playback, blitters for bitmap transfers, and page flipping for smooth animations without tearing..aspx)[7] Introduced with DirectX 1.0 in 1995, DirectDraw formed a key part of Microsoft's early efforts to provide developers with low-level access to graphics hardware, facilitating hardware-accelerated multimedia experiences in software.[3][8] It integrates with other DirectX components, such as Direct3D, allowing applications to combine 2D and 3D rendering capabilities seamlessly.[8]Role in DirectX
DirectDraw formed one of the core foundational components of the DirectX API suite, alongside DirectSound for audio management and DirectInput for input device handling, with its primary focus on accelerating 2D graphics rendering in multimedia applications.) This specialization allowed developers to perform high-speed 2D operations directly in video memory, enabling efficient handling of raster graphics without the performance bottlenecks inherent in traditional system APIs.[1] A key aspect of DirectDraw's role was its tight integration with Direct3D through DirectX 7.0, where Direct3D objects were created via DirectDraw interfaces, and Direct3D leveraged DirectDraw surfaces for essential functions such as texture mapping and rendering targets.[9] This coupling ensured that 3D acceleration could build upon DirectDraw's 2D surface management, providing a unified pathway for graphics hardware interaction in early DirectX versions.[10] In the context of early Windows game development, DirectDraw played a pivotal role by circumventing the limitations of the Windows Graphics Device Interface (GDI), which was ill-suited for real-time, performance-critical 2D tasks like sprite blitting and user interface element rendering.) By granting direct access to display hardware and memory, it facilitated smoother frame rates and reduced latency, making it indispensable for games requiring responsive 2D visuals on consumer hardware of the era.[1]History
Origins and Introduction
DirectDraw was developed by Microsoft in 1994 as part of the internal "Manhattan Project," led by engineers Alex St. John, Craig Eisler, and Eric Engstrom, to establish Windows as a competitive platform for PC gaming against the dominant MS-DOS ecosystem.[11] This initiative addressed the limitations of the Graphics Device Interface (GDI), Windows' existing software-based rendering system, which imposed high latency and CPU overhead unsuitable for real-time 2D graphics in games, particularly on the forthcoming Windows 95 operating system.[11] By providing direct access to graphics hardware, DirectDraw aimed to enable low-latency operations essential for interactive applications like video games. The API was introduced in September 1995 as a core component of DirectX 1.0, released as the Windows 95 Game Software Development Kit (SDK) to developers.[12] This timing aligned with the launch of Windows 95 in August 1995, positioning DirectDraw to leverage the new OS's 32-bit architecture for enhanced multimedia support.[13] Although not bundled directly with the base Windows 95 release or the Plus! enhancement pack, the SDK was distributed through Microsoft's developer channels to facilitate rapid adoption by game creators.[14] Key motivations for DirectDraw's creation included enabling hardware acceleration for fundamental 2D operations such as blitting (fast bitmap transfers) and color keying (transparent overlays), which were critical for supporting the burgeoning PC gaming market in the mid-1990s.[11] These features allowed developers to bypass GDI's inefficiencies, delivering smoother performance on emerging graphics hardware from vendors like ATI and NVIDIA, and fostering industry-wide support for Windows-based titles.[13] As a foundational element of DirectX, DirectDraw set the stage for integrated multimedia APIs that would define PC gaming for decades.[11] Early adopters included titles like the Windows port of Descent, which utilized DirectDraw for improved 2D rendering and hardware acceleration shortly after the SDK's availability.[15]Evolution and Platform Integration
DirectDraw underwent significant evolution through successive versions of the DirectX API, progressing from the original IDirectDraw interface introduced in DirectX 1.0 to the enhanced IDirectDraw7 in DirectX 7.0, released on September 22, 1999.[16] This iteration extended prior capabilities by providing more flexible surface management, improved enumeration of display modes, and support for multiple monitor configurations, allowing applications to span surfaces across devices more effectively.[17] These advancements facilitated better handling of complex display setups in 2D graphics applications, building on earlier hardware acceleration foundations without altering the core architecture.[17] In 2005, DirectDraw expanded beyond desktop Windows with its integration into Windows Mobile 5.0, marking a pivotal adaptation for mobile platforms. Released to manufacturing in May 2005, this version of the operating system incorporated DirectDraw to replace the deprecated Graphics API (GAPI) component, introducing hardware-accelerated 2D graphics rendering for resource-constrained devices.[18] The shift enabled mobile applications to leverage DirectDraw's surfaces and blitting operations with GPU support, improving performance over GAPI's software-based approach while maintaining backward compatibility for legacy code.[19] By DirectX 8.0, released on November 9, 2000, DirectDraw's role began to transition as it merged into a unified graphics pipeline with Direct3D, emphasizing a consolidated API for both 2D and 3D handling.[20] This integration simplified development by streamlining interfaces, reducing redundancy, and promoting a single model for resource allocation and rendering, which shifted focus toward programmable shaders and broader multimedia support in Windows applications.[20] The change reflected evolving hardware trends, positioning DirectDraw's functionalities within a more cohesive DirectX Graphics framework.Architecture
Core Components and Interfaces
DirectDraw is built on the Component Object Model (COM) architecture, providing a standardized way to interact with graphics hardware through interface-based objects. The primary interface, IDirectDraw, serves as the entry point for creating and managing DirectDraw objects, with subsequent versions such as IDirectDraw2 through IDirectDraw7 introducing enhancements like improved surface handling and additional capabilities. Applications create a DirectDraw object using the DirectDrawCreate function, which returns an IDirectDraw interface pointer; to access later versions like IDirectDraw7, developers query for the desired interface using COM's QueryInterface method.[21][17] Key objects in DirectDraw include surfaces, clippers, palettes, and mechanisms for cooperative multitasking. Surfaces, represented by the IDirectDrawSurface7 interface (or earlier equivalents), are the fundamental units for rendering and data storage; they include primary surfaces for on-screen display, offscreen plain surfaces for temporary pixel data processing, and textured surfaces optimized for 3D texture mapping. These are created via the IDirectDraw7::CreateSurface method, specifying capabilities through a DDSURFACEDESC2 structure. Clippers, managed by the IDirectDrawClipper interface, handle clipping operations to restrict drawing to specific regions, such as window boundaries, and are created using the DirectDrawCreateClipper function. Palettes, via the IDirectDrawPalette interface, control color mapping for 8-bit surfaces and are generated with IDirectDraw7::CreatePalette, allowing dynamic color adjustments. Cooperative levels, set through IDirectDraw7::SetCooperativeLevel, enable multi-application coordination by defining access modes like DDSCL_NORMAL for windowed operation or DDSCL_EXCLUSIVE for full-screen control, ensuring shared resource management without conflicts.[22][23][24][25][26] The initialization process begins with creating the DirectDraw object, followed by enumerating available display modes using IDirectDraw7::EnumDisplayModes, which calls an application-defined callback to list hardware-supported resolutions and formats compatible with a given surface description. Developers then set the cooperative level to establish the application's interaction mode with the display device, such as windowed or exclusive full-screen, before proceeding to create surfaces and other objects. This sequence ensures proper setup for graphics operations, with hardware acceleration depending on driver support for the enumerated modes.[27]Hardware Interaction and Acceleration
DirectDraw facilitates direct access to video memory through its surface abstraction, allowing applications to create and manipulate surfaces that reside in the graphics card's display memory for optimal performance. This direct manipulation bypasses traditional GDI pathways, enabling efficient data transfers and rendering operations that leverage the hardware's capabilities. Surfaces can be locked to obtain pointers to the underlying memory, permitting developers to write pixel data directly, much like legacy DOS-era video memory access, while ensuring exclusive access during modifications to prevent conflicts with the display driver.[28][29] This architecture supports hardware-accelerated blitting and overlays via the driver's Hardware Abstraction Layer (HAL), which exposes the graphics hardware's features through capability queries in structures like DDCAPS. Hardware blitters handle efficient block transfers of pixel data between surfaces, while overlays provide low-latency compositing of video content atop the primary display, often with built-in support for stretching and color space conversions such as YCbCr to RGB. Major graphics vendors, including NVIDIA, AMD, and Intel, implement HAL drivers that enable these features, allowing DirectDraw applications to utilize specialized processors on the GPU for parallelism with CPU tasks and reduced latency in 2D rendering.[28][29] However, these hardware interactions face significant limitations in modern Windows environments starting with Vista, where the Desktop Window Manager (DWM) introduces compositing that conflicts with DirectDraw overlays. DWM does not account for hardware overlays during its rendering pipeline, resulting in overlays displaying as solid colorkey colors (e.g., green or magenta) instead of intended content, particularly on NVIDIA and ATI (AMD) hardware. This incompatibility forces applications to fall back to software emulation via the Hardware Emulation Layer (HEL), which lacks the performance benefits of direct hardware access and can degrade video playback or rendering efficiency. Overlay Mixer components in later DirectShow implementations mitigate this by disabling DWM when hardware overlays are detected, but DirectDraw-specific support remains broken without custom workarounds.[30][31]Features
2D Rendering Capabilities
DirectDraw provides core 2D rendering through its blitting operations, primarily via theBlt and BltFast methods on IDirectDrawSurface interfaces. The Blt function enables versatile bit block transfers between surfaces, supporting stretching and shrinking by specifying differing source and destination rectangles, which allows for scaled rendering of graphics elements like sprites or backgrounds. It also incorporates color keying for transparency effects, using flags such as DDBLT_KEYSRC for source color keys and DDBLT_KEYDEST for destination keys, enabling efficient compositing in games by ignoring specific colors during transfers. Additionally, Blt supports raster operations (ROPs) through the DDBLT_ROP flag, allowing logical operations like AND, OR, and XOR on pixel data, which facilitates advanced manipulations such as masking or inversion without additional CPU processing.[32]
The BltFast method offers a optimized variant for high-performance scenarios, performing source copy or transparent bitblts exclusively on display memory surfaces with hardware acceleration where available, attempting asynchronous execution to minimize latency. It supports basic color keying via flags like DDBLTFAST_SRCCOLORKEY and DDBLTFAST_DESTCOLORKEY but omits stretching, clipping, and ROPs to prioritize speed, making it suitable for rapid updates in real-time applications such as tile-based scrolling or particle effects. Both methods leverage hardware acceleration for these operations when the graphics driver reports support via capabilities queries, falling back to software emulation otherwise, which ensures consistent behavior across diverse hardware.[33]
DirectDraw supports a range of pixel formats for surfaces, including RGB formats like 16-bit 5-6-5 and 32-bit ARGB, as well as paletted 8-bit modes that use color tables for efficient memory usage in low-color environments. Texture surfaces created through DirectDraw can integrate directly with Direct3D by attaching them as render targets or textures, allowing 2D content to serve as base layers for 3D rendering pipelines. While pixel formats may include alpha channels (e.g., up to 8-bit alpha in ARGB), DirectDraw's blitting operations do not perform alpha blending; transparency relies on color keying instead. Hardware acceleration extends to format conversion during blits, including color space transformations like YUV to RGB, which aids in video playback by decompressing and converting frames efficiently for overlay or sprite rendering in multimedia applications.[34][35][36]
