All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gnu.app.redbook.Cube Maven / Gradle / Ivy

Go to download

Escher is a collection of libraries for X Window System written purely in Java.

The newest version!
package gnu.app.redbook;

import gnu.x11.extension.glx.GL;


/**
 * Draw a wireframe cube. To demonstrate a single modeling transformation,
 * {@link GL#scalef} and a single viewing transformation, and {@link
 * gnu.x11.extension.glx.GLU#look_at}. Modified from cube.c.
 *
 * @see 
 * screenshot
 * 
 * @see 
 * help output
 */
public class Cube extends gnu.x11.extension.glx.Application {
  public Cube (String [] args) {
    super (args, RESIZE_BIT);

    about ("0.1", "wireframe cube",
      "Stephen Tse ",
      "http://escher.sourceforge.net/");

    if (help_option) return;
    init_window (500, 500);

    gl.shade_model (GL.FLAT);
  }


  protected void handle_expose () {
    gl.clear (GL.COLOR_BUFFER_BIT);

    gl.load_identity ();
    glu.look_at (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
    gl.scalef (1.0f, 2.0f, 1.0f);
    glut.wire_cube (1.0f);

    gl.swap_buffers (window);
  }


  protected void handle_resize (int width, int height) {
    gl.viewport (0, 0, width, height);
    gl.matrix_mode (GL.PROJECTION);
    gl.load_identity ();   
    gl.frustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
    gl.matrix_mode (GL.MODELVIEW);
  }


  public static void main (String [] args) {
    new Cube (args).exec ();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy