Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package se.wouix.voxel;
- import org.lwjgl.*;
- import org.lwjgl.opengl.*;
- import org.lwjgl.util.glu.GLU;
- import se.wouix.voxel.gamestatemanager.GameStateManager;
- public class VoxelEngine implements Runnable {
- public static int HEIGHT = 800;
- public static int WIDTH = 900;
- public static double UPS = 60.0;
- public static final DisplayMode DISPLAY_MODE = new DisplayMode(WIDTH, HEIGHT);
- public static final String TITLE = "Voxel Tech Test";
- public void init() throws LWJGLException {
- Display.setDisplayMode(DISPLAY_MODE);
- Display.setTitle(TITLE);
- Display.setResizable(true);
- Display.create();
- GL11.glClearColor(0.1f, 0.4f, 0.9f, 1.0f);
- GL11.glEnable(GL11.GL_DEPTH_TEST);
- GL11.glEnable(GL11.GL_COLOR_MATERIAL);
- GL11.glMatrixMode(GL11.GL_PROJECTION);
- GLU.gluPerspective(45f, DISPLAY_MODE.getWidth()/DISPLAY_MODE.getHeight(), 0.1f, 1000f);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- }
- public void run() {
- try {
- init();
- } catch (LWJGLException e) {
- System.err.println("LWJGL Failed to load");
- }
- GameStateManager gsm = new GameStateManager();
- Timer timer = new Timer(UPS);
- while (!Display.isCloseRequested()) {
- timer.updateTimer();
- while (timer.rightTime()) {
- gsm.update();
- }
- Display.update();
- {
- GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
- GL11.glLoadIdentity();
- GL11.glPushMatrix();
- {
- gsm.render();
- }
- GL11.glPopMatrix();
- }
- timer.afterSecond();
- }
- }
- public static void main(String[] args) {
- new Thread(new VoxelEngine()).start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement