Presentation is loading. Please wait.

Presentation is loading. Please wait.

Direct2D Karolis Jodikaitis.

Similar presentations


Presentation on theme: "Direct2D Karolis Jodikaitis."— Presentation transcript:

1 Direct2D Karolis Jodikaitis

2 Purpose Direct2D is a hardware-accelerated, immediate-mode, 2-D graphics API that provides high performance and high-quality rendering for 2-D geometry, bitmaps, and text. The Direct2D API is designed to interoperate well with GDI, GDI+, and Direct3D.

3 Overview Direct2D provides an API, similar to Direct3D, for use with C or C++. The API exposes a variety of drawing-related functionality: Render targets for display and off-screen rendering using Direct2D, Direct3D, or GDI. Objects for managing drawing state such as coordinate space transforms and antialiasing modes.

4 Overview(2) Direct2D provides an API, similar to Direct3D, for use with C or C++. The API exposes a variety of drawing-related functionality: Representations for geometric data, and functions for geometry processing. Rendering functionality for bitmaps, geometries, and text. Provisions for using graphical content created using GDI or Direct3D.

5 Main Pros The primary motivations for creating a new 2-D graphics API in Microsoft Windows include the following: To keep pace with the increasing level of visual richness that Windows users are accustomed to. To enable developers to write 2-D rendering code that scales directly with the graphics processing hardware of the PC it is running on. To enable developers to write code for rendering 2-D graphics that can run in the context of a service.

6 Direct2D Header Files The Direct2D API is defined by the following header files: To use Direct2D, your application should include the d2d1.h header file.

7 Direct2D Interfaces At the root of the Direct2D API are the ID2D1Factory and ID2D1Resource interfaces. An ID2D1Factory object creates ID2D1Resource objects and serves as the starting point for using Direct2D. All other Direct2D objects inherit from the ID2D1Resource interface.

8 ID2D1Factory The ID2D1Factory interface is the starting point for using Direct2D. You use an ID2D1Factory to instantiate Direct2D resources. One of the most useful objects a factory can create is the ID2D1RenderTarget.

9 Render Targets A render target is a resource that inherits from the ID2D1RenderTarget interface. A render target creates resources for drawing and performs drawing operations: ID2D1HwndRenderTarget objects render content to a window. ID2D1DCRenderTarget objects render to a GDI device context. Bitmap render target objects render content to an off-screen bitmap. Because a render target is associated with a particular rendering device, it is a device-dependent resource.

10 Render Target Resources
Render target can create drawing resources. Any resources created by a render target are device-dependent resources(just like the render target). It can create the following types of resources: Bitmaps Brushes Layers Meshes

11 Drawing Commands To render content, you use the render target drawing methods: Before you begin drawing, you call the BeginDraw method. After you finished drawing, you call the EndDraw method. In between these calls, you use Draw and Fill methods to render drawing resources.

12 Coordinate System Direct2D uses a left-handed coordinate system: positive x-axis values proceed to the right and positive y-axis values proceed downward.

13 Drawing Text Direct2D was designed to work with the text operations of the new text API, DirectWrite. To make using the DirectWrite API simpler, render targets provide three methods for rendering DirectWrite text resources: DrawText DrawTextLayout DrawGlyphRun

14 Visual Quality Applications that use Direct2D for graphics can deliver higher visual quality than GDI. Direct2D uses per-primitive antialiasing to deliver smoother looking curves and lines, transparency and alpha blending when rendering 2-D primitives.

15 Interoperability Applications that render content primarily with GDI, GDI+, or Direct3D, can begin by using Direct2D to render specific areas of their application, and over time move to a model where rendering is performed primarily via Direct2D, using GDI primarily for plug-ins or legacy extensibility.

16 Developer Audience Direct2D is designed primarily for use by the following classes of developers: Developers of large, enterprise-scale, native applications. Developers who create control toolkits and libraries for consumption by downstream developers. Developers who require server-side rendering of 2-D graphics. Developers who use Direct3D graphics and need simple, high-performance 2-D and text rendering for menus, UI elements, and HUDs.

17 Run-time Requirements
Windows 7 or Windows Vista with Service Pack 2 (SP2) and Platform Update for Windows Vista and later. Windows Server 2008 R2 or Windows Server 2008 with Service Pack 2 (SP2) and Platform Update for Windows Server 2008 and later.


Download ppt "Direct2D Karolis Jodikaitis."

Similar presentations


Ads by Google