当前位置: 首页>>代码示例>>C++>>正文


C++ D2D1CreateFactory函数代码示例

本文整理汇总了C++中D2D1CreateFactory函数的典型用法代码示例。如果您正苦于以下问题:C++ D2D1CreateFactory函数的具体用法?C++ D2D1CreateFactory怎么用?C++ D2D1CreateFactory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了D2D1CreateFactory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UNREFERENCED_PARAMETER

/// <summary>
/// Handle windows messages for the class instance
/// </summary>
/// <param name="hWnd">window message is for</param>
/// <param name="uMsg">message</param>
/// <param name="wParam">message data</param>
/// <param name="lParam">additional message data</param>
/// <returns>result of message processing</returns>
LRESULT CALLBACK CBodyBasics::DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(wParam);
    UNREFERENCED_PARAMETER(lParam);

    switch (message)
    {
    case WM_INITDIALOG:
    {
        // Bind application window handle
        m_hWnd = hWnd;

        // Init Direct2D
        D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory);

        // Get and initialize the default Kinect sensor
        InitializeDefaultSensor();
    }
    break;

    // If the titlebar X is clicked, destroy app
    case WM_CLOSE:
        DestroyWindow(hWnd);
        break;

    case WM_DESTROY:
        // Quit the main message pump
        PostQuitMessage(0);
        break;
    }

    return FALSE;
}
开发者ID:starwada,项目名称:K4W_Sample,代码行数:41,代码来源:BodyBasics.cpp

示例2: D2D1CreateFactory

BOOL DrawTimeFrequencyGrid::Initialize( float aFontSize )
{
	static const WCHAR msc_fontName[] = L"Verdana";
	fontSize = aFontSize;

	// Added code for factory here--odd place to put it.
	HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pFactory);
	if ( FAILED(hr)) return FALSE;
	
	// Create a DirectWrite factory.
	hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(pDWriteFactory),
            reinterpret_cast<IUnknown **>(&pDWriteFactory) );
	 if ( FAILED(hr)) return FALSE;

	 // Create a DirectWrite text format object.
     hr = pDWriteFactory->CreateTextFormat( msc_fontName, NULL,
            DWRITE_FONT_WEIGHT_NORMAL,
            DWRITE_FONT_STYLE_NORMAL,
            DWRITE_FONT_STRETCH_NORMAL,
            fontSize,
            L"", //locale
            &pTextFormat );
	 if ( FAILED(hr)) return FALSE;

	// Center the text horizontally and vertically.
	pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
	pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
	return TRUE;
}
开发者ID:johnkroeker,项目名称:ResonanceCore0,代码行数:29,代码来源:DrawTimeFrequencyGrid.cpp

示例3: nf_system_info

nf_system_info_t nf_system_info()
{
	float ppi_x = 0.0f, ppi_y = 0.0f;

	// instead of doing full initialization, let's just create a d2d1 factory
	if(!ctx.reference_counter)
	{
		HRESULT hr = 0;
		if(FAILED(hr = D2D1CreateFactory(
						D2D1_FACTORY_TYPE_SINGLE_THREADED,
						__uuidof(ID2D1Factory1),
						NULL,
						(void**)&ctx.d2d_factory)))
		{
			NF_ERROR("can't create d2d1 factory\n");
			ctx.d2d_factory = NULL;
		}
	}
	ctx.d2d_factory->GetDesktopDpi(&ppi_x, &ppi_y);
	if(!ctx.reference_counter && ctx.d2d_factory)
	{
		ctx.d2d_factory->Release();
		ctx.d2d_factory = NULL;
	}

	nf_system_info_t ret;
	ret.bitmap = NF_BITMAP_B8G8R8A8_UNORM_PMA;
	ret.max_width = NF_MAX_WIDTH;
	ret.max_height = NF_MAX_HEIGHT;
	ret.ppi_x = ppi_x;
	ret.ppi_y = ppi_y;
	return ret;
}
开发者ID:UIKit0,项目名称:nativefonts,代码行数:33,代码来源:nativefonts_dwrite.cpp

示例4: switch

LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_CREATE:
		if (FAILED(D2D1CreateFactory(
			D2D1_FACTORY_TYPE_SINGLE_THREADED, &pFactory)))
		{
			return -1;  // Fail CreateWindowEx.
		}
		return 0;

	case WM_DESTROY:
		DiscardGraphicsResources();
		SafeRelease(&pFactory);
		PostQuitMessage(0);
		return 0;

	case WM_PAINT:
		OnPaint();
		return 0;


	case WM_SIZE:
		Resize();
		return 0;
	}
	return DefWindowProc(m_hwnd, uMsg, wParam, lParam);
}
开发者ID:nstoker,项目名称:LearnWindowsGUI1,代码行数:29,代码来源:winmain.cpp

示例5: assert

void CDirect2D::init(){

	std::cout << "Direct2D initialization: \n";
	assert(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory) == S_OK);
	std::cout << "d2d1 factory created \n";

	assert(m_hwnd);
	
	RECT rc;
	GetClientRect(m_hwnd, &rc);

	HRESULT hr = m_pDirect2dFactory->CreateHwndRenderTarget(
		D2D1::RenderTargetProperties(),
		D2D1::HwndRenderTargetProperties(m_hwnd, D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top)),
		&pRenderTarget);

	//pRenderTarget->CreateSolidColorBrush(
	//	D2D1::ColorF(D2D1::ColorF::Black),
	//	&m_pBlackBrush);

	//renderObj = new CRenderObject(L"test.png");

	//renderObjectsList = new std::vector<CRenderObject *>;
	//renderObjectsList.push_back(new CRenderObject(L"test.png"));
		
}
开发者ID:kap1ec,项目名称:d2d1,代码行数:26,代码来源:CDirect2D.cpp

示例6: D2D1CreateFactory

bool NND2DRenderer::Init()
{
	HRESULT hr;
	hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_ipD2DFactory );
	if ( hr != S_OK )
	{
		return false;
	}

	HWND hwnd = NNApplication::GetInstance()->GetHWND();
	RECT rt;
	GetClientRect( hwnd, &rt );
	D2D1_SIZE_U size = D2D1::SizeU( rt.right-rt.left, rt.bottom-rt.top );

	hr = m_ipD2DFactory->CreateHwndRenderTarget( D2D1::RenderTargetProperties(),
												 D2D1::HwndRenderTargetProperties( hwnd, size ),
												 &m_ipRenderTarget );

	if ( hr != S_OK )
	{
		return false;
	}

	return true;
}
开发者ID:agebreak,项目名称:Sample_2DFighter,代码行数:25,代码来源:NND2DRenderer.cpp

示例7: main

//
// Program starts here
//
int main( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
	HRESULT hr = D2D1CreateFactory(
					 D2D1_FACTORY_TYPE_SINGLE_THREADED,
					 &g_pD2DFactory
				 );
	hr = DWriteCreateFactory(
			 DWRITE_FACTORY_TYPE_SHARED,
			 __uuidof( IDWriteFactory ),
			 reinterpret_cast<IUnknown**>( &g_pDWriteFactory )
		 );
	hr = CoInitialize( NULL );
	hr = CoCreateInstance(
			 CLSID_WICImagingFactory,
			 NULL,
			 CLSCTX_INPROC_SERVER,
			 IID_IWICImagingFactory,
			 reinterpret_cast<void**>( &g_pWICFactory )
		 );
	g_pHWND = CreateGameWindow();
	createDeviceResources();
	//
	// Create a GWEN Direct2D renderer
	//
	g_pRenderer = new gwen::Renderer::Direct2D( g_pRT, g_pDWriteFactory, g_pWICFactory );
	runSample();
	delete g_pRenderer;
	g_pRenderer = NULL;

	if ( g_pRT != NULL )
	{
		g_pRT->Release();
		g_pRT = NULL;
	}
}
开发者ID:MegaThorx,项目名称:GWEN,代码行数:38,代码来源:Direct2DSample.cpp

示例8: Direct2DRendererPrivate

    Direct2DRendererPrivate():
        VideoRendererPrivate()
      , d2d_factory(0)
      , render_target(0)
      , bitmap(0)
      , bitmap_width(0)
      , bitmap_height(0)
      , interpolation(D2D1_BITMAP_INTERPOLATION_MODE_LINEAR)
    {
        dll.setFileName(QStringLiteral("d2d1"));
        if (!dll.load()) {
            available = false;
            qWarning("Direct2D is disabled. Failed to load 'd2d1.dll': %s", dll.errorString().toUtf8().constData());
            return;
        }
        typedef HRESULT (WINAPI *D2D1CreateFactory_t)(D2D1_FACTORY_TYPE, REFIID, const D2D1_FACTORY_OPTIONS *, void **ppIFactory);
        D2D1CreateFactory_t D2D1CreateFactory;
        D2D1CreateFactory = (D2D1CreateFactory_t)dll.resolve("D2D1CreateFactory");
        if (!D2D1CreateFactory) {
            available = false;
            qWarning("Direct2D is disabled. Failed to resolve symble 'D2D1CreateFactory': %s", dll.errorString().toUtf8().constData());
            return;
        }

        D2D1_FACTORY_OPTIONS factory_opt = { D2D1_DEBUG_LEVEL_NONE };
        /*
         * d2d is accessed by AVThread and GUI thread, so we use D2D1_FACTORY_TYPE_MULTI_THREADED
         * and let d2d to deal with the thread safe problems. otherwise, if we use
         * D2D1_FACTORY_TYPE_SINGLE_THREADED, we must use lock when copying ID2D1Bitmap and calling EndDraw.
         */
        /// http://msdn.microsoft.com/en-us/library/windows/desktop/dd368104%28v=vs.85%29.aspx
        HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED
                                       , (REFIID)IID_ID2D1Factory
                                       , &factory_opt
                                       , (void**)&d2d_factory);
        if (FAILED(hr)) {
            available = false;
            qWarning("Direct2D is disabled. Create d2d factory failed");
            return;
        }
        FLOAT dpiX, dpiY;
        d2d_factory->GetDesktopDpi(&dpiX, &dpiY);
        //gcc: extended initializer lists only available with -std=c++11 or -std=gnu++11
        //vc: http://msdn.microsoft.com/zh-cn/library/t8xe60cf(v=vs.80).aspx
        /*pixel_format = {
            DXGI_FORMAT_B8G8R8A8_UNORM,
            D2D1_ALPHA_MODE_IGNORE
        };*/
        pixel_format.format = DXGI_FORMAT_B8G8R8A8_UNORM;
        pixel_format.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;//D2D1_ALPHA_MODE_IGNORE;
        /*bitmap_properties = {
            pixel_format,
            dpiX,
            dpiY
        };*/
        bitmap_properties.pixelFormat = pixel_format;
        bitmap_properties.dpiX = dpiX;
        bitmap_properties.dpiY = dpiY;
    }
开发者ID:Andytianya,项目名称:QtAV,代码行数:59,代码来源:Direct2DRenderer.cpp

示例9: D2D1CreateFactory

HRESULT CRMrender::CreateFactory()
{
	HRESULT hr = S_FALSE;

	hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDisplayFactory);

	return hr;
}
开发者ID:superhakgoman,项目名称:oldboy,代码行数:8,代码来源:RMrender.cpp

示例10: D2D1CreateFactory

HRESULT MainApp::CreateDeviceIndependentResources()
{
	HRESULT hr = S_OK;

	hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pDirect2dFactory);

	return hr;
}
开发者ID:zorkzorkus,项目名称:zorkmonsters,代码行数:8,代码来源:Direct2DMain.cpp

示例11: D2D1CreateFactory

// Creates resources that are not bound to a particular device.
// Their lifetime effectively extends for the duration of the
// application.
HRESULT DemoApp::CreateDeviceIndependentResources()
{
    HRESULT hr = S_OK;

    // Create a Direct2D factory.
    hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory);

    return hr;
}
开发者ID:MarkoFilipovic,项目名称:Playground,代码行数:12,代码来源:DemoApp.cpp

示例12: defined

  void seq_tab_dialog::create_device_independent_resources()
  {
    // Direct2DFactory の生成
    if(!d2d_factory_){
#if defined(DEBUG) || defined(_DEBUG)
      D2D1_FACTORY_OPTIONS options;
      options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION ;
      THROW_IFERR(D2D1CreateFactory(
        D2D1_FACTORY_TYPE_SINGLE_THREADED,
        options,
        d2d_factory_.GetAddressOf()
        ));
#else
      THROW_IFERR(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &d2d_factory_));
#endif

    }

    if(!write_factory_){
      THROW_IFERR(::DWriteCreateFactory(
        DWRITE_FACTORY_TYPE_SHARED,
        __uuidof(IDWriteFactory),
        reinterpret_cast<IUnknown**>(write_factory_.GetAddressOf())
        ));
    }


    //wic_imaging_factory_.CreateInstance(CLSID_WICImagingFactory);

    //thunk_proc_ = (WNDPROC)thunk_.getCode();
    layout_rect_ = D2D1::RectF(0.0f,100.0f,400.0f,100.0f);
    // Text Formatの作成
    THROW_IFERR(write_factory_->CreateTextFormat(
      L"MS GOTHIC",                // Font family name.
      NULL,                       // Font collection (NULL sets it to use the system font collection).
      DWRITE_FONT_WEIGHT_BOLD,
      DWRITE_FONT_STYLE_NORMAL,
      DWRITE_FONT_STRETCH_NORMAL,
      12.0f,
      L"ja-jp",
      &write_text_format_
      ));

  }
开发者ID:sfpgmr,项目名称:seqx,代码行数:44,代码来源:seq_tab_dialog.cpp

示例13: switch

/// <summary>
/// Handle windows messages for the class instance
/// </summary>
/// <param name="hWnd">window message is for</param>
/// <param name="uMsg">message</param>
/// <param name="wParam">message data</param>
/// <param name="lParam">additional message data</param>
/// <returns>result of message processing</returns>
LRESULT CALLBACK Direct2DWindow::DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG:
        {
            // Bind application window handle
            m_hWnd = hWnd;

            // Init Direct2D
            D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory);

            // Create and initialize a new Direct2D image renderer (take a look at ImageRenderer.h)
            // We'll use this to draw the data we receive from the Kinect to the screen
            m_pDrawDepth = new ImageRenderer();
            HRESULT hr = m_pDrawDepth->Initialize(GetDlgItem(m_hWnd, IDC_VIDEOVIEW),
                                                  m_pD2DFactory,
                                                  m_cdmap->GetFieldWidth(),
                                                  m_cdmap->GetFieldHeight(),
                                                  m_cdmap->GetFieldWidth() * sizeof(long));
            if (FAILED(hr))
            {
                SetStatusMessage(L"Failed to initialize the Direct2D draw device.");
            }
        }
        break;

        // If the titlebar X is clicked, destroy app
        case WM_CLOSE:
            DestroyWindow(hWnd);
            break;

        case WM_DESTROY:
            // Quit the main message pump
            PostQuitMessage(0);
            break;

        // Handle button press
        case WM_COMMAND:
            // If it was for the near mode control and a clicked event, change near mode
            if (IDC_CHECK_NEARMODE == LOWORD(wParam) && BN_CLICKED == HIWORD(wParam))
            {
                // Toggle out internal state for near mode
                //m_bNearMode = !m_bNearMode;

                //if (NULL != m_pNuiSensor)
                //{
                //    // Set near mode based on our internal state
                //    m_pNuiSensor->NuiImageStreamSetImageFrameFlags(m_pDepthStreamHandle, m_bNearMode ? NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE : 0);
                //}
            }
            break;
    }

    return FALSE;
}
开发者ID:vernonrj,项目名称:robotics-kinect,代码行数:64,代码来源:KinectNui.cpp

示例14: SharedD2DFactory

    SharedD2DFactory()
    {
        jassertfalse; //xxx Direct2D support isn't ready for use yet!

        D2D1CreateFactory (D2D1_FACTORY_TYPE_SINGLE_THREADED, d2dFactory.resetAndGetPointerAddress());
        DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), (IUnknown**) directWriteFactory.resetAndGetPointerAddress());

        if (directWriteFactory != nullptr)
            directWriteFactory->GetSystemFontCollection (systemFonts.resetAndGetPointerAddress());
    }
开发者ID:adscum,项目名称:MoogLadders,代码行数:10,代码来源:juce_win32_Direct2DGraphicsContext.cpp

示例15: defined

HRESULT App::CreateDeviceIndependentResources()
{
	HRESULT hr;

	// Create a Direct2D factory.
#if defined(DEBUG) || defined(_DEBUG)
	D2D1_FACTORY_OPTIONS options;
	options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;

	hr = D2D1CreateFactory(
		D2D1_FACTORY_TYPE_SINGLE_THREADED,
		options,
		&D2D_Factory
		);
#else
	hr = D2D1CreateFactory(
		D2D1_FACTORY_TYPE_MULTI_THREADED,
		&D2D_Factory
		);
#endif
	if (SUCCEEDED(hr))
	{
		// Create WIC factory.
		hr = CoCreateInstance(
			CLSID_WICImagingFactory,
			NULL,
			CLSCTX_INPROC_SERVER,
			IID_PPV_ARGS(&WIC_Factory)
			);
	}

	if (SUCCEEDED(hr))
	{
		// Create a DirectWrite factory.
		hr = DWriteCreateFactory(
			DWRITE_FACTORY_TYPE_SHARED,
			__uuidof(DW_Factory),
			reinterpret_cast<IUnknown **>(&DW_Factory)
			);
	}

    return hr;
}
开发者ID:Three141,项目名称:PectoStudioNFC,代码行数:43,代码来源:Main.cpp


注:本文中的D2D1CreateFactory函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。