daapost.blogg.se

Direct2d api windows xp
Direct2d api windows xp










The D2D1_FACTORY_TYPE enum defines both D2D1_FACTORY_TYPE_SINGLE_THREADED and D2D1_FACTORY_TYPE_MULTI_THREADED constants, but these have nothing to do with COM apartments and don't assume any thread affinity. I normally include Direct2D in a project by adding the following directives in the project's precompiled header: #include #include #pragma comment(lib, "d2d1.lib")Īs I mentioned, Direct2D does not rely on COM, but the first parameter to D2D1CreateFactory might lead you to believe otherwise. The d2d1helper.h header file also provides a great many helpful functions and classes to simply the use of Direct2D from C++. The d2d1.lib file is provided to import the D2D1CreateFactory function. Of course, before you can use any of these types, you need to include d2d1.h, the Direct2D header file, which declares the various Direct2D interfaces, structures, and constants as well as the D2D1CreateFactory function.

direct2d api windows xp direct2d api windows xp

The D2D1CreateFactory function returns an implementation of the ID2D1Factory interface: CComPtr factory HR(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory)) I would suggest that you use ATL's CComPtr smart pointer class for managing the interface pointers, as I do in the examples in this article.Įvery Direct2D application begins by creating a factory object. Unless otherwise noted, Direct2D will work only with its own implementations. Keep in mind that just because Direct2D uses COM interfaces does not mean that you can provide your own implementations of those interfaces. It's just a convention to simplify resource management and allow APIs and applications to expose and consume objects in a well-defined way. There's no need to initialize the COM run time and worry about apartments or proxies. SidebarInsights Īs with various other APIs like Direct3D and XmlLite, Direct2D uses a lightweight version of the COM specification to manage object lifetime through interfaces derived from IUnknown. Volume 24 Number 06 Windows With C++ - Introducing Direct2D












Direct2d api windows xp