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

标签 c++ opengl glfw multiple-monitors

这是我的简单代码。

#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/

相关文章:

java - GLFW (LWJGL) 输入 - 按住 CTRL 会阻止 CharCallback

c++ - 函数原型(prototype) vs 在 cpp 中包含 header

c++ - GLFW 错误 - GLFWwindow* 未被识别为有效参数

c - 如何在 Linux 上构建 GLFW3 项目?

java - LWJGL 四边形渲染问题 - 原本是正方形的对象变成了矩形

c++ - 使用 wprintf 打印 opengl 着色器编译日志

c++ - LNK4098 - 使用 GLFW 的 'MSVCRT' 冲突

c++ - 如何在不指定数组大小的情况下声明数组,但在 C++ 的类中使用初始化程序?

c++ - 在 C++ 中将汇编内联到字节

c++ - 如果我的模板特化没有被执行,为什么它会被编译?