本文整理汇总了C++中LPD3DXFONT::DrawTextW方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXFONT::DrawTextW方法的具体用法?C++ LPD3DXFONT::DrawTextW怎么用?C++ LPD3DXFONT::DrawTextW使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXFONT
的用法示例。
在下文中一共展示了LPD3DXFONT::DrawTextW方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Direct3DRender
void Direct3DRender(HWND hwnd)
{
gPD3DDevice->Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
gPD3DDevice->BeginScene();
InputUpdate();
MatrixSet();
RECT formatRect;
GetClientRect(hwnd, &formatRect);
for (int i = 0; i < gDwNumMtrl; i++)
{
gPD3DDevice->SetMaterial(&gPMaterial[i]);
gPD3DDevice->SetTexture(0, gPTexture[i]);
gPCharacter->DrawSubset(i);
}
int strLen = swprintf_s(gStrFPS, _T("FPS: %f"), 123.45f);
gPTextFPSFont->DrawTextW(nullptr, gStrFPS, strLen, &formatRect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(0, 239, 136));
strLen = sizeof(gStrAdapterDesc);
gPTextAdapterFont->DrawTextW(nullptr, gStrAdapterDesc, -1, &formatRect, DT_TOP | DT_LEFT, D3DCOLOR_XRGB(23, 23, 236));
formatRect.top = 30;
static wchar_t strInfo[256] = { 0 };
swprintf_s(strInfo, -1, L"模型坐标: (%.2f, %.2f, %.2f)", gMatWorld._41, gMatWorld._42, gMatWorld._43);
gPTextHelperFont->DrawText(NULL, strInfo, -1, &formatRect, DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(135, 239, 136, 255));
formatRect.top = WINDOW_HEIGHT * 2 / 3;
gPTextInfoFont->DrawTextW(nullptr, _T("控制说明:"), -1, &formatRect, DT_NOCLIP|DT_LEFT | DT_SINGLELINE, D3DCOLOR_XRGB(23, 25, 111));
formatRect.top += 35;
formatRect.left += 50;
gPTextHelperFont->DrawText(NULL, L"按住鼠标左键并拖动:平移模型", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
gPTextHelperFont->DrawText(NULL, L"按住鼠标右键并拖动:旋转模型", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
gPTextHelperFont->DrawText(NULL, L"滑动鼠标滚轮:拉伸模型", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
gPTextHelperFont->DrawText(NULL, L"W、S、A、D键:平移模型 ", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
gPTextHelperFont->DrawText(NULL, L"上、下、左、右方向键:旋转模型 ", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
gPTextHelperFont->DrawText(NULL, L"ESC键 : 退出程序", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
gPD3DDevice->EndScene();
gPD3DDevice->Present(nullptr, nullptr, nullptr, nullptr);
}
示例2: Render
VOID Render( )
{
RECT rt1, rt2;
D3DXMATRIX matWorld, matScale, matRotateZ, matTrans;
g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );
if ( SUCCEEDED( g_pD3DDevice->BeginScene( ) ) )
{
SetupMatrices( );
SetRect( &rt1, 10, 10, 0, 0 );
if (!g_Method)
{
g_pFont->DrawTextW( NULL, L"AABB 충돌(left click으로 방법 변경)", -1, &rt1, DT_NOCLIP, D3DXCOLOR( 1.f, 1.f, 0.f, 1.f ) );
}
else
{
g_pFont->DrawTextW( NULL, L"OBB 충돌(left click으로 방법 변경)", -1, &rt1, DT_NOCLIP, D3DXCOLOR( 1.f, 1.f, 0.f, 1.f ) );
}
g_pD3DDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
for ( DWORD i = 0; i < sizeof( g_Box ) / sizeof( g_Box[1] ); ++i )
{
D3DXMatrixTranslation( &matTrans, g_Box[i].CenterPos.x, g_Box[i].CenterPos.y, g_Box[i].CenterPos.z );
D3DXMatrixScaling( &matScale, g_Box[i].BoxScaling, g_Box[i].BoxScaling, g_Box[i].BoxScaling );
D3DXMatrixRotationZ( &matRotateZ, g_Box[i].BoxRotateZ );
matWorld = matRotateZ * matScale * matTrans;
g_pD3DDevice->SetTransform( D3DTS_WORLD, &matWorld );
g_pMesh->DrawSubset( 0 );
}
SetRect( &rt2, 10, 30, 0, 0 );
if ( g_CheckFlag )
{
g_pFont->DrawTextW( NULL, L"박았음!!", -1, &rt2, DT_NOCLIP, D3DXCOLOR( 1.f, 1.f, 0.f, 1.f ) );
}
else
{
g_pFont->DrawTextW( NULL, L"아직 멀었음!!", -1, &rt2, DT_NOCLIP, D3DXCOLOR( 1.f, 1.f, 0.f, 1.f ) );
}
g_pD3DDevice->EndScene( );
}
g_pD3DDevice->Present( NULL, NULL, NULL, NULL );
}
示例3: D3DDrawText
void D3DDrawText(wchar_t *str)
{
if (*str == L'\0') return;
RECT rect;
//SetRect(&rct, rect.left, rect.top, rect.right, rect.bottom);
GetClientRect(hwnd, &rect);
uint width = rect.right - rect.left;
wstring wstr = addenter(str, width / 30);
//pDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
pDevice->BeginScene();
g_pTextSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE);
//描边
rect.left += 2;
g_pFont->DrawTextW(g_pTextSprite, wstr.c_str(), -1, &rect, DT_LEFT | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 255, 255));
rect.left -= 2;
rect.top += 2;
g_pFont->DrawTextW(g_pTextSprite, wstr.c_str(), -1, &rect, DT_LEFT | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 255, 255));
rect.left += 4;
g_pFont->DrawTextW(g_pTextSprite, wstr.c_str(), -1, &rect, DT_LEFT | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 255, 255));
rect.left -= 2;
rect.top += 2;
g_pFont->DrawTextW(g_pTextSprite, wstr.c_str(), -1, &rect, DT_LEFT | DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 255, 255));
//实体
rect.top -= 2;
g_pFont->DrawTextW(g_pTextSprite, wstr.c_str(), -1, &rect, DT_LEFT | DT_NOCLIP, D3DCOLOR_ARGB(255, 0, 0, 0));
g_pTextSprite->End();
pDevice->EndScene();
//pDevice->Present(&rect, &rect, 0, 0);
}
示例4: draw_next
void WINAPI draw_next(draw_info_t* data)
{
RECT rect;
memcpy(&rect,&data->rect,sizeof(data->rect));
RECT rct;
SetRect(&rct, rect.left,rect.top, rect.right, rect.bottom);
g_pTextSprite->Begin( D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE );
g_pFont->DrawTextW(g_pTextSprite,data->str, -1, &rct, DT_LEFT | DT_NOCLIP, D3DCOLOR_ARGB(255,255,255,255));
g_pTextSprite->End();
}
示例5: CalculateRect
void C_Renderer::CalculateRect(IResource* font, RectangleI* pt, const wchar_t* str, unsigned int start, unsigned int end, unsigned int style, float scale)
{
if(font==0) return;
#ifdef USE_BITMAPFONT
Sprite* Font = CAST_RES(Sprite*, font);
FontResource* rc = (FontResource*)font;
#else
LPD3DXFONT Font = CAST_RES(LPD3DXFONT, font);
#endif
if(Font==0) return;
#ifdef USE_BITMAPFONT
#else
D3DXMatrixScaling(&mat, scale, scale, 1.0f);
m_sprite->GetTransform(&m2);
m_sprite->SetTransform(&(mat * m2));
pt->left = (LONG)(pt->left/scale);
pt->top = (LONG)(pt->top/scale);
pt->right = (LONG)(pt->right/scale);
pt->bottom = (LONG)(pt->bottom/scale);
#endif
#ifdef USE_BITMAPFONT
float sw = 0.0f;
RectangleI* rct = 0;
RectangleF rect;
rect.left = (float)pt->left;
rect.top = (float)pt->top;
rect.right = (float)pt->right;
rect.bottom = (float)pt->bottom;
unsigned int txtsize = wcslen(str);
float fsize = (float)rc->GetSize();
if(start>=txtsize || end>txtsize) return;
float fwidth = 0.0f;
float fheight = 0.0f;
for(unsigned int i=start; i< start + end; i++)
{
rct = Font->GetSpriteRect((unsigned int)str[i]);
if(rct!=0)
{
float scale2 = fsize / (rct->bottom - rct->top);
fwidth += ((rct->right - rct->left - BFONTSPACEW) * scale2) * scale;
fheight = ((rct->bottom - rct->top) * scale2) * scale;
}
}
if(style&FONT_STYLE_MULTILINE)
{
rect.left -= BFONTSPACE;
rect.right -= BFONTSPACE;
}
else
{
rect.left -= BFONTSPACE;
rect.right = rect.left + fwidth - BFONTSPACE;
rect.bottom = rect.top + fheight;
pt->left = (int)(rect.left/scale);
pt->top = (int)(rect.top/scale);
pt->right = (int)(rect.right/scale);
pt->bottom = (int)(rect.bottom/scale);
}
#else
Font->DrawTextW(m_sprite, str + start, end, (LPRECT)pt, style | DT_CALCRECT, D3DXCOLOR(0,0,0,1));
m_sprite->SetTransform(&m2);
#endif
}
示例6: DrawText
//.........这里部分代码省略.........
float scale2 = fsize / (rct->bottom - rct->top);
fwidth += ((rct->right - rct->left - BFONTSPACEW) * scale2) * scale;
fheight = ((rct->bottom - rct->top) * scale2) * scale;
}
}
if(style&FONT_STYLE_MULTILINE)
{
rect.left -= BFONTSPACE;
rect.right -= BFONTSPACE;
}
else
{
if(style&FONT_STYLE_CENTERALIGN)
{
float hfwidth = fwidth / 2.0f;
float hwidth = (rect.right - rect.left) / 2.0f;
rect.left = (rect.left + hwidth) - hfwidth - BFONTSPACEW;
rect.right = rect.left + fwidth - BFONTSPACEW;
}
else if(style&FONT_STYLE_RIGHTALIGN)
{
rect.left = rect.right - fwidth - BFONTSPACE;
rect.right = rect.left + fwidth - BFONTSPACE;
}
else
{
rect.left -= BFONTSPACE;
rect.right = rect.left + fwidth - BFONTSPACE;
}
if(style&FONT_STYLE_VCENTERALIGN)
{
float hfheight = fheight / 2.0f;
float hheight = (rect.bottom - rect.top) / 2.0f;
rect.top = (rect.top + hheight) - hfheight;
rect.bottom = rect.top + fheight;
}
else if(style&FONT_STYLE_BOTTOMALIGN)
{
rect.top = rect.bottom - fheight;
rect.right = rect.top + fheight;
}
else
{
rect.bottom = rect.top + fheight;
}
}
float ty = 0.0f;
float tx = 0;
for(unsigned int i=0; i<txtsize; i++)
{
rct = Font->GetSpriteRect((unsigned int)text[i]);
if(rct!=0)
{
float scale2 = fsize / (rct->bottom - rct->top);
if(style&FONT_STYLE_MULTILINE)
{
RectangleF rect2 = rect;
rect2.left = rect.left + tx;
rect2.right = (rect2.left + (rct->right - rct->left) * scale2 * scale);
if(rect2.right>rect.right || text[i] == L'\n' || text[i] == L'\r')
{
ty += fsize * scale + BFONTVSPACE;
tx = 0;
rect2.left = rect.left + tx;
rect2.right = (rect2.left + (rct->right - rct->left) * scale2 * scale);
}
rect2.top = rect.top + ty;
rect2.bottom = (rect2.top + fsize * scale);
if(!(text[i] == L'\n' || text[i] == L'\r'))
{
Font->SetIndex((unsigned int)text[i]);
if(Drawonly==-1 || Drawonly==i) Font->Draw(this, rect2, color, 0.0f, 0.0f);
tx += ((rct->right - rct->left - BFONTSPACEW) * scale2) * scale;
}
}
else
{
rect.right = (rect.left + (rct->right - rct->left) * scale2 * scale);
rect.bottom = (rect.top + fsize * scale);
Font->SetIndex((unsigned int)text[i]);
if(Drawonly==-1 || Drawonly==i) Font->Draw(this, rect, color, 0.0f, 0.0f);
rect.left += ((rct->right - rct->left - BFONTSPACEW) * scale2) * scale;
}
}
}
#else
Font->DrawTextW(m_sprite, text, -1, (LPRECT)&rect, style, color);
m_sprite->SetTransform(&m2);
#endif
}