Draw cached GLFontCacheString
| 637 | |
| 638 | // Draw cached GLFontCacheString |
| 639 | void GLFont::drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Align hAlign, Align vAlign) const { |
| 640 | |
| 641 | float size = (float) fc->pxHeight / (float) fc->vpy; |
| 642 | |
| 643 | glPushMatrix(); |
| 644 | glTranslatef(xpos, ypos, 0.0f); |
| 645 | |
| 646 | switch (vAlign) { |
| 647 | case GLFONT_ALIGN_TOP: |
| 648 | glTranslatef(0.0, -size, 0.0); |
| 649 | break; |
| 650 | case GLFONT_ALIGN_CENTER: |
| 651 | glTranslatef(0.0, -size/2.0, 0.0); |
| 652 | break; |
| 653 | default: |
| 654 | break; |
| 655 | } |
| 656 | |
| 657 | switch (hAlign) { |
| 658 | case GLFONT_ALIGN_RIGHT: |
| 659 | glTranslatef(-fc->msgWidth, 0.0, 0.0); |
| 660 | break; |
| 661 | case GLFONT_ALIGN_CENTER: |
| 662 | glTranslatef(-fc->msgWidth / 2.0, 0.0, 0.0); |
| 663 | break; |
| 664 | default: |
| 665 | break; |
| 666 | } |
| 667 | |
| 668 | glEnable(GL_TEXTURE_2D); |
| 669 | glBindTexture(GL_TEXTURE_2D, texId); |
| 670 | |
| 671 | glEnable(GL_BLEND); |
| 672 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 673 | |
| 674 | glEnableClientState(GL_VERTEX_ARRAY); |
| 675 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
| 676 | glVertexPointer(2, GL_FLOAT, 0, &fc->gl_vertices[0]); |
| 677 | glTexCoordPointer(2, GL_FLOAT, 0, &fc->gl_uv[0]); |
| 678 | |
| 679 | glDrawArrays(GL_QUADS, 0, 4 * fc->drawlen); |
| 680 | |
| 681 | glVertexPointer(2, GL_FLOAT, 0, nullptr); |
| 682 | glTexCoordPointer(2, GL_FLOAT, 0, nullptr); |
| 683 | |
| 684 | glDisableClientState(GL_VERTEX_ARRAY); |
| 685 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
| 686 | |
| 687 | glPopMatrix(); |
| 688 | |
| 689 | glDisable(GL_BLEND); |
| 690 | glDisable(GL_TEXTURE_2D); |
| 691 | } |
| 692 | |
| 693 | // Compile optimized GLFontCacheString |
| 694 | GLFontStringCache *GLFont::cacheString(const std::wstring& str, int pxHeight, int vpx, int vpy) { |
nothing calls this directly
no outgoing calls
no test coverage detected