Advertisement
Guest User

Window.java

a guest
Apr 12th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. package base;
  2.  
  3. import org.lwjgl.LWJGLException;
  4. import org.lwjgl.opengl.ContextAttribs;
  5. import org.lwjgl.opengl.Display;
  6. import org.lwjgl.opengl.DisplayMode;
  7. import org.lwjgl.opengl.PixelFormat;
  8. import org.lwjgl.util.vector.Vector3f;
  9.  
  10. import static org.lwjgl.util.glu.GLU.*;
  11. import static org.lwjgl.opengl.GL11.*;
  12.  
  13. import entities.*;
  14.  
  15. public class Window {
  16.  
  17.     int WIDTH = 1280, HEIGHT = 720;
  18.     Camera camera;
  19.     public static void main(String[] args) {
  20.         Window w = new Window();
  21.         w.game();
  22.     }
  23.    
  24.     public void game(){
  25.         setupWindow();
  26.         setupMatrices();
  27.         Cube c = new Cube();
  28.         c.setup();
  29.         c.setupShaders();
  30.        
  31.         Timer.lastFPS = Timer.getTime();
  32.        
  33.         while(!Display.isCloseRequested()){
  34.             glClear(GL_COLOR_BUFFER_BIT);
  35.            
  36.             camera.cameraLogic();
  37.            
  38.             /**
  39.              * Render Loop
  40.              * */
  41.             c.render();
  42.            
  43.             Timer.updateFPS();
  44.             Display.update();
  45.             Display.sync(120);
  46.         }
  47.        
  48.         Display.destroy();
  49.         System.exit(0);
  50.     }
  51.    
  52.     public void setupWindow(){
  53.         try{
  54.             PixelFormat pixelFormat = new PixelFormat();
  55.             ContextAttribs contextAttributes = new ContextAttribs(3, 3).withForwardCompatible(true).withProfileCore(true);
  56.             Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
  57.             Display.create(pixelFormat, contextAttributes);
  58.             Display.setTitle("Shadertest");
  59.         } catch(LWJGLException e) {
  60.             e.printStackTrace();
  61.             Display.destroy();
  62.             System.exit(0);
  63.         }
  64.        
  65.         glClearColor(0.4f, 0.6f, 0.9f, 0f);
  66.         glViewport(0, 0, WIDTH, HEIGHT);
  67.     }
  68.    
  69.     public void setupMatrices(){
  70.         Matrices.setupPerspective(70.0f, (float)WIDTH, (float)HEIGHT, 0.1f, 100.0f);
  71.         Matrices.setupModel();
  72.         camera = new Camera();
  73.        
  74.     }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement