diff --git a/saco/d3d9/common/DXUTgui.cpp b/saco/d3d9/common/DXUTgui.cpp index 77fb1c4..e669314 100644 --- a/saco/d3d9/common/DXUTgui.cpp +++ b/saco/d3d9/common/DXUTgui.cpp @@ -219,6 +219,42 @@ VOID CDXUTDialog::SendEvent( UINT nEvent, bool bTriggeredByUser, CDXUTControl* p } +//-------------------------------------------------------------------------------------- +int CDXUTDialogResourceManager::AddFont( LPCTSTR strFaceName, LONG height, LONG weight ) +{ + // See if this font already exists + for( int i=0; i < m_FontCache.GetSize(); i++ ) + { + DXUTFontNode* pFontNode = m_FontCache.GetAt(i); + if( 0 == _strnicmp( pFontNode->strFace, strFaceName, MAX_PATH-1 ) && + pFontNode->nHeight == height && + pFontNode->nWeight == weight ) + { + return i; + } + } + + // Add a new font and try to create it + DXUTFontNode* pNewFontNode = new DXUTFontNode(); + if( pNewFontNode == NULL ) + return -1; + + ZeroMemory( pNewFontNode, sizeof(DXUTFontNode) ); + StringCchCopy( pNewFontNode->strFace, MAX_PATH, strFaceName ); + pNewFontNode->nHeight = height; + pNewFontNode->nWeight = weight; + m_FontCache.Add( pNewFontNode ); + + int iFont = m_FontCache.GetSize()-1; + + // If a device is available, try to create immediately + if( m_pd3dDevice ) + CreateFont( iFont ); + + return iFont; +} + + //-------------------------------------------------------------------------------------- // CDXUTControl class //-------------------------------------------------------------------------------------- diff --git a/saco/d3d9/common/DXUTgui.h b/saco/d3d9/common/DXUTgui.h index f399adb..e92e6f6 100644 --- a/saco/d3d9/common/DXUTgui.h +++ b/saco/d3d9/common/DXUTgui.h @@ -181,6 +181,8 @@ public: HRESULT OnResetDevice(); void OnLostDevice(); void OnDestroyDevice(); + + int AddFont( LPCTSTR strFaceName, LONG height, LONG weight ); // Shared between all dialogs IDirect3DStateBlock9* m_pStateBlock;