Search in sources :

Example 1 with Buffer

use of org.lwjgl.glfw.GLFWVidMode.Buffer 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 2 with Buffer

use of org.lwjgl.glfw.GLFWVidMode.Buffer in project libgdx by libgdx.

the class Lwjgl3ApplicationConfiguration method getDisplayModes.

/**
	 * @return the available {@link DisplayMode}s of the given {@link Monitor}
	 */
public static DisplayMode[] getDisplayModes(Monitor monitor) {
    Lwjgl3Application.initializeGlfw();
    Buffer videoModes = GLFW.glfwGetVideoModes(((Lwjgl3Monitor) monitor).monitorHandle);
    DisplayMode[] result = new DisplayMode[videoModes.limit()];
    for (int i = 0; i < result.length; i++) {
        GLFWVidMode videoMode = videoModes.get(i);
        result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(((Lwjgl3Monitor) monitor).monitorHandle, 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) Lwjgl3Monitor(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics.Lwjgl3Monitor) GLFWVidMode(org.lwjgl.glfw.GLFWVidMode)

Example 3 with Buffer

use of org.lwjgl.glfw.GLFWVidMode.Buffer in project libgdx by libgdx.

the class GlfwTest method main.

public static void main(String[] argv) {
    GLFW.glfwSetErrorCallback(errorCallback);
    if (!glfwInit()) {
        System.out.println("Couldn't initialize GLFW");
        System.exit(-1);
    }
    glfwDefaultWindowHints();
    glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
    // fullscreen, not current resolution, fails
    Buffer modes = glfwGetVideoModes(glfwGetPrimaryMonitor());
    for (int i = 0; i < modes.limit(); i++) {
        System.out.println(modes.get(i).width() + "x" + modes.get(i).height());
    }
    GLFWVidMode mode = modes.get(7);
    System.out.println("Mode: " + mode.width() + "x" + mode.height());
    windowHandle = glfwCreateWindow(mode.width(), mode.height(), "Test", glfwGetPrimaryMonitor(), 0);
    if (windowHandle == 0) {
        throw new RuntimeException("Couldn't create window");
    }
    glfwMakeContextCurrent(windowHandle);
    GL.createCapabilities();
    glfwSwapInterval(1);
    glfwShowWindow(windowHandle);
    IntBuffer tmp = BufferUtils.createIntBuffer(1);
    IntBuffer tmp2 = BufferUtils.createIntBuffer(1);
    int fbWidth = 0;
    int fbHeight = 0;
    while (!glfwWindowShouldClose(windowHandle)) {
        glfwGetFramebufferSize(windowHandle, tmp, tmp2);
        if (fbWidth != tmp.get(0) || fbHeight != tmp2.get(0)) {
            fbWidth = tmp.get(0);
            fbHeight = tmp2.get(0);
            System.out.println("Framebuffer: " + tmp.get(0) + "x" + tmp2.get(0));
        //				GL11.glViewport(0, 0, tmp.get(0) * 2, tmp2.get(0) * 2);
        }
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        GL11.glBegin(GL11.GL_TRIANGLES);
        GL11.glVertex2f(-1f, -1f);
        GL11.glVertex2f(1f, -1f);
        GL11.glVertex2f(0, 1f);
        GL11.glEnd();
        glfwSwapBuffers(windowHandle);
        glfwPollEvents();
    }
    glfwDestroyWindow(windowHandle);
    glfwTerminate();
}
Also used : Buffer(org.lwjgl.glfw.GLFWVidMode.Buffer) IntBuffer(java.nio.IntBuffer) IntBuffer(java.nio.IntBuffer) GLFWVidMode(org.lwjgl.glfw.GLFWVidMode)

Aggregations

IntBuffer (java.nio.IntBuffer)3 GLFWVidMode (org.lwjgl.glfw.GLFWVidMode)3 Buffer (org.lwjgl.glfw.GLFWVidMode.Buffer)3 DisplayMode (com.badlogic.gdx.Graphics.DisplayMode)2 PointerBuffer (org.lwjgl.PointerBuffer)2 Lwjgl3Monitor (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics.Lwjgl3Monitor)1