Advertisement
Guest User

Untitled

a guest
Nov 18th, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. import org.lwjgl.LWJGLException;
  2. import org.lwjgl.opengl.Display;
  3. import org.lwjgl.opengl.DisplayMode;
  4. import org.lwjgl.opengl.GL11;
  5. import org.lwjgl.util.glu.GLU;
  6.  
  7. import static org.lwjgl.opengl.GL11.*;
  8. import static org.lwjgl.util.glu.GLU.*;
  9.  
  10. public class Main {
  11.     public static int HEIGHT = 800;
  12.     public static int WIDTH = 1000;
  13.  
  14.     public void start() {
  15.         try {
  16.         Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
  17.         Display.create();
  18.     } catch (LWJGLException e) {
  19.         e.printStackTrace();
  20.         System.exit(0);
  21.     }
  22.  
  23.     // init OpenGL here
  24.        
  25.  
  26.     /* Use depth buffering for hidden surface elimination. */
  27.       glEnable(GL_DEPTH_TEST);
  28.  
  29.       /* Setup the view of the cube. */
  30.       glMatrixMode(GL_PROJECTION);
  31.       glLoadIdentity();
  32.       gluPerspective(45, (float)WIDTH/(float)HEIGHT, 1, 100);
  33.       glMatrixMode(GL_MODELVIEW);
  34.  
  35.     int z = -50;
  36.     while (!Display.isCloseRequested()) {
  37.  
  38.         //glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear the background of our <a title="window" href="http://www.swiftless.com/tutorials/opengl/window.html">window</a> to red
  39.         glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
  40.         //glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations
  41.  
  42.         glColor3f(0f, 1f, 1f);
  43.         glBegin(GL_QUADS);
  44.         {
  45.             glVertex3i(10, 10, z);
  46.             glVertex3i(10+10, 10, z);
  47.             glVertex3i(10+10, 10+10, z);
  48.             glVertex3i(10, 10+10, z);
  49.         }
  50.         glEnd();
  51.  
  52.         glFlush(); // Flush the OpenGL buffers to the window
  53.         Display.update();
  54.     }
  55.        
  56.     Display.destroy();
  57.     }
  58.    
  59.     public static void main(String[] argv) {
  60.         Main m = new Main();
  61.         m.start();
  62.     }
  63. }
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement