GLFW_RESIZABLE 创建后 window

GLFW_RESIZABLE after the creation of the window

我真的是从 LWJGL 开始的(我刚开始),我专注于一件事:当我创建一个 window 并且我想将它设置为不可调整大小时,我使用:

glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
window = glfwCreateWindow(WIDTH, HEIGHT, TITLE, NULL, NULL);

但是,即使我想在 创建 window 之后设置这个 ,我也不知道如何设置。我只是试图在创建 window 之后输入命令,但它不起作用:

window = glfwCreateWindow(WIDTH, HEIGHT, TITLE, NULL, NULL);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

那么,我该如何解决这个问题?

来自GLFW Window Guide

Window creation hints

There are a number of hints that can be set before the creation of a window and context. Some affect the window itself, others affect the framebuffer or context. These hints are set to their default values each time the library is initialized with glfwInit, can be set individually with glfwWindowHint and reset all at once to their defaults with glfwDefaultWindowHints.

Note that hints need to be set before the creation of the window and context you wish to have the specified attributes.

本质上,您通过 glfwWindowHint() 调用设置提示,例如 window 是否应该调整大小,它具有哪个上下文版本等。下次您使用 glfwCreateWindow() 创建 window 时将使用这些提示。如果在创建 window 之后设置提示 after,那么只有在调用之后创建的新 windows 会受到影响。

因此,目前无法在创建后更改某些 GLFW window 属性,例如是否可调整大小。

您现在可以更改 glfw Window 属性:

void glfwSetWindowAttrib(GLFWwindow * window, int attrib, int value);

来自 glfw3 or lwjgl

的文档

此函数设置指定window的属性值。

支持的属性有 GLFW_DECORATED、GLFW_RESIZABLE、GLFW_FLOATING、GLFW_AUTO_ICONIFY 和 GLFW_FOCUS_ON_SHOW。

对于全屏 windows,其中一些属性会被忽略。如果 window 稍后被 windowed.

,新值将生效

windowed 模式 windows 忽略了其中一些属性。如果 window 稍后全屏显示,新值将生效。