---恢复内容开始---
Direct2D是一个函数库,结构库,类库?
函数被管理在不同的接口里面,要使用接口里面的函数,需要先实例化接口。
Direct2D的绘图机制(简单):
第一:获得虚拟画面(呈现器)。
第二:获得画刷。
第三:使用画刷在虚拟画面上画图。
其中,画面(资源),画刷(资源),画画(函数)等,都在Direct2D里面产生。并通过相应的接口管理。
ID2D1Factory -> ID2D1RenderTarget ->ID2D1Brush
->DrawLine
->Fill
->Draw
[工厂]->[呈现器]->[画笔]
->[画线]
->[描画轮廓]
->[填充轮廓]
->[呈现文字]
实例化ID2D1Factory接口
template<class Factory> HRESULT D2D1CreateFactory( __in D2D1_FACTORY_TYPE factoryType,//控制是否单线程 __out Factory **factory );//暂时了解到的创建方法.
HRESULT hr = S_OK;
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory);
实例化ID2D1RenderTarget接口
virtual HRESULT CreateHwndRenderTarget( [in] D2D1_RENDER_TARGET_PROPERTIES *renderTargetProperties, [in] D2D1_HWND_RENDER_TARGET_PROPERTIES *hwndRenderTargetProperties, //绑定窗口的句柄 [out] ID2D1HwndRenderTarget **hwndRenderTarget ) = 0;
RECT rc;
HRESULT hr = S_OK;
GetClientRect(m_hwnd, &rc); D2D1_SIZE_U size = D2D1::SizeU( rc.right - rc.left, rc.bottom - rc.top ); hr = m_pDirect2dFactory->CreateHwndRenderTarget( D2D1::RenderTargetProperties(), D2D1::HwndRenderTargetProperties(m_hwnd, size), &m_pRenderTarget );
---恢复内容开始---
Direct2D是一个函数库,结构库,类库?
函数被管理在不同的接口里面,要使用接口里面的函数,需要先实例化接口。
Direct2D的绘图机制(简单):
第一:获得虚拟画面(呈现器)。
第二:获得画刷。
第三:使用画刷在虚拟画面上画图。
其中,画面(资源),画刷(资源),画画(函数)等,都在Direct2D里面产生。并通过相应的接口管理。
使用Direct2D的函数,必须先获得里面的接口。
其中,ID2D1Factory接口是Direct2D的入口。共四种创建方法。
template<class Factory> HRESULT D2D1CreateFactory( __in D2D1_FACTORY_TYPE factoryType,//控制是否单线程 __out Factory **factory );//暂时了解到的创建方法.
template<class Factory> HRESULT D2D1CreateFactory( __in D2D1_FACTORY_TYPE factoryType,//控制是否单线程 __in CONST D2D1_FACTORY_OPTIONS &factoryOptions, __out Factory **factory );
HRESULT WINAPI D2D1CreateFactory(D2D1_FACTORY_TYPE,REFIID,**void)( __in D2D1_FACTORY_TYPE factoryType,//控制是否单线程 __in REFIID riid, __out void **ppIFactory );
HRESULT WINAPI D2D1CreateFactory( __in D2D1_FACTORY_TYPE factoryType,//控制是否单线程 __in REFIID riid, __in_opt const D2D1_FACTORY_OPTIONS *pFactoryOptions, __out void **ppIFactory );
---恢复内容结束---
原文:http://www.cnblogs.com/hxml/p/5184669.html