Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / JOGL Development / Re: bitmap for jogl question on: 2007-05-09 12: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.
2  Java Game APIs & Engines / JOGL Development / Re: bitmap for jogl question on: 2007-05-09 11: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?
3  Java Game APIs & Engines / JOGL Development / bitmap for jogl question on: 2007-05-09 08: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
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (39 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!