diff options
Diffstat (limited to '3rdparty/bgfx/examples/10-font')
-rw-r--r-- | 3rdparty/bgfx/examples/10-font/font.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/3rdparty/bgfx/examples/10-font/font.cpp b/3rdparty/bgfx/examples/10-font/font.cpp index 26dbfc76e6e..7d0921ddc41 100644 --- a/3rdparty/bgfx/examples/10-font/font.cpp +++ b/3rdparty/bgfx/examples/10-font/font.cpp @@ -1,6 +1,6 @@ /* * Copyright 2013 Jeremie Roy. All rights reserved. - * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE */ #include "common.h" @@ -54,8 +54,8 @@ static const char* s_fontFilePath[] = class ExampleFont : public entry::AppI { public: - ExampleFont(const char* _name, const char* _description) - : entry::AppI(_name, _description) + ExampleFont(const char* _name, const char* _description, const char* _url) + : entry::AppI(_name, _description, _url) { } @@ -71,6 +71,9 @@ public: bgfx::Init init; init.type = args.m_type; init.vendorId = args.m_pciId; + init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); + init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; @@ -87,6 +90,10 @@ public: , 0 ); + // Initialize Imgui + // This initializes the same allocator used by stb_truetype, so must do that before creating the font manager + imguiCreate(); + // Init the text rendering system. m_fontManager = new FontManager(512); m_textBufferManager = new TextBufferManager(m_fontManager); @@ -186,8 +193,6 @@ public: // Create a transient buffer for real-time data. m_transientText = m_textBufferManager->createTextBuffer(FONT_TYPE_ALPHA, BufferType::Transient); - - imguiCreate(); } virtual int shutdown() override @@ -264,7 +269,10 @@ public: float view[16]; bx::mtxLookAt(view, eye, at); - const float centering = 0.5f; + float centering = 0.0f; + if (bgfx::getRendererType() == bgfx::RendererType::Direct3D9) { + centering = -0.5f; + } // Setup a top-left ortho matrix for screen space drawing. const bgfx::Caps* caps = bgfx::getCaps(); @@ -329,4 +337,9 @@ public: } // namespace -ENTRY_IMPLEMENT_MAIN(ExampleFont, "10-font", "Use the font system to display text and styled text."); +ENTRY_IMPLEMENT_MAIN( + ExampleFont + , "10-font" + , "Use the font system to display text and styled text." + , "https://bkaradzic.github.io/bgfx/examples.html#font" + ); |