Package fm.ak.otse

Source Code of fm.ak.otse.Screen

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fm.ak.otse;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

/**
* it doesn't abstract org.lwjgl.opengl.Display fully, so you may still want to
* use that directly, e.g. Display.setTitle. This class merely accommodates it
* with some helpers
*
* provided by {@link Otse}
*
* @author otse
*/
public final class Screen {
    private Otse base;
   
    public String title = "otse";
   
    DisplayMode displaymode;
   
    private int width;
    private int height;
    private float aspect;
   
    Screen(Otse base) {
        this.base = base;
    }
   
    /**
     * creates the screen
     *
     * @param width
     * @param height
     * @param fullscreen
     * @throws LWJGLException
     */
    public final void create
            (int width, int height, boolean fullscreen)
            throws LWJGLException {       
        this.width = width;
        this.height = height;
       
        DisplayMode desktop = Display.getDesktopDisplayMode();

        if ( fullscreen  &&  desktop.isFullscreenCapable() ) {
            Display.setDisplayMode(desktop);
            Display.setFullscreen(true);
           
            this.width = desktop.getWidth();
            this.height = desktop.getHeight();
        } else {
            displaymode = new DisplayMode(this.width, this.height);
            Display.setDisplayMode(displaymode);
        }

        aspect = (float) this.width / (float) this.height;
       
        System.out.println(aspect);
       
        Display.setTitle(title);
        Display.setVSyncEnabled(true);
        Display.create();
       
        base.getMouse().enable(true);
        base.getKeyboard().enable(true);
       
        org.lwjgl.input.Mouse.create();
        org.lwjgl.input.Keyboard.create();
    }
   
    public DisplayMode getDisplayMode() {
        return displaymode;
    }
       
    public int getWidth() {
        return width;
    }
   
    public int getHeight() {
        return height;
    }
   
    public float getAspect() {
        return aspect;
    }
}
TOP

Related Classes of fm.ak.otse.Screen

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.