Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1.     /**
  2.      * Tries to initalise a bunch of stuff.
  3.      *
  4.      * @return true if successful, false otherwise.
  5.      */
  6.     public boolean setup() {
  7.         try {
  8.             // Grab a list of display modes with our specified width and height
  9.             // as the minimum and maximum requirement.
  10.             DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(
  11.                     this.width,
  12.                     this.height,
  13.                     this.width,
  14.                     this.height,
  15.                     -1, -1, -1, -1);
  16.            
  17.             // Assume the first one is correct.
  18.             // I don' give a shit.
  19.             Display.setDisplayMode(dm[0]);
  20.            
  21.             // Finally actually make the drawing context.
  22.             Display.create();
  23.         } catch (Exception e) {
  24.             System.out.println("Unable to create OpenGL window.");
  25.             return false;
  26.         }
  27.        
  28.         // Switch to the projection matrix and reset it.
  29.         glMatrixMode(GL_PROJECTION);
  30.         glLoadIdentity();
  31.        
  32.         // Give us an orthogonal display, setting the coordinates to match
  33.         // the screen size rather than this -1.0 to 1.0 business.
  34.         glOrtho(0, this.width, this.height, 0, -10, 10);
  35.         glViewport(0, 0, this.width, this.height);
  36.        
  37.         // Switch to the model view (as in what we're drawing) and reset it.
  38.         glMatrixMode(GL_MODELVIEW);
  39.         glLoadIdentity();
  40.        
  41.         // The game is now probably running!
  42.         this.isRunning = true;
  43.        
  44.         return true;
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement