public static void FontPrint(GR gr, float x, float y, String asciiText) { int n = 0; n = asciiText.Length; if (n <= 0) { return; } if (0 == mFontTextureName) { MakeFontTexture(gr); } // DISABLE Z-WRITES AND Z-TESTING gr.glDisable(GR.GL_DEPTH_TEST); gr.glEnable(GR.GL_BLEND); gr.glBlendFunc(GR.GL_SRC_ALPHA, GR.GL_ONE_MINUS_SRC_ALPHA); gr.glEnable(GR.GL_TEXTURE_2D); gr.glBindTexture(GR.GL_TEXTURE_2D, mFontTextureName); gr.glBegin(GR.GL_TRIANGLES); float du = 0.0f; float dv = 0.0f; du = (0.0625f); dv = (0.1250f); int i = 0; int j = 0; int k = 0; int index = 0; float u = 0.0f; float v = 0.0f; for (k = 0; k < n; k++) { index = (int)(asciiText[k]); if (index > 255) { index = 0; } else if (index >= 192) { index -= 96; } else if (index >= 32) { index -= 32; } else if (index < 32) { index = 0; } if (index < 0) { index = 0; } if (index >= 128) { index = 0; } i = (index & 0xf); j = (7 - (index >> 4)); u = du * ((float)i); v = dv * ((float)j); gr.glTexCoord2f(u, v); gr.glVertex3f(x + (float)(FONT_WIDTH * k), y - (float)(FONT_HEIGHT), 0.0f); gr.glTexCoord2f((u + du), v); gr.glVertex3f(x + (float)(FONT_WIDTH * (k + 1)), y - (float)(FONT_HEIGHT), 0.0f); gr.glTexCoord2f(u, (v + dv)); gr.glVertex3f(x + (float)(FONT_WIDTH * k), y, 0.0f); gr.glTexCoord2f(u, (v + dv)); gr.glVertex3f(x + (float)(FONT_WIDTH * k), y, 0.0f); gr.glTexCoord2f((u + du), v); gr.glVertex3f(x + (float)(FONT_WIDTH * (k + 1)), y - (float)(FONT_HEIGHT), 0.0f); gr.glTexCoord2f((u + du), (v + dv)); gr.glVertex3f(x + (float)(FONT_WIDTH * (k + 1)), y, 0.0f); } gr.glEnd( ); gr.glDisable(GR.GL_TEXTURE_2D); gr.glDisable(GR.GL_BLEND); gr.glEnable(GR.GL_DEPTH_TEST); }