BMFont* ContentManager::LoadFont(const UString& path)
  {
    	if (path.empty()) {
	  DebugPrintF(VTEXT("Error Loading [BMFont]"));
			return NULL;
		}

		UString _path = os_path(FONT_FOLDER_PATH + path);
		UString _texPath = os_path(FONT_FOLDER_PATH + TEX_FOLDER_PATH);

		ContentMap::iterator it = m_fonts.find(_path);
		if (it != m_fonts.end()) {
			return (BMFont*)it->second;
		}
		else {

			/*create new font*/
			BMFont* font = new BMFont(_path);
			/*load textures for font*/
			for (auto& page : font->FontFile().pages) {
				Texture* tex = LoadTexture(_texPath + page.file);
				if (tex)
					font->AddPageTexture(tex);
			}
			m_fonts[_path] = (IContent*)font;
			return font;
		}

		return NULL;
  }
예제 #2
0
파일: Pane.cpp 프로젝트: kristofe/RiftRay
void Pane::DrawTextOverlay(
    const std::string text,
    int x,
    int y,
    const ShaderWithVariables& sh,
    const BMFont& font) const
{
    const glm::mat4 modelview(1.0f);
    const glm::mat4 projection = glm::ortho(
        0.0f,
        static_cast<float>(m_paneRenderBuffer.w),
        static_cast<float>(m_paneRenderBuffer.h),
        0.0f,
        -1.0f,
        1.0f);

    font.DrawString(text, x, y, modelview, projection, sh);
}
예제 #3
0
void Pane::DrawTextOverlay(
    const std::string text,
    int x,
    int y,
    const ShaderWithVariables& sh,
    const BMFont& font) const
{
    if (m_visible == false)
        return;

    const glm::mat4 modelview(1.0f);
    const glm::mat4 projection = glm::ortho(
        0.0f,
        // Text size is tuned to font size and max shader title/author/license length
        static_cast<float>(600),//m_paneRenderBuffer.w),
        static_cast<float>(600),//m_paneRenderBuffer.h),
        0.0f,
        -1.0f,
        1.0f);

    font.DrawString(text, x, y, modelview, projection, sh);
}
예제 #4
0
void debugDraw(const BMFont& font, GLfloat x, GLfloat y) {
	font.renderText(x, y, debugStr.str().c_str());
}