Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package base;
- import org.lwjgl.LWJGLException;
- import org.lwjgl.opengl.ContextAttribs;
- import org.lwjgl.opengl.Display;
- import org.lwjgl.opengl.DisplayMode;
- import org.lwjgl.opengl.PixelFormat;
- import org.lwjgl.util.vector.Vector3f;
- import static org.lwjgl.util.glu.GLU.*;
- import static org.lwjgl.opengl.GL11.*;
- import entities.*;
- public class Window {
- int WIDTH = 1280, HEIGHT = 720;
- Camera camera;
- public static void main(String[] args) {
- Window w = new Window();
- w.game();
- }
- public void game(){
- setupWindow();
- setupMatrices();
- Cube c = new Cube();
- c.setup();
- c.setupShaders();
- Timer.lastFPS = Timer.getTime();
- while(!Display.isCloseRequested()){
- glClear(GL_COLOR_BUFFER_BIT);
- camera.cameraLogic();
- /**
- * Render Loop
- * */
- c.render();
- Timer.updateFPS();
- Display.update();
- Display.sync(120);
- }
- Display.destroy();
- System.exit(0);
- }
- public void setupWindow(){
- try{
- PixelFormat pixelFormat = new PixelFormat();
- ContextAttribs contextAttributes = new ContextAttribs(3, 3).withForwardCompatible(true).withProfileCore(true);
- Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
- Display.create(pixelFormat, contextAttributes);
- Display.setTitle("Shadertest");
- } catch(LWJGLException e) {
- e.printStackTrace();
- Display.destroy();
- System.exit(0);
- }
- glClearColor(0.4f, 0.6f, 0.9f, 0f);
- glViewport(0, 0, WIDTH, HEIGHT);
- }
- public void setupMatrices(){
- Matrices.setupPerspective(70.0f, (float)WIDTH, (float)HEIGHT, 0.1f, 100.0f);
- Matrices.setupModel();
- camera = new Camera();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement