bitmap for jogl question

I have a question,
this is a piece of programmes as follows:
private byte rasters[] = new byte[] { (byte) 0xc0, (byte) 0x00,
(byte) 0xc0, (byte) 0x00, (byte) 0xc0, (byte) 0x00, (byte) 0xc0,
(byte) 0x00, (byte) 0xc0, (byte) 0x00, (byte) 0xff, (byte) 0x00,
(byte) 0xff, (byte) 0x00, (byte) 0xc0, (byte) 0x00, (byte) 0xc0,
(byte) 0x00, (byte) 0xc0, (byte) 0x00, (byte) 0xff, (byte) 0xc0,
(byte) 0xff, (byte) 0xc0 };
display(){
gl.glBitmap(10, 12, 0.0f, 0.0f, 12.0f, 0.0f, rasters, 0);
gl.glBitmap(10, 12, 0.0f, 0.0f, 12.0f, 0.0f, rasters, 0);
gl.glBitmap(10, 12, 0.0f, 0.0f, 12.0f, 0.0f, rasters, 0);
gl.glflush();
}
as a result of it . three ‘f’ is printed on the screen.
I don’t know how rasters array is setted?

who know ?
thanks

???

what exactly is the problem?

this is all codes of a test programme as follows:

public class drawf
extends glskeleton
implements GLEventListener
, KeyListener
{
private byte rasters2[]=new byte[]
{(byte)0xff,(byte)0xff,(byte)0xc0,(byte)0xc0,(byte)0xc0,(byte)0xff,
(byte)0xff,(byte)0xc0,(byte)0xc0,(byte)0xc0,(byte)0xff,(byte)0xff};

private byte rasters[] = new byte[] { (byte) 0xc0, (byte) 0x00,
        (byte) 0xc0, (byte) 0x00, (byte) 0xc0, (byte) 0x00, (byte) 0xc0,
        (byte) 0x00, (byte) 0xc0, (byte) 0x00, (byte) 0xff, (byte) 0x00,
        (byte) 0xff, (byte) 0x00, (byte) 0xc0, (byte) 0x00, (byte) 0xc0,
        (byte) 0x00, (byte) 0xc0, (byte) 0x00, (byte) 0xff, (byte) 0xc0,
        (byte) 0xff, (byte) 0xc0 };

//
public drawf() {
}

public static void main(String[] args) {
    GLCapabilities caps = new GLCapabilities();
    GLJPanel canvas = new GLJPanel(caps);
    drawf demo = new drawf();
    canvas.addGLEventListener(demo);
    demo.setCanvas(canvas);
    demo.setDefaultListeners(demo);

// JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame(“drawf”);
frame.setSize(500, 500);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.getContentPane().add(canvas);
    frame.setVisible(true);
    canvas.requestFocusInWindow();
    
}

public void init(GLAutoDrawable drawable) {
    GL gl = drawable.getGL();
    //
    gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

public void display(GLAutoDrawable drawable) {
    GL gl = drawable.getGL();
    GLUT glut = new GLUT();
    //
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    gl.glColor3f(1.0f, 1.0f, 1.0f);
    gl.glRasterPos2f(50.5f,20.5f);
    //绘制4个字符

// gl.glBitmap(10, 12, 0.0f, 0.0f, 12.0f, 0.0f, rasters, 0);
// gl.glBitmap(10, 12, 0.0f, 0.0f, 12.0f, 0.0f, rasters, 0);
// gl.glBitmap(10, 12, 0.0f, 0.0f, 12.0f, 0.0f, rasters, 0);
// gl.glBitmap(10,12,0.0f,0.0f,14.0f,0.0f,rasters2,0);
glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, “Hello world”);
gl.glFlush();
}

public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    GL gl = drawable.getGL();
    //
    gl.glViewport(0, 0, w, h);
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glOrtho(0, w, 0, h, -1.0, 1.0);
    gl.glMatrixMode(GL.GL_MODELVIEW);
}

public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
        boolean deviceChanged) {
}

public void keyTyped(KeyEvent key) {
    // TODO Auto-generated method stub
}

public void keyPressed(KeyEvent key) {
    switch (key.getKeyChar()) {
    case KeyEvent.VK_ESCAPE:
        System.exit(0);
        break;

    default:
        break;
    }
}

public void keyReleased(KeyEvent key) {
    // TODO Auto-generated method stub
}

}

I don’t know how “rasters” is used ? I see some codes look like this array . question is how " rasters" comes?

This snippet defines a field named “rasters” which is an array of bytes:


    private byte rasters[]=...

I personally don’t like the c-style syntax rasters[]. I would rather write it as:


    private byte[] rasters=...

which is the same.

The second part


    ...new byte[]{...}

creates a new byte-array ant initializes it on the fly to the given values. e.g.


    private byte[] rasters= new byte[]{(byte)4,(byte)7};

is the same as:


    private byte[] rasters= new byte[2];
    ...
    rasters[0]=(byte)4;
    rasters[1]=(byte)7;

The numbers used to initialize the array specify a bitmap raster corresponding to the pixels, that form the “f” in your example. The rasters field is later used in the glBitmap() call to blit the “f” to the framebuffer of the graphics card.

i glad to see that you reply.
if you know c-style syntax rasters[] , please tell me ,too.

thanks to cylab.