本文整理汇总了C++中FontManager::destroyFont方法的典型用法代码示例。如果您正苦于以下问题:C++ FontManager::destroyFont方法的具体用法?C++ FontManager::destroyFont怎么用?C++ FontManager::destroyFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontManager
的用法示例。
在下文中一共展示了FontManager::destroyFont方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _main_
//.........这里部分代码省略.........
while (!entry::processEvents(width, height, debug, reset) )
{
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to view 0.
bgfx::touch(0);
int64_t now = bx::getHPCounter();
static int64_t last = now;
const int64_t frameTime = now - last;
last = now;
const double freq = double(bx::getHPFrequency() );
const double toMs = 1000.0 / freq;
// Use debug font to print information about this example.
bgfx::dbgTextClear();
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/10-font");
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Use the font system to display text and styled text.");
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
// Use transient text to display debug information.
wchar_t fpsText[64];
bx::swnprintf(fpsText, BX_COUNTOF(fpsText), L"Frame: % 7.3f[ms]", double(frameTime) * toMs);
textBufferManager->clearTextBuffer(transientText);
textBufferManager->setPenPosition(transientText, width - 150.0f, 10.0f);
textBufferManager->appendText(transientText, visitor10, L"Transient\n");
textBufferManager->appendText(transientText, visitor10, L"text buffer\n");
textBufferManager->appendText(transientText, visitor10, fpsText);
float at[3] = { 0, 0, 0.0f };
float eye[3] = { 0, 0, -1.0f };
float view[16];
bx::mtxLookAt(view, eye, at);
const float centering = 0.5f;
// Setup a top-left ortho matrix for screen space drawing.
const bgfx::HMD* hmd = bgfx::getHMD();
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
{
float proj[16];
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
static float time = 0.0f;
time += 0.05f;
const float dist = 10.0f;
const float offset0 = -proj[8] + (hmd->eye[0].viewOffset[0] / dist * proj[0]);
const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]);
float ortho[2][16];
const float offsetx = width/2.0f;
bx::mtxOrtho(ortho[0], centering, offsetx + centering, height + centering, centering, -1.0f, 1.0f, offset0);
bx::mtxOrtho(ortho[1], centering, offsetx + centering, height + centering, centering, -1.0f, 1.0f, offset1);
bgfx::setViewTransform(0, view, ortho[0], BGFX_VIEW_STEREO, ortho[1]);
bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
}
else
{
float ortho[16];
bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f);
bgfx::setViewTransform(0, view, ortho);
bgfx::setViewRect(0, 0, 0, width, height);
}
// Submit the debug text.
textBufferManager->submitTextBuffer(transientText, 0);
// Submit the static text.
textBufferManager->submitTextBuffer(staticText, 0);
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
}
fontManager->destroyTtf(fontAwesomeTtf);
fontManager->destroyTtf(visitorTtf);
// Destroy the fonts.
fontManager->destroyFont(fontAwesome72);
fontManager->destroyFont(visitor10);
for (uint32_t ii = 0; ii < numFonts; ++ii)
{
fontManager->destroyFont(fonts[ii]);
}
textBufferManager->destroyTextBuffer(staticText);
textBufferManager->destroyTextBuffer(transientText);
delete textBufferManager;
delete fontManager;
// Shutdown bgfx.
bgfx::shutdown();
return 0;
}
示例2: _main_
int _main_(int /*_argc*/, char** /*_argv*/)
{
uint32_t width = 1280;
uint32_t height = 720;
uint32_t debug = BGFX_DEBUG_TEXT;
uint32_t reset = BGFX_RESET_VSYNC;
bgfx::init();
bgfx::reset(width, height, reset);
// Enable debug text.
bgfx::setDebug(debug);
// Set view 0 clear state.
bgfx::setViewClear(0
, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
, 0x303030ff
, 1.0f
, 0
);
// Imgui.
imguiCreate();
char* bigText = loadText( "text/sherlock_holmes_a_scandal_in_bohemia_arthur_conan_doyle.txt");
// Init the text rendering system.
FontManager* fontManager = new FontManager(512);
TextBufferManager* textBufferManager = new TextBufferManager(fontManager);
TrueTypeHandle font = loadTtf(fontManager, "font/special_elite.ttf");
// Create a distance field font.
FontHandle fontSdf = fontManager->createFontByPixelSize(font, 0, 48, FONT_TYPE_DISTANCE);
// Create a scaled down version of the same font (without adding anything to the atlas).
FontHandle fontScaled = fontManager->createScaledFontToPixelSize(fontSdf, 14);
TextLineMetrics metrics(fontManager->getFontInfo(fontScaled) );
uint32_t lineCount = metrics.getLineCount(bigText);
float visibleLineCount = 20.0f;
const char* textBegin = 0;
const char* textEnd = 0;
metrics.getSubText(bigText, 0, (uint32_t)visibleLineCount, textBegin, textEnd);
TextBufferHandle scrollableBuffer = textBufferManager->createTextBuffer(FONT_TYPE_DISTANCE, BufferType::Transient);
textBufferManager->setTextColor(scrollableBuffer, 0xFFFFFFFF);
textBufferManager->appendText(scrollableBuffer, fontScaled, textBegin, textEnd);
entry::MouseState mouseState;
int32_t scrollArea = 0;
const int32_t guiPanelWidth = 250;
const int32_t guiPanelHeight = 200;
float textScroll = 0.0f;
float textRotation = 0.0f;
float textScale = 1.0f;
float textSize = 14.0f;
while (!entry::processEvents(width, height, debug, reset, &mouseState) )
{
imguiBeginFrame(mouseState.m_mx
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
, mouseState.m_mz
, width
, height
);
imguiBeginScrollArea("Text Area"
, width - guiPanelWidth - 10
, 10
, guiPanelWidth
, guiPanelHeight
, &scrollArea
);
imguiSeparatorLine();
bool recomputeVisibleText = false;
recomputeVisibleText |= imguiSlider("Number of lines", visibleLineCount, 1.0f, 177.0f , 1.0f);
if (imguiSlider("Font size", textSize, 6.0f, 64.0f , 1.0f) )
{
fontManager->destroyFont(fontScaled);
fontScaled = fontManager->createScaledFontToPixelSize(fontSdf, (uint32_t) textSize);
metrics = TextLineMetrics(fontManager->getFontInfo(fontScaled) );
recomputeVisibleText = true;
}
recomputeVisibleText |= imguiSlider("Scroll", textScroll, 0.0f, (lineCount-visibleLineCount) , 1.0f);
imguiSlider("Rotate", textRotation, 0.0f, bx::pi*2.0f , 0.1f);
recomputeVisibleText |= imguiSlider("Scale", textScale, 0.1f, 10.0f , 0.1f);
if (recomputeVisibleText)
{
textBufferManager->clearTextBuffer(scrollableBuffer);
metrics.getSubText(bigText,(uint32_t)textScroll, (uint32_t)(textScroll+visibleLineCount), textBegin, textEnd);
//.........这里部分代码省略.........
示例3: _main_
//.........这里部分代码省略.........
// Setup style colors.
textBufferManager->setBackgroundColor(staticText, 0x551111FF);
textBufferManager->setUnderlineColor(staticText, 0xFF2222FF);
textBufferManager->setOverlineColor(staticText, 0x2222FFFF);
textBufferManager->setStrikeThroughColor(staticText, 0x22FF22FF);
// Background.
textBufferManager->setStyle(staticText, STYLE_BACKGROUND);
textBufferManager->appendText(staticText, fonts[0], L"The quick ");
// Strike-through.
textBufferManager->setStyle(staticText, STYLE_STRIKE_THROUGH);
textBufferManager->appendText(staticText, fonts[0], L"brown fox ");
// Overline.
textBufferManager->setStyle(staticText, STYLE_OVERLINE);
textBufferManager->appendText(staticText, fonts[0], L"jumps over ");
// Underline.
textBufferManager->setStyle(staticText, STYLE_UNDERLINE);
textBufferManager->appendText(staticText, fonts[0], L"the lazy ");
// Background + strike-through.
textBufferManager->setStyle(staticText, STYLE_BACKGROUND | STYLE_STRIKE_THROUGH);
textBufferManager->appendText(staticText, fonts[0], L"dog\n");
// Create a transient buffer for real-time data.
TextBufferHandle transientText = textBufferManager->createTextBuffer(FONT_TYPE_ALPHA, BufferType::Transient);
while (!processEvents(width, height, debug, reset) )
{
// Set view 0 default viewport.
bgfx::setViewRect(0, 0, 0, width, height);
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to view 0.
bgfx::submit(0);
int64_t now = bx::getHPCounter();
static int64_t last = now;
const int64_t frameTime = now - last;
last = now;
const double freq = double(bx::getHPFrequency() );
const double toMs = 1000.0 / freq;
// Use transient text to display debug information.
wchar_t fpsText[64];
bx::swnprintf(fpsText, countof(fpsText), L"Frame: % 7.3f[ms]", double(frameTime) * toMs);
textBufferManager->clearTextBuffer(transientText);
textBufferManager->setPenPosition(transientText, 20.0, 4.0f);
textBufferManager->appendText(transientText, consola_16, L"bgfx/examples/10-font\n");
textBufferManager->appendText(transientText, consola_16, L"Description: Use the font system to display text and styled text.\n");
textBufferManager->appendText(transientText, consola_16, fpsText);
float at[3] = { 0, 0, 0.0f };
float eye[3] = {0, 0, -1.0f };
float view[16];
float proj[16];
mtxLookAt(view, eye, at);
// Setup a top-left ortho matrix for screen space drawing.
float centering = 0.5f;
mtxOrtho(proj, centering, width + centering, height + centering, centering, -1.0f, 1.0f);
// Set view and projection matrix for view 0.
bgfx::setViewTransform(0, view, proj);
// Submit the debug text.
textBufferManager->submitTextBuffer(transientText, 0);
// Submit the static text.
textBufferManager->submitTextBuffer(staticText, 0);
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
}
fontManager->destroyTtf(console_tt);
// Destroy the fonts.
fontManager->destroyFont(consola_16);
for (uint32_t ii = 0; ii < fontCount; ++ii)
{
fontManager->destroyFont(fonts[ii]);
}
textBufferManager->destroyTextBuffer(staticText);
textBufferManager->destroyTextBuffer(transientText);
delete textBufferManager;
delete fontManager;
// Shutdown bgfx.
bgfx::shutdown();
return 0;
}