Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CRender::Text( int x , int y , bool center , bool shadow , int font, Color color , const char* format , ... )
- {
- if ( m_pStateBlockText )
- m_pStateBlockText->Capture();
- m_pDevice->SetFVF( D3DFVF_CUSTOM_TEXT );
- m_pDevice->SetRenderState( D3DRS_LIGHTING , false );
- m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE , true );
- m_pDevice->SetRenderState( D3DRS_ALPHATESTENABLE , false );
- m_pDevice->SetRenderState( D3DRS_CULLMODE , D3DCULL_NONE );
- m_pDevice->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );
- m_pDevice->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );
- char Buffer[128] = { '\0' };
- va_list va_alist;
- va_start( va_alist , format );
- vsprintf_s( Buffer , format , va_alist );
- va_end( va_alist );
- BSTR text = CSX::Utils::ConvertStringToBSTR_UTF8( Buffer );
- DWORD dxTextColor = D3DCOLOR_XRGB( color.r() , color.g() , color.b() );
- auto drawShadow = [&]( RECT rect )
- {
- rect.left++;
- m_pFont[font]->DrawTextW( NULL , text , -1 , &rect , DT_TOP | DT_LEFT | DT_NOCLIP , 0xFF000000 );
- rect.top++;
- m_pFont[font]->DrawTextW( NULL , text , -1 , &rect , DT_TOP | DT_LEFT | DT_NOCLIP , 0xFF000000 );
- };
- if ( center )
- {
- RECT rec = { 0,0,0,0 };
- m_pFont[font]->DrawTextW( NULL , text , -1 , &rec , DT_CALCRECT | DT_NOCLIP , dxTextColor );
- rec =
- {
- static_cast<LONG>( x ) - rec.right / 2,
- static_cast<LONG>( y ),
- 0,
- 0
- };
- if ( shadow )
- drawShadow( rec );
- m_pFont[font]->DrawTextW( NULL , text , -1 , &rec , DT_TOP | DT_LEFT | DT_NOCLIP , dxTextColor );
- }
- else
- {
- RECT rec =
- {
- static_cast<LONG>( x ),
- static_cast<LONG>( y ),
- 0,
- 0
- };
- if ( shadow )
- drawShadow( rec );
- m_pFont[font]->DrawTextW( NULL , text , -1 , &rec , DT_TOP | DT_LEFT | DT_NOCLIP , dxTextColor );
- }
- if ( m_pStateBlockText )
- m_pStateBlockText->Apply();
- SysFreeString( text );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement