Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Tries to initalise a bunch of stuff.
- *
- * @return true if successful, false otherwise.
- */
- public boolean setup() {
- try {
- // Grab a list of display modes with our specified width and height
- // as the minimum and maximum requirement.
- DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(
- this.width,
- this.height,
- this.width,
- this.height,
- -1, -1, -1, -1);
- // Assume the first one is correct.
- // I don' give a shit.
- Display.setDisplayMode(dm[0]);
- // Finally actually make the drawing context.
- Display.create();
- } catch (Exception e) {
- System.out.println("Unable to create OpenGL window.");
- return false;
- }
- // Switch to the projection matrix and reset it.
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- // Give us an orthogonal display, setting the coordinates to match
- // the screen size rather than this -1.0 to 1.0 business.
- glOrtho(0, this.width, this.height, 0, -10, 10);
- glViewport(0, 0, this.width, this.height);
- // Switch to the model view (as in what we're drawing) and reset it.
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- // The game is now probably running!
- this.isRunning = true;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement