// Init glyph provider HRESULT CFW1TextGeometry::initTextGeometry(IFW1Factory *pFW1Factory) { HRESULT hResult = initBaseObject(pFW1Factory); if(FAILED(hResult)) return hResult; return hResult; }
// Init HRESULT CFW1GlyphVertexDrawer::initVertexDrawer( IFW1Factory *pFW1Factory, ID3D11Device *pDevice, UINT vertexBufferSize ) { HRESULT hResult = initBaseObject(pFW1Factory); if(FAILED(hResult)) return hResult; if(pDevice == NULL) return E_INVALIDARG; pDevice->AddRef(); m_pDevice = pDevice; D3D_FEATURE_LEVEL featureLevel = m_pDevice->GetFeatureLevel(); m_vertexBufferSize = 4096 * 16; if(vertexBufferSize >= 1024) { if(featureLevel < D3D_FEATURE_LEVEL_9_2) vertexBufferSize = std::min(vertexBufferSize, 512U*1024U); m_vertexBufferSize = vertexBufferSize; } m_maxIndexCount = (m_vertexBufferSize * 3) / (2 * sizeof(QuadVertex)); if(m_maxIndexCount < 64) m_maxIndexCount = 64; // Create device buffers hResult = createBuffers(); if(SUCCEEDED(hResult)) hResult = S_OK; return hResult; }
// Init HRESULT CFW1ColorRGBA::initColor(IFW1Factory *pFW1Factory, UINT32 initialColor32) { HRESULT hResult = initBaseObject(pFW1Factory); if(FAILED(hResult)) return hResult; m_color32 = initialColor32; return S_OK; }
// Init HRESULT CFW1FontWrapper::initFontWrapper( IFW1Factory *pFW1Factory, ID3D11Device *pDevice, IFW1GlyphAtlas *pGlyphAtlas, IFW1GlyphProvider *pGlyphProvider, IFW1GlyphVertexDrawer *pGlyphVertexDrawer, IFW1GlyphRenderStates *pGlyphRenderStates, IDWriteFactory *pDWriteFactory, const FW1_DWRITEFONTPARAMS *pDefaultFontParams ) { HRESULT hResult = initBaseObject(pFW1Factory); if(FAILED(hResult)) return hResult; if( pDevice == NULL || pGlyphAtlas == NULL || pGlyphProvider == NULL || pGlyphVertexDrawer == NULL || pGlyphRenderStates == NULL || pDWriteFactory == NULL ) return E_INVALIDARG; pDevice->AddRef(); m_pDevice = pDevice; m_featureLevel = m_pDevice->GetFeatureLevel(); pDWriteFactory->AddRef(); m_pDWriteFactory = pDWriteFactory; pGlyphAtlas->AddRef(); m_pGlyphAtlas = pGlyphAtlas; pGlyphProvider->AddRef(); m_pGlyphProvider = pGlyphProvider; pGlyphRenderStates->AddRef(); m_pGlyphRenderStates = pGlyphRenderStates; pGlyphVertexDrawer->AddRef(); m_pGlyphVertexDrawer = pGlyphVertexDrawer; // Create default text format for strings, if provided if(pDefaultFontParams->pszFontFamily != NULL && pDefaultFontParams->pszFontFamily[0] != 0) { IDWriteTextFormat *pTextFormat; hResult = m_pDWriteFactory->CreateTextFormat( pDefaultFontParams->pszFontFamily, NULL, pDefaultFontParams->FontWeight, pDefaultFontParams->FontStyle, pDefaultFontParams->FontStretch, 32.0f, (pDefaultFontParams->pszLocale != NULL) ? pDefaultFontParams->pszLocale : L"", &pTextFormat ); if(FAILED(hResult)) { m_lastError = L"Failed to create DWrite text format"; } else { m_pDefaultTextFormat = pTextFormat; m_defaultTextInited = true; hResult = S_OK; } } return hResult; }
// Init HRESULT CFW1GlyphRenderStates::initRenderResources( IFW1Factory *pFW1Factory, ID3D11Device *pDevice, bool wantGeometryShader, bool anisotropicFiltering ) { HRESULT hResult = initBaseObject(pFW1Factory); if(FAILED(hResult)) return hResult; if(pDevice == NULL) return E_INVALIDARG; pDevice->AddRef(); m_pDevice = pDevice; m_featureLevel = m_pDevice->GetFeatureLevel(); // D3DCompiler #ifdef FW1_DELAYLOAD_D3DCOMPILER_XX_DLL HMODULE hD3DCompiler = LoadLibrary(D3DCOMPILER_DLL); if(hD3DCompiler == NULL) { DWORD dwErr = GetLastError(); dwErr; m_lastError = std::wstring(L"Failed to load ") + D3DCOMPILER_DLL_W; hResult = E_FAIL; } else { m_pfnD3DCompile = reinterpret_cast<pD3DCompile>(GetProcAddress(hD3DCompiler, "D3DCompile")); if(m_pfnD3DCompile == NULL) { DWORD dwErr = GetLastError(); dwErr; m_lastError = std::wstring(L"Failed to load D3DCompile from ") + D3DCOMPILER_DLL_W; hResult = E_FAIL; } else { hResult = S_OK; } } #else m_pfnD3DCompile = D3DCompile; hResult = S_OK; #endif // Create all needed resources if(SUCCEEDED(hResult)) hResult = createQuadShaders(); if(SUCCEEDED(hResult)) hResult = createPixelShaders(); if(SUCCEEDED(hResult)) hResult = createConstantBuffer(); if(SUCCEEDED(hResult)) hResult = createRenderStates(anisotropicFiltering); if(SUCCEEDED(hResult) && wantGeometryShader) { hResult = createGlyphShaders(); if(FAILED(hResult)) hResult = S_OK; } if(SUCCEEDED(hResult)) hResult = S_OK; #ifdef FW1_DELAYLOAD_D3DCOMPILER_XX_DLL FreeLibrary(hD3DCompiler); #endif return hResult; }