/// <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; }
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; }
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; }
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); }
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")); }
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; }
// // 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; } }
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; }
HRESULT CRMrender::CreateFactory() { HRESULT hr = S_FALSE; hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDisplayFactory); return hr; }
HRESULT MainApp::CreateDeviceIndependentResources() { HRESULT hr = S_OK; hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pDirect2dFactory); return hr; }
// 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; }
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_ )); }
/// <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; }
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()); }
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; }
VOID CreateD2DResource(HWND hWnd) { if (!g_pRenderTarget) { HRESULT hr ; hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &g_pD2DFactory) ; if (FAILED(hr)) { MessageBox(hWnd, "Create D2D factory failed!", "Error", 0) ; return ; } // Obtain the size of the drawing area RECT rc ; GetClientRect(hWnd, &rc) ; // Create a Direct2D render target hr = g_pD2DFactory->CreateHwndRenderTarget( D2D1::RenderTargetProperties(), D2D1::HwndRenderTargetProperties( hWnd, D2D1::SizeU(rc.right - rc.left,rc.bottom - rc.top) ), &g_pRenderTarget ) ; if (FAILED(hr)) { MessageBox(hWnd, "Create render target failed!", "Error", 0) ; return ; } // Create a brush hr = g_pRenderTarget->CreateSolidColorBrush( D2D1::ColorF(D2D1::ColorF::Black), &g_pBlackBrush ) ; if (FAILED(hr)) { MessageBox(hWnd, "Create brush failed!", "Error", 0) ; return ; } // Create a rectangle hr = g_pD2DFactory->CreateRectangleGeometry( D2D1::RectF(10, 10, 50, 50), &g_pRectangleGeometry ); if (FAILED(hr)) { MessageBox(hWnd, "Create rectangle geometry failed!", "Error", 0); return; } } }
HRESULT CMainWindow::CreateDeviceIndependentResources() { // Create a Direct2D factory HRESULT hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory ); return hr; }
void Factory::Init( FactoryType factoryType, DebugLevel debugLevel ) { ID2D1Factory *factory = NULL; D2D1_FACTORY_OPTIONS options; options.debugLevel = static_cast<D2D1_DEBUG_LEVEL>( debugLevel ); if( RECORD_D2D( D2D1CreateFactory( static_cast<D2D1_FACTORY_TYPE>( factoryType ), IID_ID2D1Factory, &options, (void**) &factory ) ).IsFailure ) throw gcnew Direct2DException( Result::Last ); Construct( factory ); }
HRESULT initDraw(void) { D2D1_FACTORY_OPTIONS opts; ZeroMemory(&opts, sizeof (D2D1_FACTORY_OPTIONS)); // TODO make this an option opts.debugLevel = D2D1_DEBUG_LEVEL_NONE; return D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, &opts, (void **) (&d2dfactory)); }
bool Graphics::InitGraphics(HWND hwnd) { HRESULT res = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory); if (res != S_OK) return false; RECT rect; GetClientRect(hwnd, &rect); res = factory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(), D2D1::HwndRenderTargetProperties(hwnd, D2D1::SizeU(rect.right, rect.bottom)), &renderTarget); if (res != S_OK) return false; return true; }
HRESULT FirstTry::CreateDeviceIndependentResources() { HRESULT hr = S_OK; // Create a Direct2D factory. hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory); if (SUCCEEDED(hr)) hr = CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pWICFactory)); return hr; }
/// <summary> /// Ensure the independent Direct2D resources have been created /// </summary> void EnsureIndependentResourcesCreated() { if (nullptr == g_pD2DFactory) { D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, &g_pD2DFactory); } if (nullptr == g_pDWriteFactory) { DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&g_pDWriteFactory)); } }
plx::ComPtr<ID2D1Factory2> CreateD2D1FactoryST(D2D1_DEBUG_LEVEL debug_level) { D2D1_FACTORY_OPTIONS options = {}; options.debugLevel = debug_level; plx::ComPtr<ID2D1Factory2> factory; auto hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, options, factory.GetAddressOf()); if (hr != S_OK) throw plx::ComException(__LINE__, hr); return factory; }
inline ComPtr<ID2D1Factory1> CreateD2DFactory() { D2D1_FACTORY_OPTIONS fo{}; #ifdef DEBUG fo.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION; #endif ComPtr<ID2D1Factory1> d2dFactory; HR(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, fo, d2dFactory.GetAddressOf())); return d2dFactory; }
/// <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 CCoordinateMappingBasics::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); // 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_pDrawCoordinateMapping = new ImageRenderer(); HRESULT hr = m_pDrawCoordinateMapping->Initialize(GetDlgItem(m_hWnd, IDC_VIDEOVIEW), m_pD2DFactory, cDepthWidth, cDepthHeight, cDepthWidth * sizeof(RGBQUAD)); if (FAILED(hr)) { SetStatusMessage(L"Failed to initialize the Direct2D draw device.", 10000, true); } // 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; // Handle button press case WM_COMMAND: // If it was for the screenshot control and a button clicked event, save a screenshot next frame if (IDC_BUTTON_SCREENSHOT == LOWORD(wParam) && BN_CLICKED == HIWORD(wParam)) { m_bSaveScreenshot = true; } break; } return FALSE; }
HRESULT ClixRenderer::CreateDIR() { HRESULT hr = S_OK; hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &D2Factory); if (SUCCEEDED(hr)) { hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&pDWriteFactory) ); } if (SUCCEEDED(hr)) { hr = pDWriteFactory->CreateTextFormat( L"Microsoft Sans Serif Regular", // Font family name. NULL, // Font collection (NULL sets it to use the system font collection). DWRITE_FONT_WEIGHT_REGULAR, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 15.0f, L"en-us", &pTextFormat ); } // Center align (horizontally) the text. if (SUCCEEDED(hr)) { hr = pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING); } if (SUCCEEDED(hr)) { hr = pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); } #ifdef CONSOLE if (SUCCEEDED(hr)) std::wcout << "DeviceIndependendResources Succesfully created!" << std::endl; else std::wcout << "DeviceIndependedResources Error: " << std::hex << hr << std::endl; #endif return hr; }
HRESULT CAshaD2D::CreateFactory(void) { HRESULT hr=S_OK; //Initialize com CoInitializeEx(NULL,COINIT_MULTITHREADED); //Create WIC factory hr=CoCreateInstance(CLSID_WICImagingFactory1,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&m_pWICImgFactory)); //Create D2D factory if(SUCCEEDED(hr)) hr=D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED,&m_pD2D1Facatory); //Create DWrite factory if(SUCCEEDED(hr)) hr=DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,__uuidof(IDWriteFactory),reinterpret_cast<IUnknown**>(&m_pDWriteFactory)); return hr; }
BOOL ResonanceStudioDraw::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs // Added code for factory here--odd place to put it. HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pFactory); if ( FAILED(hr)) return FALSE; ptheDrawTimeFrequencyGrid = new DrawTimeFrequencyGrid(); if ( !ptheDrawTimeFrequencyGrid->Initialize( 10.0 ) ) return FALSE; return TRUE; }
opengl_window::opengl_window(i_rendering_engine& aRenderingEngine, i_surface_manager& aSurfaceManager, i_native_window_event_handler& aEventHandler) : native_window(aRenderingEngine, aSurfaceManager), iEventHandler(aEventHandler), iLogicalCoordinateSystem(neogfx::logical_coordinate_system::AutomaticGui), iFrameRate(60), iFrameCounter(0), iLastFrameTime(0), iRendering(false) { #ifdef _WIN32 ID2D1Factory* m_pDirect2dFactory; D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory); FLOAT dpiX, dpiY; m_pDirect2dFactory->GetDesktopDpi(&dpiX, &dpiY); iPixelDensityDpi = size(static_cast<size::dimension_type>(dpiX), static_cast<size::dimension_type>(dpiY)); #endif }
/// <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 CSkeletonBasics::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); // Look for a connected Kinect, and create it if found CreateFirstConnected(); } 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_SEATED == LOWORD(wParam) && BN_CLICKED == HIWORD(wParam)) { // Toggle out internal state for near mode m_bSeatedMode = !m_bSeatedMode; if (NULL != m_pNuiSensor) { // Set near mode for sensor based on our internal state m_pNuiSensor->NuiSkeletonTrackingEnable(m_hNextSkeletonEvent, m_bSeatedMode ? NUI_SKELETON_TRACKING_FLAG_ENABLE_SEATED_SUPPORT : 0); } } break; } return FALSE; }