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

x33g5p2x  于2022-01-19 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(191)

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

GLFW.glfwSetWindowSize介绍

[英]Sets the size, in pixels, of the client area of the specified window.

For full screen windows, this function updates the resolution of its desired video mode and switches to the video mode closest to it, without affecting the window's context. As the context is unaffected, the bit depths of the framebuffer remain unchanged.

If you wish to update the refresh rate of the desired video mode in addition to its resolution, see #glfwSetWindowMonitor.

The window manager may put limits on what sizes are allowed. GLFW cannot and should not override these limits.

Notes:

  • This function must only be called from the main thread.
  • Wayland: A full screen window will not attempt to change the mode, no matter what the requested size.
    [中]设置指定窗口的客户端区域的大小(以像素为单位)。
    对于全屏窗口,此功能更新其所需视频模式的分辨率,并切换到最接近的视频模式,而不影响窗口的上下文。由于上下文不受影响,帧缓冲区的位深度保持不变。
    如果要更新所需视频模式的刷新率以及分辨率,请参阅#glfwSetWindowMonitor。
    窗口管理器可能会限制允许的大小。GLFW不能也不应超越这些限制。
    笔记:
    *只能从主线程调用此函数。
    *Wayland:无论请求的大小如何,全屏窗口都不会尝试更改模式。

代码示例

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

  1. @Override
  2. public boolean setWindowedMode(int width, int height) {
  3. window.getInput().resetPollingStates();
  4. if (!isFullscreen()) {
  5. GLFW.glfwSetWindowSize(window.getWindowHandle(), width, height);
  6. } else {
  7. if (displayModeBeforeFullscreen == null) {
  8. storeCurrentWindowPositionAndDisplayMode();
  9. }
  10. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), 0,
  11. windowPosXBeforeFullscreen, windowPosYBeforeFullscreen, width, height,
  12. displayModeBeforeFullscreen.refreshRate);
  13. }
  14. updateFramebufferInfo();
  15. return true;
  16. }

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

  1. @Override
  2. public boolean setWindowedMode(int width, int height) {
  3. window.getInput().resetPollingStates();
  4. if (!isFullscreen()) {
  5. GLFW.glfwSetWindowSize(window.getWindowHandle(), width, height);
  6. } else {
  7. if (displayModeBeforeFullscreen == null) {
  8. storeCurrentWindowPositionAndDisplayMode();
  9. }
  10. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), 0,
  11. windowPosXBeforeFullscreen, windowPosYBeforeFullscreen, width, height,
  12. displayModeBeforeFullscreen.refreshRate);
  13. }
  14. updateFramebufferInfo();
  15. return true;
  16. }

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

  1. ((OSVR)environment.getVRHardware()).getRenderSize(windowSize);
  2. windowSize.x = Math.max(windowSize.x * 2f, leftCamera.getWidth());
  3. org.lwjgl.glfw.GLFW.glfwSetWindowSize(window, (int)windowSize.x, (int)windowSize.y);
  4. environment.getApplication().getContext().getSettings().setResolution((int)windowSize.x, (int)windowSize.y);

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

  1. @Override
  2. public boolean setFullscreenMode(DisplayMode displayMode) {
  3. window.getInput().resetPollingStates();
  4. Lwjgl3DisplayMode newMode = (Lwjgl3DisplayMode) displayMode;
  5. if (isFullscreen()) {
  6. Lwjgl3DisplayMode currentMode = (Lwjgl3DisplayMode) getDisplayMode();
  7. if (currentMode.getMonitor() == newMode.getMonitor() && currentMode.refreshRate == newMode.refreshRate) {
  8. // same monitor and refresh rate
  9. GLFW.glfwSetWindowSize(window.getWindowHandle(), newMode.width, newMode.height);
  10. } else {
  11. // different monitor and/or refresh rate
  12. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), newMode.getMonitor(),
  13. 0, 0, newMode.width, newMode.height, newMode.refreshRate);
  14. }
  15. } else {
  16. // store window position so we can restore it when switching from fullscreen to windowed later
  17. storeCurrentWindowPositionAndDisplayMode();
  18. // switch from windowed to fullscreen
  19. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), newMode.getMonitor(),
  20. 0, 0, newMode.width, newMode.height, newMode.refreshRate);
  21. }
  22. updateFramebufferInfo();
  23. return true;
  24. }

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

  1. @Override
  2. public boolean setFullscreenMode(DisplayMode displayMode) {
  3. window.getInput().resetPollingStates();
  4. Lwjgl3DisplayMode newMode = (Lwjgl3DisplayMode) displayMode;
  5. if (isFullscreen()) {
  6. Lwjgl3DisplayMode currentMode = (Lwjgl3DisplayMode) getDisplayMode();
  7. if (currentMode.getMonitor() == newMode.getMonitor() && currentMode.refreshRate == newMode.refreshRate) {
  8. // same monitor and refresh rate
  9. GLFW.glfwSetWindowSize(window.getWindowHandle(), newMode.width, newMode.height);
  10. } else {
  11. // different monitor and/or refresh rate
  12. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), newMode.getMonitor(),
  13. 0, 0, newMode.width, newMode.height, newMode.refreshRate);
  14. }
  15. } else {
  16. // store window position so we can restore it when switching from fullscreen to windowed later
  17. storeCurrentWindowPositionAndDisplayMode();
  18. // switch from windowed to fullscreen
  19. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), newMode.getMonitor(),
  20. 0, 0, newMode.width, newMode.height, newMode.refreshRate);
  21. }
  22. updateFramebufferInfo();
  23. return true;
  24. }

代码示例来源:origin: jsettlers/settlers-remake

  1. public void async_set_size(int width, int height) {
  2. GLFW.glfwSetWindowSize(glfw_wnd, width, height);
  3. }

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

  1. /**
  2. * <p> This method sets the size, in screen coordinates, of the client area of this window.</p>
  3. *
  4. * <p> For full screen windows, this method selects and switches to the resolution closest to the specified size,
  5. * without affecting the window's context. As the context is unaffected, the bit depths of the framebuffer remain
  6. * unchanged.</p>
  7. *
  8. * <p> The window manager may put limits on what sizes are allowed. GLFW cannot and should not override these
  9. * limits.</p>
  10. *
  11. * @param size The new size of the client area of this window, in screen coordinates, as a Vector2.
  12. */
  13. public void setSize(Vector2 size)
  14. {
  15. this.size.set(size);
  16. glfwSetWindowSize(handle, (int) size.x, (int) size.y);
  17. }

代码示例来源:origin: fynnfluegge/oreon-engine

  1. public void resize(int width, int height) {
  2. glfwSetWindowSize(getId(), width, height);
  3. setHeight(height);
  4. setWidth(width);
  5. BaseContext.getConfig().setWindowWidth(width);
  6. BaseContext.getConfig().setWindowHeight(height);
  7. // TODO set camera projection
  8. }
  9. }

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

  1. @Override
  2. public boolean setWindowedMode(int width, int height) {
  3. window.getInput().resetPollingStates();
  4. if (!isFullscreen()) {
  5. GLFW.glfwSetWindowSize(window.getWindowHandle(), width, height);
  6. } else {
  7. if (displayModeBeforeFullscreen == null) {
  8. storeCurrentWindowPositionAndDisplayMode();
  9. }
  10. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), 0,
  11. windowPosXBeforeFullscreen, windowPosYBeforeFullscreen, width, height,
  12. displayModeBeforeFullscreen.refreshRate);
  13. }
  14. updateFramebufferInfo();
  15. return true;
  16. }

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

  1. @Override public void setSize (int width, int height, boolean fullscreen) {
  2. if (plat.config.fullscreen != fullscreen) {
  3. plat.log().warn("fullscreen cannot be changed via setSize, use config.fullscreen instead");
  4. return;
  5. }
  6. GLFWVidMode vidMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
  7. if (width > vidMode.width()) {
  8. plat.log().debug("Capping window width at desktop width: " + width + " -> " +
  9. vidMode.width());
  10. width = vidMode.width();
  11. }
  12. if (height > vidMode.height()) {
  13. plat.log().debug("Capping window height at desktop height: " + height + " -> " +
  14. vidMode.height());
  15. height = vidMode.height();
  16. }
  17. glfwSetWindowSize(window, width, height);
  18. // plat.log().info("setSize: " + width + "x" + height);
  19. viewSizeM.setSize(width, height);
  20. IntBuffer fbSize = BufferUtils.createIntBuffer(2);
  21. long addr = MemoryUtil.memAddress(fbSize);
  22. nglfwGetFramebufferSize(window, addr, addr + 4);
  23. viewportAndScaleChanged(fbSize.get(0), fbSize.get(1));
  24. }

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

  1. @Override
  2. public boolean setFullscreenMode(DisplayMode displayMode) {
  3. window.getInput().resetPollingStates();
  4. Lwjgl3DisplayMode newMode = (Lwjgl3DisplayMode) displayMode;
  5. if (isFullscreen()) {
  6. Lwjgl3DisplayMode currentMode = (Lwjgl3DisplayMode) getDisplayMode();
  7. if (currentMode.getMonitor() == newMode.getMonitor() && currentMode.refreshRate == newMode.refreshRate) {
  8. // same monitor and refresh rate
  9. GLFW.glfwSetWindowSize(window.getWindowHandle(), newMode.width, newMode.height);
  10. } else {
  11. // different monitor and/or refresh rate
  12. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), newMode.getMonitor(),
  13. 0, 0, newMode.width, newMode.height, newMode.refreshRate);
  14. }
  15. } else {
  16. // store window position so we can restore it when switching from fullscreen to windowed later
  17. storeCurrentWindowPositionAndDisplayMode();
  18. // switch from windowed to fullscreen
  19. GLFW.glfwSetWindowMonitor(window.getWindowHandle(), newMode.getMonitor(),
  20. 0, 0, newMode.width, newMode.height, newMode.refreshRate);
  21. }
  22. updateFramebufferInfo();
  23. return true;
  24. }

相关文章

GLFW类方法