I am trying to mimic the glBitmap() example in the Red Book, but having no luck! Here is the important bits of code:
HashMap<String, byte[]> font = new HashMap<String, byte[]>(36);
private void buildTable()
{
font.put("A", new byte[]{(byte)0x70, (byte)0x88, (byte)0x88, (byte)0x88, (byte)0xF8, (byte)0x88, (byte)0x88, (byte)0x00});
font.put("B", new byte[]{(byte)0xF0, (byte)0x88, (byte)0x88, (byte)0xF0, (byte)0x88, (byte)0x88, (byte)0xF0, (byte)0x00});
font.put("C", new byte[]{(byte)0x70, (byte)0x88, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x88, (byte)0x70, (byte)0x00});
font.put("D", new byte[]{(byte)0xF0, (byte)0x90, (byte)0x88, (byte)0x88, (byte)0x88, (byte)0x90, (byte)0xF0, (byte)0x00});
font.put("E", new byte[]{(byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0xF8, (byte)0x00});
font.put("F", new byte[]{(byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x00});
...
font.put("2", new byte[]{(byte)0x70, (byte)0x88, (byte)0x08, (byte)0x10, (byte)0x20, (byte)0x40, (byte)0xF8, (byte)0x00});
font.put("3", new byte[]{(byte)0xF8, (byte)0x10, (byte)0x20, (byte)0x10, (byte)0x08, (byte)0x88, (byte)0x70, (byte)0x00});
font.put("4", new byte[]{(byte)0x10, (byte)0x30, (byte)0x50, (byte)0x90, (byte)0xF8, (byte)0x10, (byte)0x10, (byte)0x00});
font.put("5", new byte[]{(byte)0xF8, (byte)0x80, (byte)0xF0, (byte)0x08, (byte)0x08, (byte)0x88, (byte)0x70, (byte)0x00});
font.put("6", new byte[]{(byte)0x30, (byte)0x40, (byte)0x80, (byte)0xF0, (byte)0x88, (byte)0x88, (byte)0x70, (byte)0x00});
font.put("7", new byte[]{(byte)0xF8, (byte)0x08, (byte)0x10, (byte)0x20, (byte)0x40, (byte)0x40, (byte)0x40, (byte)0x00});
font.put("8", new byte[]{(byte)0x70, (byte)0x88, (byte)0x88, (byte)0x70, (byte)0x88, (byte)0x88, (byte)0x70, (byte)0x00});
font.put("9", new byte[]{(byte)0x70, (byte)0x88, (byte)0x88, (byte)0x78, (byte)0x08, (byte)0x10, (byte)0x60, (byte)0x00});
}
public ByteBuffer text(String text)
{
ByteBuffer retBuffer = ByteBuffer.allocateDirect(text.length()*8).order(ByteOrder.nativeOrder());
byte[] letter;
for(int i = 0; i < text.length(); i++)
{
letter = font.get(text.substring(i, i+1).toUpperCase());
if(letter == null) letter = font.get("*");
retBuffer.put(letter);
}
retBuffer.flip();
retBuffer.rewind();
return retBuffer;
}
private void render()
{
// clear background
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glLoadIdentity();
GL11.glTranslatef(0.0f, 0.0f, -1f);
stringBuffer = text("A");
GL11.glRasterPos2f(0f, 0f);
GL11.glBitmap(5, 8, 0, 0, 8, 0, stringBuffer);
}
This is what I get:

If I change the
stringBuffer = text("A");
to
stringBuffer = text("AAAAAAAAAA");
I get this:

What am I doing wrong?