如何在 C++ 的 GLFW 中获取 WindowSize?
How to get WindowSize in GLFW for C++?
我正在使用 ImGui 和 GLFW 开发应用程序,但是我不知道如何正确获取 Window 大小。
我知道 glfwGetWindowSize
确实存在,但是我不太明白它是如何工作的,特别是 int 和 width 参数。
我试过:初始化 int* w
和 int* h
并将它们插入函数中。然而那没有用。
你试过用这样的东西吗:
int width, height;
glfwGetWindowSize(window, &width, &height);
其中 window 是您的 window 实例。但是如果你对指针有问题,那么你应该按照评论的建议去做。但是,如果你想使用指针,试试这个:
int* width = new int(0);
int* height = new int(0);
glfwGetWindowSize(window, width, height);
//do stuff with the values
delete width;
width = nullptr;
delete height;
height = nullptr;
//this will delete the value and delete the pointer
我正在使用 ImGui 和 GLFW 开发应用程序,但是我不知道如何正确获取 Window 大小。
我知道 glfwGetWindowSize
确实存在,但是我不太明白它是如何工作的,特别是 int 和 width 参数。
我试过:初始化 int* w
和 int* h
并将它们插入函数中。然而那没有用。
你试过用这样的东西吗:
int width, height;
glfwGetWindowSize(window, &width, &height);
其中 window 是您的 window 实例。但是如果你对指针有问题,那么你应该按照评论的建议去做。但是,如果你想使用指针,试试这个:
int* width = new int(0);
int* height = new int(0);
glfwGetWindowSize(window, width, height);
//do stuff with the values
delete width;
width = nullptr;
delete height;
height = nullptr;
//this will delete the value and delete the pointer