Cuadrado en jogl

Solo disponible en BuenasTareas
  • Páginas : 2 (426 palabras )
  • Descarga(s) : 14
  • Publicado : 27 de julio de 2010
Leer documento completo
Vista previa del texto
import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.*;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

public class Graficos implements GLEventListener,KeyListener {

private float zoom=-150f,rotax=0.0f,rotay=0.0f,rotaz=0.0f;
private static final GLU glu = new GLU();

public static void main(String[] args) {
Frame frame = new Frame("Simple JOGL Application");
GLCanvas canvas = newGLCanvas();
canvas.addGLEventListener(new Graficos());
frame.add(canvas);
frame.setSize(1200, 700);
final Animator animator = new Animator(canvas);frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
public void run() {animator.stop();
System.exit(0);
}
}).start();
}
});
// Center frameframe.setLocationRelativeTo(null);
frame.setVisible(true);
animator.start();
}

public void display(GLAutoDrawable gLDrawable) {
final GL gl = gLDrawable.getGL();gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
//gl.glTranslatef(0.0f, 0.0f, -4.0f);
gl.glTranslated(0,0,zoom);gl.glRotatef(rotax, 1,0,0);
gl.glRotatef(rotay, 0,1,0);
gl.glRotatef(rotaz, 0,0,1);

gl.glBegin(gl.GL_LINES);
gl.glColor3f(1.0f, 1.0f, 1.0f); gl.glVertex3f(0.0f,...
tracking img