gpt4 book ai didi

c++ - GLFW get Monitors count = 0,附加了另外两个监视器

转载 作者:太空狗 更新时间:2023-10-29 20:13:15 28 4
gpt4 key购买 nike

这是我的简单代码。

#include <iostream>
#include <GLFW/glfw3.h>

int main() {

int count;
GLFWmonitor** monitors = glfwGetMonitors(&count);
std::cout << count << std::endl;
return 0;
}

出于某种原因,它一直告诉我有零监视器。我假设 0 表示确实有 1。但是我的计算机上连接了另外两个显示器。当我进入系统首选项时,我可以清楚地看到另外两个显示器。但我不知道为什么它一直告诉我零。我不知道问题是什么。

最佳答案

我猜你需要先调用 glfwInit(),然后再做其他事情。

来自 glfw 文档:

int glfwInit (void)

This function initializes the GLFW library. Before most GLFW functions can be used, GLFW must be initialized, and before a program terminates GLFW should be terminated in order to free any resources allocated during or after initialization.

If this function fails, it calls glfwTerminate before returning. If it succeeds, you should call glfwTerminate before the program exits.

Additional calls to this function after successful initialization but before termination will succeed but will do nothing.

Returns GL_TRUE if successful, or GL_FALSE if an error occurred.

关于c++ - GLFW get Monitors count = 0,附加了另外两个监视器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22520706/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com