Really newbie Question

I’m starting to use Java and JoGL and I have a problem with my first program above.

The files are:
Ep1.class


import java.awt.*;
import java.awt.event.*;

import net.java.games.jogl.*;

public class Ep1 {

      public static void main(String[] args) {
            Frame frame = initFrame ();

        GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas (new GLCapabilities ());

        frame.add (canvas);

        canvas.addGLEventListener (new Mandelbrot ());            

            frame.addWindowListener (new WindowAdapter () {
                  public void windowClosing (WindowEvent e) {
                        System.exit (0);
                  }
            });
        
        frame.setVisible (true);
      }

      private static Frame initFrame () {
            Frame frame = new Frame ("Test");
            frame.setSize (640, 400);
            frame.setBackground (Color.BLACK);
            frame.setLayout (new FlowLayout ());
            return frame;
      }
}

And Mandelbrot.class:


import net.java.games.jogl.*;

public class Mandelbrot implements GLEventListener {
      
      public void init (GLDrawable drawable) {
    }

      public void display (GLDrawable drawable) {
        GL gl = drawable.getGL ();
        gl.glColor3f (1.0f, 0.0f, 0.0f); 
        
        gl.glBegin (GL.GL_POINTS);
                gl.glVertex2i (100, 50);
                gl.glVertex2i (100, 130);
                gl.glVertex2i (150, 150);
            gl.glEnd ();      
      }
      
      public void reshape (GLDrawable drawable, int x, int y, int width, int height) {

    }

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


Why it isn’t work? It’s only displaying a blank window. Please help me!

Hi,

You have to make some init in the reshape method at least for your program to work, take a look at the Gears Demo (and use gluOrtho2D if you want to stick to 2D).