Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (529)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  bitmap for jogl question  (Read 1112 times)
0 Members and 1 Guest are viewing this topic.
Offline aban740

Junior Newbie





« Posted 2007-05-09 10:48:00 »

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
Offline cylab

JGO Ninja


Medals: 38



« Reply #1 - Posted 2007-05-09 12:28:33 »

I don't  know how rasters array is setted?

Huh

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 };

what exactly is the problem?

Mathias - I Know What [you] Did Last Summer!
Offline aban740

Junior Newbie





« Reply #2 - Posted 2007-05-09 13:03:33 »

Huh

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?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cylab

JGO Ninja


Medals: 38



« Reply #3 - Posted 2007-05-09 13:57:35 »

This snippet defines a field named "rasters" which is an array of bytes:
1  
    private byte rasters[]=...


I personally don't like the c-style syntax rasters[]. I would rather write it as:
1  
    private byte[] rasters=...


which is the same.

The second part
1  
    ...new byte[]{...}


creates a new byte-array ant initializes it on the fly to the given values. e.g.
1  
    private byte[] rasters= new byte[]{(byte)4,(byte)7};


is the same as:
1  
2  
3  
4  
    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.

Mathias - I Know What [you] Did Last Summer!
Offline aban740

Junior Newbie





« Reply #4 - Posted 2007-05-09 14:21:44 »

This snippet defines a field named "rasters" which is an array of bytes:
1  
    private byte rasters[]=...


I personally don't like the c-style syntax rasters[]. I would rather write it as:
1  
    private byte[] rasters=...


which is the same.

The second part
1  
    ...new byte[]{...}


creates a new byte-array ant initializes it on the fly to the given values. e.g.
1  
    private byte[] rasters= new byte[]{(byte)4,(byte)7};


is the same as:
1  
2  
3  
4  
    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.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (31 views)
2014-07-18 06:55:21

Zero Volt (27 views)
2014-07-17 23:47:54

danieldean (23 views)
2014-07-17 23:41:23

MustardPeter (24 views)
2014-07-16 23:30:00

Cero (39 views)
2014-07-16 00:42:17

Riven (41 views)
2014-07-14 18:02:53

OpenGLShaders (28 views)
2014-07-14 16:23:47

Riven (28 views)
2014-07-14 11:51:35

quew8 (25 views)
2014-07-13 13:57:52

SHC (61 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!