Can’t seem to find the GLAutoDrawable :S
Anyone know the reason?
Code:
public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glClearColor(0, 0, 0, 0);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0, 1, 0, 1, -1, 1);
}
Whole code: I changed others that said GLAutoDrawable to GLDrawable to see if that would work -.-
import net.java.games.jogl.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import net.java.games.jogl.GLCanvas.*;
//import net.java.games.jogl.GLAutoDrawable;
public class Main {
public static void main(String[] args) {
HelloWorldDemo test = new HelloWorldDemo();
test.setVisible(true);
}
}
class HelloWorldDemo extends JFrame implements GLEventListener, WindowListener {
public HelloWorldDemo() {
super("Basic JOGL Demo");
setLayout(new BorderLayout());
addWindowListener(this);
setSize(600, 600);
setLocation(40, 40);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void setupJOGL() {
GLCapabilities caps = new GLCapabilities();
caps.setDoubleBuffered(true);
caps.setHardwareAccelerated(true);
GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(caps);
canvas.addGLEventListener(this);
add(canvas, BorderLayout.CENTER);
Animator anim = new Animator(canvas);
anim.start();
}
public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glClearColor(0, 0, 0, 0);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0, 1, 0, 1, -1, 1);
}
public void reshape(GLDrawable drawable, int x, int y, int width, int height) {
}
public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
public void windowDeactivated(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void display(GLDrawable drawable) {
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glBegin(200);
float l = 1;
gl.glColor3f(1, 0, 0);
gl.glVertex3f(0.25f, 0.25f, 0);
gl.glColor3f(0, 1, 0);
gl.glVertex3f(0.5f, 0.25f, 0);
gl.glColor3f(0, 0, 1);
gl.glVertex3f(0.25f, 0.5f, 0);
gl.glEnd();
gl.glFlush();
}
}