Exemple #1
0
 /**
  * Return a texture containing the given single character with the Courier font. TO DO: pass Font
  * as a parameter.
  *
  * @param onechar character to draw into texture
  */
 public static int makeCharTexture(Font f, String onechar, float[] fgColor, float[] bgColor) {
   int texture = 0;
   try {
     // Create a BufferedImage with one character
     BufferedImage image =
         createCharImage(
             onechar, f, // the font
             fgColor, // text
             bgColor); // background
     // make a texture from the image
     Texture tex = TextureStorage.loadTexture("Font-" + f.getFontName() + "-" + onechar, image);
     texture = tex.getTextureID();
   } catch (Exception e) {
     System.out.println("makeChar(): exception " + e);
   }
   return texture;
 }
Exemple #2
0
 /**
  * Return a texture containing a character set with the given Font arranged in a 10x10 grid of
  * printable characters.
  *
  * @param f the font to draw characters
  * @param fgColor foreground (text) color as rgb or rgba values in range 0-1
  * @param bgColor background color as rgb or rgba values in range 0-1 (set alpha to 0 to make
  *     transparent)
  * @see createFontImage()
  * @see print()
  */
 public int makeFontTexture(Font f, float[] fgColor, float[] bgColor) {
   int texture = 0;
   try {
     // Create a BufferedImage containing a 10x10 grid of printable
     // characters
     BufferedImage image =
         createFontImage(
             f, // the font
             fgColor, // text color
             bgColor); // background color
     // make a texture with the buffered image
     this.texture = TextureStorage.loadTexture("font-" + f.getFontName(), image);
     texture = this.texture.getTextureID();
   } catch (Exception e) {
     System.out.println("makeChar(): exception " + e);
   }
   return texture;
 }