本文整理汇总了C++中BitmapFont::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapFont::GetData方法的具体用法?C++ BitmapFont::GetData怎么用?C++ BitmapFont::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitmapFont
的用法示例。
在下文中一共展示了BitmapFont::GetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawTextPrivate
void RenderManager::DrawTextPrivate()
{
if(enqueuedTextData.size() == 0)
return;
gRenderAPI->BeginPerfEvent("RenderText");
for(int fnt=0; fnt<FONT_MaxSupported; fnt++)
{
// Calculate number of quads to render
int numQuads = 0;
for(vector<TextRenderData>::const_iterator it=enqueuedTextData.begin(); it != enqueuedTextData.end(); it++)
{
if(it->useFont == fnt)
numQuads += it->text.length();
}
if(numQuads == 0)
continue;
// Create vertex buffer
VertexBuffer* textVB = gRenderAPI->CreateVertexBuffer(VFMT_P3C3U2, numQuads*4, NULL, true);
VertexContainer_P3C3U2* pData = (VertexContainer_P3C3U2*)textVB->Lock();
float fontHeightNDC, fontWidthNDC;
for(vector<TextRenderData>::const_iterator it=enqueuedTextData.begin(); it != enqueuedTextData.end(); it++)
{
const TextRenderData& data = *it;
if(data.useFont == fnt)
{
// Convert font height from pixel units to NDC units
fontHeightNDC = 2*data.size/fullScreenBufferSizeY;
// The current position of the render cursor
float renderCursorX = data.posX;
// Font used
BitmapFont* font = engineFonts[data.useFont];
// Font color
ColorVector color = data.color;
// Text to render
const string& renderText = data.text;
for(unsigned int i=0; i<renderText.length(); i++)
{
BitmapFont::CharDescriptor charData = font->GetData(renderText.at(i), data.bBold);
fontWidthNDC = charData.aspectRatio * fontHeightNDC;
pData->px = renderCursorX;
pData->py = data.posY;
pData->pz = 0.f;
pData->cx = color.r;
pData->cy = color.g;
pData->cz = color.b;
pData->u = charData.u1;
pData->v = charData.v1;
pData++;
pData->px = renderCursorX + fontWidthNDC;
pData->py = data.posY;
pData->pz = 0.f;
pData->cx = color.r;
pData->cy = color.g;
pData->cz = color.b;
pData->u = charData.u2;
pData->v = charData.v1;
pData++;
pData->px = renderCursorX + fontWidthNDC;
pData->py = data.posY - fontHeightNDC;
pData->pz = 0.f;
pData->cx = color.r;
pData->cy = color.g;
pData->cz = color.b;
pData->u = charData.u2;
pData->v = charData.v2;
pData++;
pData->px = renderCursorX;
pData->py = data.posY - fontHeightNDC;
pData->pz = 0.f;
pData->cx = color.r;
pData->cy = color.g;
pData->cz = color.b;
pData->u = charData.u1;
pData->v = charData.v2;
pData++;
renderCursorX += fontWidthNDC;
}
}
}
//.........这里部分代码省略.........