| 636 | } |
| 637 | |
| 638 | void SimpleOpenGL3App::drawText(const char* txt, int posXi, int posYi, float size, float colorRGBA[4]) |
| 639 | { |
| 640 | float posX = (float)posXi; |
| 641 | float posY = (float)posYi; |
| 642 | |
| 643 | // |
| 644 | //printf("str = %s\n",unicodeText); |
| 645 | |
| 646 | float dx = 0; |
| 647 | |
| 648 | //int measureOnly=0; |
| 649 | |
| 650 | glEnable(GL_BLEND); |
| 651 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 652 | |
| 653 | if (1) //m_useTrueTypeFont) |
| 654 | { |
| 655 | bool measureOnly = false; |
| 656 | |
| 657 | float fontSize = 64 * size; //512;//128; |
| 658 | sth_draw_text(m_data->m_fontStash, |
| 659 | m_data->m_droidRegular, fontSize, posX, posY, |
| 660 | txt, &dx, this->m_instancingRenderer->getScreenWidth(), |
| 661 | this->m_instancingRenderer->getScreenHeight(), |
| 662 | measureOnly, |
| 663 | m_window->getRetinaScale(), colorRGBA); |
| 664 | |
| 665 | sth_end_draw(m_data->m_fontStash); |
| 666 | sth_flush_draw(m_data->m_fontStash); |
| 667 | } |
| 668 | else |
| 669 | { |
| 670 | //float width = 0.f; |
| 671 | int pos = 0; |
| 672 | //float color[]={0.2f,0.2,0.2f,1.f}; |
| 673 | glActiveTexture(GL_TEXTURE0); |
| 674 | glBindTexture(GL_TEXTURE_2D, m_data->m_largeFontTextureId); |
| 675 | |
| 676 | //float width = r.x; |
| 677 | //float extraSpacing = 0.; |
| 678 | |
| 679 | float startX = posX; |
| 680 | float startY = posY; |
| 681 | |
| 682 | while (txt[pos]) |
| 683 | { |
| 684 | int c = txt[pos]; |
| 685 | //r.h = g_DefaultNormalFont->m_CharHeight; |
| 686 | //r.w = g_DefaultNormalFont->m_CharWidth[c]+extraSpacing; |
| 687 | float endX = startX + g_DefaultLargeFont->m_CharWidth[c]; |
| 688 | float endY = startY + g_DefaultLargeFont->m_CharHeight; |
| 689 | |
| 690 | float currentColor[] = {0.2f, 0.2, 0.2f, 1.f}; |
| 691 | |
| 692 | m_primRenderer->drawTexturedRect(startX, startY, endX, endY, currentColor, g_DefaultLargeFont->m_CharU0[c], g_DefaultLargeFont->m_CharV0[c], g_DefaultLargeFont->m_CharU1[c], g_DefaultLargeFont->m_CharV1[c]); |
| 693 | |
| 694 | //DrawTexturedRect(0,r,g_DefaultNormalFont->m_CharU0[c],g_DefaultNormalFont->m_CharV0[c],g_DefaultNormalFont->m_CharU1[c],g_DefaultNormalFont->m_CharV1[c]); |
| 695 | // DrawFilledRect(r); |
no test coverage detected