Search in sources :

Example 1 with DisplayMode

use of com.badlogic.gdx.Graphics.DisplayMode in project AmazingMaze by TheVirtualMachine.

the class DesktopLauncher method main.

public static void main(String[] arg) {
    System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", "true");
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    DisplayMode displayMode = LwjglApplicationConfiguration.getDesktopDisplayMode();
    config.setFromDisplayMode(displayMode);
    config.title = "Amazing Maze";
    config.vSyncEnabled = true;
    config.foregroundFPS = 0;
    config.addIcon("icons/128.png", FileType.Internal);
    config.addIcon("icons/32.png", FileType.Internal);
    config.addIcon("icons/16.png", FileType.Internal);
    new LwjglApplication(new AmazingMazeGame(), config);
}
Also used : DisplayMode(com.badlogic.gdx.Graphics.DisplayMode) AmazingMazeGame(ca.hiphiparray.amazingmaze.AmazingMazeGame) LwjglApplication(com.badlogic.gdx.backends.lwjgl.LwjglApplication) LwjglApplicationConfiguration(com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration)

Example 2 with DisplayMode

use of com.badlogic.gdx.Graphics.DisplayMode in project libgdx by libgdx.

the class LwjglApplicationConfiguration method getDisplayModes.

public static DisplayMode[] getDisplayModes() {
    GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = genv.getDefaultScreenDevice();
    java.awt.DisplayMode desktopMode = device.getDisplayMode();
    java.awt.DisplayMode[] displayModes = device.getDisplayModes();
    ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
    int idx = 0;
    for (java.awt.DisplayMode mode : displayModes) {
        boolean duplicate = false;
        for (int i = 0; i < modes.size(); i++) {
            if (modes.get(i).width == mode.getWidth() && modes.get(i).height == mode.getHeight() && modes.get(i).bitsPerPixel == mode.getBitDepth()) {
                duplicate = true;
                break;
            }
        }
        if (duplicate)
            continue;
        if (mode.getBitDepth() != desktopMode.getBitDepth())
            continue;
        modes.add(new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()));
    }
    return modes.toArray(new DisplayMode[modes.size()]);
}
Also used : DisplayMode(com.badlogic.gdx.Graphics.DisplayMode) GraphicsDevice(java.awt.GraphicsDevice) ArrayList(java.util.ArrayList) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 3 with DisplayMode

use of com.badlogic.gdx.Graphics.DisplayMode in project libgdx by libgdx.

the class JglfwApplicationConfiguration method getDisplayModes.

public static DisplayMode[] getDisplayModes() {
    GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    java.awt.DisplayMode desktopMode = device.getDisplayMode();
    java.awt.DisplayMode[] displayModes = device.getDisplayModes();
    Array<DisplayMode> modes = new Array();
    outer: for (java.awt.DisplayMode mode : displayModes) {
        for (DisplayMode other : modes) if (other.width == mode.getWidth() && other.height == mode.getHeight() && other.bitsPerPixel == mode.getBitDepth())
            // Duplicate.
            continue outer;
        if (mode.getBitDepth() != desktopMode.getBitDepth())
            continue;
        modes.add(new JglfwDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()));
    }
    return modes.toArray(DisplayMode.class);
}
Also used : JglfwDisplayMode(com.badlogic.gdx.backends.jglfw.JglfwGraphics.JglfwDisplayMode) DisplayMode(com.badlogic.gdx.Graphics.DisplayMode) Array(com.badlogic.gdx.utils.Array) GraphicsDevice(java.awt.GraphicsDevice) JglfwDisplayMode(com.badlogic.gdx.backends.jglfw.JglfwGraphics.JglfwDisplayMode)

Example 4 with DisplayMode

use of com.badlogic.gdx.Graphics.DisplayMode in project libgdx by libgdx.

the class Lwjgl3ApplicationConfiguration method getDisplayModes.

/**
	 * @return the available {@link DisplayMode}s of the primary monitor
	 */
public static DisplayMode[] getDisplayModes() {
    Lwjgl3Application.initializeGlfw();
    Buffer videoModes = GLFW.glfwGetVideoModes(GLFW.glfwGetPrimaryMonitor());
    DisplayMode[] result = new DisplayMode[videoModes.limit()];
    for (int i = 0; i < result.length; i++) {
        GLFWVidMode videoMode = videoModes.get(i);
        result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(GLFW.glfwGetPrimaryMonitor(), videoMode.width(), videoMode.height(), videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits());
    }
    return result;
}
Also used : Buffer(org.lwjgl.glfw.GLFWVidMode.Buffer) PointerBuffer(org.lwjgl.PointerBuffer) IntBuffer(java.nio.IntBuffer) DisplayMode(com.badlogic.gdx.Graphics.DisplayMode) GLFWVidMode(org.lwjgl.glfw.GLFWVidMode)

Example 5 with DisplayMode

use of com.badlogic.gdx.Graphics.DisplayMode in project libgdx by libgdx.

the class DisplayModeTest method create.

@Override
public void create() {
    DisplayMode displayMode = Gdx.graphics.getDisplayMode();
    DisplayMode displayModeForMonitor = Gdx.graphics.getDisplayMode(Gdx.graphics.getMonitor());
    DisplayMode[] displayModes = Gdx.graphics.getDisplayModes();
    DisplayMode[] displayModesForMonitor = Gdx.graphics.getDisplayModes(Gdx.graphics.getMonitor());
    Gdx.app.log("DisplayModeTest", "Display mode (using Gdx.graphics.getDisplayMode() ) : " + displayMode);
    Gdx.app.log("DisplayModeTest", "Display mode (using Gdx.graphics.getDisplayMode(Gdx.graphics.getMonitor()) ) : " + Arrays.toString(displayModes));
    Gdx.app.log("DisplayModeTest", "Display mode (using Gdx.graphics.getDisplayModes() ) : " + Arrays.toString(displayModesForMonitor));
    Gdx.app.log("DisplayModeTest", "Display mode (using Gdx.graphics.getDisplayModes(Gdx.graphics.getMonitor()) ): " + displayModeForMonitor);
    assertDisplayModeEquals(displayMode, displayModeForMonitor);
    assertDisplayModesEquals(displayModes, displayModesForMonitor);
}
Also used : DisplayMode(com.badlogic.gdx.Graphics.DisplayMode)

Aggregations

DisplayMode (com.badlogic.gdx.Graphics.DisplayMode)9 Texture (com.badlogic.gdx.graphics.Texture)2 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)2 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)2 GraphicsDevice (java.awt.GraphicsDevice)2 IntBuffer (java.nio.IntBuffer)2 PointerBuffer (org.lwjgl.PointerBuffer)2 GLFWVidMode (org.lwjgl.glfw.GLFWVidMode)2 Buffer (org.lwjgl.glfw.GLFWVidMode.Buffer)2 AmazingMazeGame (ca.hiphiparray.amazingmaze.AmazingMazeGame)1 InputAdapter (com.badlogic.gdx.InputAdapter)1 JglfwDisplayMode (com.badlogic.gdx.backends.jglfw.JglfwGraphics.JglfwDisplayMode)1 LwjglApplication (com.badlogic.gdx.backends.lwjgl.LwjglApplication)1 LwjglApplicationConfiguration (com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration)1 Lwjgl3Application (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application)1 Lwjgl3ApplicationConfiguration (com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration)1 Lwjgl3Monitor (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics.Lwjgl3Monitor)1 Lwjgl3Window (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window)1 Lwjgl3WindowListener (com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowListener)1 FPSLogger (com.badlogic.gdx.graphics.FPSLogger)1