public virtual void renderString(string str, Font font, Point2 location) { renderString(str, font, location.toPoint3(), defaultColor, font.size); }
public TextRenderingHelper(Font font, FontGlyphCollection pmGlyph) { character= pmGlyph.regular.character; lcoord= new TexCoord((pmGlyph.regular.location.x)/(font.bitmap.Width), (pmGlyph.regular.location.y)/(font.bitmap.Height)); rcoord= new TexCoord((pmGlyph.regular.location.x+pmGlyph.regular.size.width)/(font.bitmap.Width), (pmGlyph.regular.location.y+pmGlyph.regular.size.height)/(font.bitmap.Height)); glyph= pmGlyph.regular; }
public virtual void renderString(string str, Font font, Point2 location, Color color) { renderString(str, font, location.toPoint3(), color, font.size); }
public virtual void renderString(string str, Font font) { renderString(str, font, Point3.ORIGIN, defaultColor, font.size); }
public virtual void renderString(string str, Font font, Color color) { renderString(str, font, Point3.ORIGIN, color, font.size); }
public virtual void renderString(string str, Font font, Point3 location, float fontSize) { renderString(str, font, location, defaultColor, fontSize); }
// Renders a string with the given string, position, color, font, and font size public virtual void renderString(string str, Font font, Point3 location, Color color, float fontSize) { if(str.IndexOf("\n")!= -1) { // Variables string[] breaks= str.Split("\n".ToCharArray()); for(int i= 0; i< breaks.Length; i++) renderString(breaks[i], font, new Point3(location.x, location.y+((font.getMaxHeight()+4)*i), location.z), color, fontSize); return; } // Variables List<TextRenderingHelper> helpers= new List<TextRenderingHelper>(); float currX= location.x; float[] wh= new float[2]; for(int i= 0; i< str.Length; i++) helpers.add(new TextRenderingHelper(font, font.glyphs[str[i]])); if(currTextureID!= font.texture.ID) bindToTexture(font.texture.ID); GL.Begin(PrimitiveType.Quads); { GL.Color4(color.red, color.green, color.blue, color.alpha); for(int i= 0; i< helpers.size; i++) { wh[0]= helpers.items[i].glyph.size.width*(fontSize/font.originalSize); wh[1]= helpers.items[i].glyph.size.height*(fontSize/font.originalSize); // Top Left GL.TexCoord2(helpers.items[i].lcoord.u, helpers.items[i].lcoord.v); GL.Vertex3(currX, location.y, location.z); // Bottom Left GL.TexCoord2(helpers.items[i].lcoord.u, helpers.items[i].rcoord.v); GL.Vertex3(currX, location.y+wh[1], location.z); // Bottom Right GL.TexCoord2(helpers.items[i].rcoord.u, helpers.items[i].rcoord.v); GL.Vertex3(currX+wh[0], location.y+wh[1], location.z); // Top Right GL.TexCoord2(helpers.items[i].rcoord.u, helpers.items[i].lcoord.v); GL.Vertex3(currX+wh[0], location.y, location.z); currX+= wh[0]; } } GL.End(); }