本文整理汇总了C++中LPD3DXFONT::DrawTextA方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXFONT::DrawTextA方法的具体用法?C++ LPD3DXFONT::DrawTextA怎么用?C++ LPD3DXFONT::DrawTextA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXFONT
的用法示例。
在下文中一共展示了LPD3DXFONT::DrawTextA方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Direct3D::Text( LPD3DXFONT Font, int X, int Y, D3DCOLOR Color, char *String )
{
// DT_WORDBREAK might be needed.
// Rectangle where the text will be located
RECT TextRect={X,Y,0,0};
// Calculate the rectangle the text will occupy
Font->DrawTextA( Sprite, String, -1, &TextRect, DT_CALCRECT, 0 );
// Output the text, left aligned
Font->DrawTextA( Sprite, String, -1, &TextRect, DT_LEFT, Color );
}
示例2:
/// <summary>Draws some text to the screen at the specified coordinates
/// with the given color, drawing from the display parameters initialized
/// in this display manager's constructor.</summary>
/// <param name="pDevice">LPDIRECT3DDEVICE9 to render to.</param>
/// <param name="x">Screen X coordinate to draw to.</param>
/// <param name="y">Screen Y coordinate to draw to.</param>
/// <param name="alpha">Alpha level for the rectangle (transparency).</param>
/// <param name="r">Red color component for the colour of the rectangle.</param>
/// <param name="g">Green color component for the colour of the rectangle.</param>
/// <param name="b">Blue color component for the colour of the rectangle.</param>
/// <param name="message">String to draw.</param>
/// <param name="fontType">D3DDisplayManager::FontType value to describe the
/// type of font which should be used.</param>
bool D3DDisplayManager::DrawCooldownTextToScreen(LPDIRECT3DDEVICE9 pDevice,
unsigned int x, unsigned int y, int alpha, int r, int g, int b,
LPCSTR message, FontType fontType) {
_CreateFont(pDevice);
// Choose our font based on input
LPD3DXFONT font;
switch (fontType) {
case FontType::TITLE:
font = pTitleFont;
break;
default:
font = pFont;
}
D3DCOLOR fontColor = D3DCOLOR_ARGB(alpha, r, g, b);
RECT rct;
rct.left = x;
rct.right = x + ((mDisplayParams.backdropWidth / 5) * 4);
rct.top = y;
rct.bottom = rct.top + mDisplayParams.backdropHeight;
// TODO: add better support for different resolutions:
// Use a lookup table to adjust font size dynamically?
// Draw the text
pFontSprite->Begin(D3DXSPRITE_SORT_TEXTURE);
font->DrawTextA(pFontSprite, message, -1, &rct, DT_RIGHT, fontColor);
pFontSprite->End();
return true;
}
示例3: OnFrameRender
void CConsoleBuffer::OnFrameRender(IDirect3DDevice9 *pd3dDevice, LPD3DXFONT font, RECT rct){
int height = rct.bottom - rct.top; // The height of one line in the buffer
float left = (float) rct.left - 4,
right = (float) rct.right + 4,
top = (float) rct.top - 4;
SVertex bverts[] =
{
{ left, top + (height * (int)m_iMaxLines) + 8, 0.0f, 1.0f, 0x11ffffff },
{ left, top, 0.0f, 1.0f, 0x11ffffff },
{ right, top, 0.0f, 1.0f, 0x11ffffff },
{ right, top + (height * (int)m_iMaxLines) + 8, 0.0f, 1.0f, 0x11ffffff },
{ left, top + (height * (int)m_iMaxLines) + 8, 0.0f, 1.0f, 0x11ffffff }
};
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, bverts, sizeof(SVertex));
SVertex verts[] =
{
{ left, top + (height * (int)m_iMaxLines) + 8, 0.0f, 1.0f, 0xccffffff },
{ left, top, 0.0f, 1.0f, 0xccffffff },
{ right, top, 0.0f, 1.0f, 0xccffffff },
{ right, top, 0.0f, 1.0f, 0xcc888888 },
{ right, top + (height * (int)m_iMaxLines) + 8, 0.0f, 1.0f, 0xcc888888 },
{ left, top + (height * (int)m_iMaxLines) + 8, 0.0f, 1.0f, 0xcc888888 }
};
pd3dDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, 5, verts, sizeof(SVertex));
if (m_vLines.empty())
return;
for (UINT i = m_start; i <= m_end; i++){
font->DrawTextA(NULL, m_vLines[i]->GetText(), -1, &rct, DT_LEFT, D3DCOLOR_ARGB(255,255,255,255) );
rct.top = rct.top + height;
rct.bottom = rct.top + height;
}
}
示例4: Draw
void Draw() {
device->CreateStateBlock(D3DSBT_ALL, &state);
state->Capture();
device->SetVertexShader(nullptr);
// draw
try {
if (memory.UpdateAll()) {
device->GetCreationParameters(&cparams);
GetClientRect(cparams.hFocusWindow, &gameWindow);
if (gameWindow.bottom / 1080.0 != heightModifier || gameWindow.right / 1920.0 != widthModifier) {
heightModifier = gameWindow.bottom / 1080.0;
widthModifier = gameWindow.right / 1920.0;
D3DXCreateFont(device, (int)(40 * heightModifier * (heightModifier + .75 * (1 - heightModifier))), 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, 5, DEFAULT_PITCH | FF_DONTCARE, L"Verdana", &pFont);
int left = (int)(855 * widthModifier);
int top = (int)(304 * heightModifier);
int right = (int)(left + 285 * widthModifier);
int bottom = (int)(top + 50 * heightModifier);
rectangle = { left, top, right, bottom };
textrect = { left, top, right, bottom };
}
if (memory.IsOnEndScreen.Current()) {
DrawIGTRectangle();
DrawIGT();
}
}
}
catch (...) {
pFont->DrawTextA(NULL, "Exception", -1, &textrect, DT_CENTER, textColor);
}
//release
state->Apply();
state->Release();
}
示例5: drawPeschkes
void drawPeschkes(const char* peschkes)
{
static RECT textbox;
SetRect(&textbox, 224, 700, 1014, 758);
dxfontpeschkes->DrawTextA(NULL, peschkes, strlen(peschkes), &textbox, DT_RIGHT | DT_BOTTOM,
D3DCOLOR_ARGB(255, 255, 255, 255));
}
示例6: drawChat
void drawChat(string msg)
{
static RECT textbox{ 10, 586, 341, 1024 };
StartSpriteRender();
DrawSprite(chatWindow, 0, 576);
EndSpriteRender();
dxfont->DrawTextA(NULL, msg.c_str(), msg.size(), &textbox, DT_LEFT | DT_TOP | DT_WORDBREAK, D3DCOLOR_ARGB(255, 255, 255, 0));
}
示例7: DrawString
void DrawString(int x, int y, int FontSize, DWORD color, LPD3DXFONT g_pFont, LPCSTR Message)
{
D3DXCreateFont(d3ddev, FontSize, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &pFont);
RECT FontPos = { x, y, x + 120, y + 16 };
pFont->DrawTextA(NULL, Message, -1, (LPRECT)&FontPos, 0, color);
pFont->Release();
}
示例8: DrawHUDText
void CHud::DrawHUDText(LPD3DXFONT font, LPCSTR text, int x, int y, int height, int width, DWORD format, SColor c, float alphaPercent){
if (!font)
return;
RECT rct;
rct.top = y;// + height / 4;
rct.bottom = y + height; //3 * height / 4;
rct.left = x;
rct.right = x + width;
font->DrawTextA(NULL, text, -1, &rct, format, D3DCOLOR_ARGB((int)(alpha * alphaPercent), c.r, c.g, c.b) );
}
示例9: DrawIGT
void DrawIGT() {
UINT32 igt = memory.GameTime.Current();
UINT32 millis = igt % 1000;
UINT32 seconds = (igt / 1000) % 60;
UINT32 minutes = ((igt / (1000 * 60)) % 60);
UINT32 hours = ((igt / (1000 * 60 * 60)) % 24);
char timer_text[128];
sprintf_s(timer_text, 128, "%01u:%02u:%02u.%03u", hours, minutes, seconds, millis);
pFont->DrawTextA(NULL, timer_text, -1, &textrect, DT_CENTER | DT_VCENTER, textColor);
}
示例10: Game_Run
void Game_Run(HWND window)
{
UINT numPasses = 0;
static float y = 0.0;
if (!d3ddev) return;
myInput->DirectInput_UpdateState();
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET , D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);
// slow rendering to approximately 60 fps
if (timeGetTime() > screentimer + 14)
{
screentimer = GetTickCount();
//start rendering
if (d3ddev->BeginScene())
{
//rotate the view
View_Change();
if (myInput->Key_Down(DIK_J))
{
d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
}
else if (myInput->Key_Down(DIK_K))
{
d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
}
//concrete rendering............................................................
for (int i=0;i<nums;i++)
{
d3ddev->SetMaterial(&mats[i]);
d3ddev->SetTexture(0,textures[i]);
mesh->DrawSubset(i);
}
RECT rect={0,0,0,0};
font->DrawTextA(nullptr,s.c_str(),s.length(),&rect,DT_SINGLELINE | DT_NOCLIP | DT_LEFT,D3DCOLOR_XRGB(255,0,0));
//concrete rendering............................................................
//stop rendering
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}
}
if (myInput->Key_Down(DIK_ESCAPE)) gameOver = true;
}
示例11: renderFrame
void renderFrame(void) {
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 162, 232), 1.0f, 0); // use 0, 162, 232 for nice blue color
d3ddev->BeginScene(); // begins the 3D scene
// SET UP THE PIPELINE
D3DXMATRIX matTranslate;
Vector2 mousePos = worldCoord(mouseX, mouseY);
D3DXMatrixTranslation(&matTranslate, mousePos.x, mousePos.y, 0);
D3DXMATRIX matView; // the view transform matrix
D3DXMatrixLookAtRH(&matView,
&D3DXVECTOR3(0.0f, 0.0f, 5.0f), // the camera position
&D3DXVECTOR3(0.0f, 0.0f, 0.0f), // the look-at position
&D3DXVECTOR3(0.0f, 1.0f, 0.0f)); // the up direction
d3ddev->SetTransform(D3DTS_VIEW, &(matView)); // set the view transform to matView
D3DXMATRIX matProjection; // the projection transform matrix
D3DXMatrixOrthoRH(&matProjection,
viewWidth, // the horizontal view volume
viewWidth * currentRatio, // the vertical view volume
0.25f, // the near view-plane
15.0f); // the far view-plane
d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection); // set the projection
d3ddev->SetTexture(0, tx);
// select the vertex buffer to display
d3ddev->SetStreamSource(0, vb, 0, sizeof(CUSTOMVERTEX));
// copy the vertex buffer to the back buffer
d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
RECT rect;
SetRect(&rect, 0, 0, wndWidth, wndHeight);
font->DrawTextA(NULL, "Everward", 8, &rect, DT_CENTER | DT_VCENTER, 0xffffff00);
d3ddev->EndScene(); // ends the 3D scene
d3ddev->Present(NULL, NULL, NULL, NULL); // displays the created frame on the screen
}
示例12: ImgReadMap
//这里才是镜像文件的实际读取
BOOL ImgReadMap(int no)
{
char buff[256];
RECT rc={40,200,600,400};
g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,128,0), 1.0f, 0L );
g_pD3DDevice->BeginScene();
GetClientRect(hwndMain,&rc); rc.top+=(rc.bottom-rc.top)/3;
wsprintf(buff,"僼傽僀儖傪撉傒崬傫偱偄傑偡丅");
pDxFont->DrawTextA(NULL, buff,lstrlen(buff),&rc, DT_CENTER, D3DCOLOR_XRGB(0,255,255));
g_pD3DDevice->EndScene();
g_pD3DDevice->Present( NULL, NULL, NULL, NULL );
for (int i = 0; i < NumTexList; ++i)
{
if (TexList[i].pTex)
{
TexList[i].pTex->Release();
TexList[i].pTex = NULL;
}
}
NumTexList = 0;
NumMMB = 0;
noj = 0;
oj = NULL;
if( !ImgLoad(no) ) return FALSE;
g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,128,0), 1.0f, 0L );
g_pD3DDevice->BeginScene();
rc.top+=16;
wsprintf(buff,"妋擣偟偰偄傑偡丅");
pDxFont->DrawTextA(NULL, buff,lstrlen(buff),&rc, DT_CENTER, D3DCOLOR_XRGB(0,255,255));
g_pD3DDevice->EndScene();
g_pD3DDevice->Present( NULL, NULL, NULL, NULL );
char *p;
DATHEAD hd;
for( p=f.FistData(&hd); p; p=f.NextData(&hd) )
{
int type = (int)hd.type;
switch (type)
{
case 0x1c: //MZB
{
decode_mzb((BYTE*)(p+16));
oj = (OBJINFO *)(p+16+32);
noj = (*(int*)(p+16+4) )&0xffffff;
}
break;
case 0x2e: //MMB
{
decode_mmb((BYTE*)(p+16));
MMBlist[NumMMB++] = p+16;
if( NumMMB >= sizeof(MMBlist)/sizeof(MMBlist[0]) )
{
logprintf("NumTextList偑椪奅揰偵払偟傑偟偨");
}
}
break;
case 0x20: //IMG
{
if( IsImg(p+16) )
{
AddList(p+16);
}
}
break;
}
}
wsprintf(buff,"%d",no);
WritePrivateProfileString("GENERIC","LASTMAP" ,buff,".\\TDWGame.ini");
g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,128,0), 1.0f, 0L );
g_pD3DDevice->BeginScene();
rc.top+=16;
wsprintf(buff,"撉傒崬傒傪廔椆偟傑偟偨丅昤夋偟傑偡丅\n偙偙偱傾僾儕働乕僔儑儞僄儔乕弌偨応崌偼師夞昤夋偝傟傑偣傫丅");
pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_CENTER, D3DCOLOR_XRGB(0,255,255));
g_pD3DDevice->EndScene();
g_pD3DDevice->Present( NULL, NULL, NULL, NULL );
return TRUE;
}
示例13: DrawText
VOID CDXCtrlTreeview::DrawText()
{
TEXTMETRIC tm;
LPD3DXFONT pFont;
RECT rect, irect;
PLISTITEM pItem;
D3DCOLOR Color;
DWORD dwIndex;
DWORD dwIndexTextSize;
SIZE size;
char szBuff[8];
if(m_pManager)
{
GetRect(&rect);
pFont = m_pManager->GetFixedWidthFont();
pFont->GetTextMetrics(&tm);
GetTextExtentPoint32(pFont->GetDC(), "999", 3, &size);
if(m_bShowIndex)
dwIndexTextSize = size.cx;
else
dwIndexTextSize = 0;
pItem = m_pList;
for(dwIndex = 0; dwIndex < m_dwTopIndex; dwIndex++)
pItem = pItem->link;
rect.left += (5 * m_dwFrameWidth / 8) + tm.tmHeight;
rect.top += (5 * m_dwFrameWidth / 8);
rect.bottom -= (5 * m_dwFrameWidth / 8);
rect.right -= ((5 * m_dwFrameWidth / 8) + 16 + dwIndexTextSize);
for(; rect.top <= rect.bottom - tm.tmHeight && pItem; dwIndex++)
{
if(pItem->bGroup || pItem->bVisible)
{
if(dwIndex == m_dwSelectedIndex)
{
Color = m_SelectedColor;
}
else
{
if(pItem->bGroup)
Color = m_GroupColor;
else
Color = m_ItemColor;
}
pFont->DrawTextA(m_pManager->GetFontSprite(), pItem->szText, -1, &rect, DT_TOP | DT_LEFT, Color);
if(m_bShowIndex && pItem->bGroup == FALSE)
{
irect = rect;
irect.left = irect.right;
irect.right = irect.left + dwIndexTextSize;
pFont->DrawTextA(m_pManager->GetFontSprite(), itoa(dwIndex, szBuff, 10), -1, &irect, DT_TOP | DT_RIGHT, Color);
}
rect.top += tm.tmHeight;
}
pItem = pItem->link;
}
}
}
示例14: printName
void Dialog::printName()
{
g_dlgContentFont->DrawTextA(0, m_speakArray[m_curSpeakIdx].name, -1, &m_nameRect, DT_NOCLIP | DT_WORDBREAK, D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
}
示例15: printDialog
void Dialog::printDialog()
{
g_dlgNameFont->DrawTextA(0, m_speakArray[m_curSpeakIdx].content, -1, &m_contentRect, DT_NOCLIP | DT_WORDBREAK, D3DXCOLOR( 0.0f, 1.0f, 1.0f, 1.0f ) );
}