Hello
For some reason the init method is never getting called, and as a result nothing is displayed on the screen in my app. The following is the code of the GraphicsComponent that I’m trying to get to work with JOGL:
public class GLTest extends GraphicsComponent implements GLEventListener {
private Plot2DPanel parent = null;
private GLJPanel glJPanel = null;
private Animator anim = null;
/** Creates a GLTest
*
* @param parent The Plot2DPanel this is stored in
*/
public GLTest(Plot2DPanel parent) {
this.parent = parent;
GLCapabilities caps = new GLCapabilities();
caps.setHardwareAccelerated(true);
caps.setDoubleBuffered(true);
glJPanel = GLDrawableFactory.getFactory().createGLJPanel(caps);
glJPanel.addGLEventListener(this);
glJPanel.setSize(parent.getWidth(),parent.getHeight());
glJPanel.setVisible(true);
glJPanel.setOpaque(false);
this.add(glJPanel);
anim = new Animator(glJPanel);
anim.start();
} // GLTest()
public void paintComponent(Graphics g) {
System.out.println("go");
glJPanel.repaint();
} // paintComponent()
public void init(GLDrawable gld) {
gld.setGL(new DebugGL(gld.getGL()));
System.out.println("init");
} // init()
public void display(GLDrawable gld) {
GL gl = gld.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
gl.glLoadIdentity();
gl.glColor3f(1.0f, 0.0f, 0.0f );
gl.glBegin( GL.GL_TRIANGLES );
gl.glVertex3f( 0.0f, 0.0f, 0.0f );
gl.glVertex3f( 1.0f, 0.0f, 0.0f );
gl.glVertex3f( 1.0f, 1.0f, 0.0f );
gl.glEnd();
} // display()
public void reshape(GLDrawable gld, int x, int y, int w, int h) {} // reshape()
public void displayChanged(GLDrawable gld, boolean modeChng, boolean devChng) {} // displayChanged()
} // GLTest
The only thing about this that might be worth noting that doesn’t have anything to do with JOGL is that a GraphicsComponent is just a class that extends JPanel (and provides some other features for our program), and this will ultimately be added into a component that is inside a JInternalFrame. Could anyone tell me what might be going wrong here?
It doesn’t work either with or without an Animator present, and there is no code anywhere else in the program that uses JOGL (as this is a test file to try and make it work).
Thank you!
-Tom