| 277 | } |
| 278 | |
| 279 | void font_impl::loadFont(const char* const pFile) |
| 280 | { |
| 281 | CheckGL("Begin font_impl::loadFont"); |
| 282 | |
| 283 | /* Check if font is already loaded. If yes, check if current font load |
| 284 | * request is same as earlier. If so, return from the function, otherwise, |
| 285 | * cleanup currently used resources and mark accordingly for subsequent |
| 286 | * font loading.*/ |
| 287 | if (mIsFontLoaded) { |
| 288 | if (pFile==mTTFfile) |
| 289 | return; |
| 290 | else { |
| 291 | destroyGLResources(); |
| 292 | mIsFontLoaded = false; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | mTTFfile = pFile; |
| 297 | /* Load different font sizes into font atlas */ |
| 298 | for (size_t s = size_t(MIN_FONT_SIZE); s <= size_t(MAX_FONT_SIZE); ++s) { |
| 299 | loadAtlasWithGlyphs(s); |
| 300 | } |
| 301 | |
| 302 | mAtlas->upload(); |
| 303 | |
| 304 | /* push each glyphs vertex and texture data into VBO */ |
| 305 | std::vector<float> vdata; |
| 306 | |
| 307 | uint index = 0; |
| 308 | |
| 309 | for (size_t f=0; f<mGlyphLists.size(); ++f) |
| 310 | { |
| 311 | auto& list = mGlyphLists[f]; |
| 312 | |
| 313 | for (size_t l=0; l<list.size(); ++l) |
| 314 | { |
| 315 | Glyph* g = list[l]; |
| 316 | |
| 317 | std::vector<float> data(16, 0.0f); |
| 318 | data[0] = 0.0f; data[1] = float(-g->mAdvanceY+g->mHeight); |
| 319 | data[2] = g->mS0; data[3] = g->mT1; |
| 320 | |
| 321 | data[4] = 0.0f; data[5] = float(-g->mAdvanceY); |
| 322 | data[6] = g->mS0; data[7] = g->mT0; |
| 323 | |
| 324 | data[8] = float(g->mWidth); data[9] = float(-g->mAdvanceY+g->mHeight); |
| 325 | data[10] = g->mS1; data[11] = g->mT1; |
| 326 | |
| 327 | data[12] = float(g->mWidth); data[13] = float(-g->mAdvanceY); |
| 328 | data[14] = g->mS1; data[15] = g->mT0; |
| 329 | |
| 330 | vdata.insert(vdata.end(), data.begin(), data.end()); |
| 331 | |
| 332 | g->mOffset = index; |
| 333 | index += 4; |
| 334 | } |
| 335 | } |
| 336 |
no test coverage detected