org.lwjgl.glfw.GLFW.glfwGetVideoModes()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.lwjgl.glfw.GLFW.glfwGetVideoModes()方法的一些代码示例,展示了GLFW.glfwGetVideoModes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwGetVideoModes()方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwGetVideoModes

GLFW.glfwGetVideoModes介绍

[英]Returns an array of all video modes supported by the specified monitor. The returned array is sorted in ascending order, first by color bit depth (the sum of all channel depths) and then by resolution area (the product of width and height).

The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified monitor is disconnected, this function is called again for that monitor or the library is terminated.

This function must only be called from the main thread.
[中]返回指定监视器支持的所有视频模式的数组。返回的数组按升序排序,首先按颜色位深度(所有通道深度之和)排序,然后按分辨率区域(宽度和高度的乘积)排序。
返回的数组由GLFW分配和释放。你不应该自己把它放出来。在指定的监视器断开连接、为该监视器再次调用此函数或终止库之前,此函数一直有效。
只能从主线程调用此函数。

代码示例

代码示例来源:origin: libgdx/libgdx

  1. /**
  2. * @return the available {@link DisplayMode}s of the given {@link Monitor}
  3. */
  4. public static DisplayMode[] getDisplayModes(Monitor monitor) {
  5. Lwjgl3Application.initializeGlfw();
  6. Buffer videoModes = GLFW.glfwGetVideoModes(((Lwjgl3Monitor)monitor).monitorHandle);
  7. DisplayMode[] result = new DisplayMode[videoModes.limit()];
  8. for (int i = 0; i < result.length; i++) {
  9. GLFWVidMode videoMode = videoModes.get(i);
  10. result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(((Lwjgl3Monitor)monitor).monitorHandle, videoMode.width(), videoMode.height(),
  11. videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits());
  12. }
  13. return result;
  14. }

代码示例来源:origin: libgdx/libgdx

  1. /**
  2. * @return the available {@link DisplayMode}s of the given {@link Monitor}
  3. */
  4. public static DisplayMode[] getDisplayModes(Monitor monitor) {
  5. Lwjgl3Application.initializeGlfw();
  6. Buffer videoModes = GLFW.glfwGetVideoModes(((Lwjgl3Monitor)monitor).monitorHandle);
  7. DisplayMode[] result = new DisplayMode[videoModes.limit()];
  8. for (int i = 0; i < result.length; i++) {
  9. GLFWVidMode videoMode = videoModes.get(i);
  10. result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(((Lwjgl3Monitor)monitor).monitorHandle, videoMode.width(), videoMode.height(),
  11. videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits());
  12. }
  13. return result;
  14. }

代码示例来源:origin: libgdx/libgdx

  1. /**
  2. * @return the available {@link DisplayMode}s of the primary monitor
  3. */
  4. public static DisplayMode[] getDisplayModes() {
  5. Lwjgl3Application.initializeGlfw();
  6. Buffer videoModes = GLFW.glfwGetVideoModes(GLFW.glfwGetPrimaryMonitor());
  7. DisplayMode[] result = new DisplayMode[videoModes.limit()];
  8. for (int i = 0; i < result.length; i++) {
  9. GLFWVidMode videoMode = videoModes.get(i);
  10. result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(GLFW.glfwGetPrimaryMonitor(), videoMode.width(), videoMode.height(),
  11. videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits());
  12. }
  13. return result;
  14. }

代码示例来源:origin: libgdx/libgdx

  1. /**
  2. * @return the available {@link DisplayMode}s of the primary monitor
  3. */
  4. public static DisplayMode[] getDisplayModes() {
  5. Lwjgl3Application.initializeGlfw();
  6. Buffer videoModes = GLFW.glfwGetVideoModes(GLFW.glfwGetPrimaryMonitor());
  7. DisplayMode[] result = new DisplayMode[videoModes.limit()];
  8. for (int i = 0; i < result.length; i++) {
  9. GLFWVidMode videoMode = videoModes.get(i);
  10. result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(GLFW.glfwGetPrimaryMonitor(), videoMode.width(), videoMode.height(),
  11. videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits());
  12. }
  13. return result;
  14. }

代码示例来源:origin: sriharshachilakapati/SilenceEngine

  1. /**
  2. * This function returns a list of all video modes supported by the specified monitor. The returned list is sorted
  3. * in ascending order, first by color bit depth (the sum of all channel depths) and then by resolution area (the
  4. * product of width and height).
  5. *
  6. * @return The list of {@link VideoMode}s supported by this Monitor object. Note that this list is unmodifiable.
  7. */
  8. public List<VideoMode> getVideoModes()
  9. {
  10. if (videoModes == null)
  11. {
  12. videoModes = new ArrayList<>();
  13. GLFWVidMode.Buffer modes = glfwGetVideoModes(handle);
  14. for (int i = 0; i < modes.capacity(); i++)
  15. {
  16. modes.position(i);
  17. int width = modes.width();
  18. int height = modes.height();
  19. int redBits = modes.redBits();
  20. int greenBits = modes.greenBits();
  21. int blueBits = modes.blueBits();
  22. int refreshRate = modes.refreshRate();
  23. videoModes.add(new VideoMode(width, height, redBits, greenBits, blueBits, refreshRate));
  24. }
  25. videoModes = Collections.unmodifiableList(videoModes);
  26. }
  27. return videoModes;
  28. }

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3

  1. /**
  2. * @return the available {@link DisplayMode}s of the given {@link Monitor}
  3. */
  4. public static DisplayMode[] getDisplayModes(Monitor monitor) {
  5. Lwjgl3Application.initializeGlfw();
  6. Buffer videoModes = GLFW.glfwGetVideoModes(((Lwjgl3Monitor)monitor).monitorHandle);
  7. DisplayMode[] result = new DisplayMode[videoModes.limit()];
  8. for (int i = 0; i < result.length; i++) {
  9. GLFWVidMode videoMode = videoModes.get(i);
  10. result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(((Lwjgl3Monitor)monitor).monitorHandle, videoMode.width(), videoMode.height(),
  11. videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits());
  12. }
  13. return result;
  14. }

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3

  1. /**
  2. * @return the available {@link DisplayMode}s of the primary monitor
  3. */
  4. public static DisplayMode[] getDisplayModes() {
  5. Lwjgl3Application.initializeGlfw();
  6. Buffer videoModes = GLFW.glfwGetVideoModes(GLFW.glfwGetPrimaryMonitor());
  7. DisplayMode[] result = new DisplayMode[videoModes.limit()];
  8. for (int i = 0; i < result.length; i++) {
  9. GLFWVidMode videoMode = videoModes.get(i);
  10. result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(GLFW.glfwGetPrimaryMonitor(), videoMode.width(), videoMode.height(),
  11. videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits());
  12. }
  13. return result;
  14. }

相关文章

GLFW类方法