I'm trying to learn OpenGL basics via Justin Stoecker's JOGL Tutorials. However Eclipse gives me errors when I try to use some of the methods as he describes.
public class RenderingTest {
public static void main(String[] args) {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
GLContext con = GLContext.getCurrent() ;
GLCanvas canvas = new GLCanvas(canvas, 0, caps, null, con);
Frame frame = new Frame("AWT Window Test");
frame.setSize(300, 300);
frame.add(canvas); //doesn't compile
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() { //doesn't compile
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
Two problems: first java.awt.Frame
won't allow a GLCanvas
as an argument for the add
method. The second problem is similar, attempting to use the addWindowListener
method gives the error message: "The method addWindowListener(WindowListener) in the type Window is not applicable for the arguments (new WindowAdapter(){})." I'm confused because this code obviously worked when it was written. Being completely new to JOGL and GUI programming in general, I'm not sure what I need to change to make this run correctly.