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;
}
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;
}
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();
}
Aggregations