what calls init()


package game.custom.test;

import net.java.games.jogl.*;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

/**
 * Created by IntelliJ IDEA.
 * User: Hamster Of Death
 * Date: 26.02.2004
 * Time: 19:48:09
 * To change this template use File | Settings | File Templates.
 */
public class Dummy extends Frame implements GLEventListener
{
      private GLCanvas canvas;
      private Robot mouseBot;

      public Dummy() throws AWTException
      {
            mouseBot = new Robot();
            GLCapabilities capabilities = new GLCapabilities();
            canvas =
                GLDrawableFactory.getFactory().createGLCanvas(capabilities);
            canvas.addGLEventListener(this);
            setSize(640,480);
            add(canvas);
            setVisible(true);
      }

      public void init(GLDrawable glDrawable)
      {
            Animator loop = new Animator(glDrawable);
            loop.start();
      }

      public void display(GLDrawable glDrawable)
      {
            //To change body of implemented methods use File | Settings | File Templates.
      }

      public void reshape(GLDrawable glDrawable, int i, int i1, int i2, int i3)
      {
            //To change body of implemented methods use File | Settings | File Templates.
      }

      public void displayChanged(GLDrawable glDrawable, boolean b, boolean b1)
      {
            //To change body of implemented methods use File | Settings | File Templates.
      }

      public static void main(String[] args)
          throws AWTException
      {
            new Dummy();
      }
}

init() gets called…but why ? when ?

init() is part of the GLEventListener interface, and gets called when the OpenGL canvas is first initialised. It may or may not be a good place to load textures and set yourself up a default GL state.

In your example I’m pretty sure that the canvas is first initialised when it becomes visible, so the .init happens sometime soon after the setVisible(true) call for the frame.