Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ GLFW get监视器计数=0,连接了另外两个监视器_C++_Opengl_Glfw_Multiple Monitors - Fatal编程技术网

C++ GLFW get监视器计数=0,连接了另外两个监视器

C++ GLFW get监视器计数=0,连接了另外两个监视器,c++,opengl,glfw,multiple-monitors,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; } #包括 #包括 int main(){ 整数计数; GLFW

这是我的简单代码

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

int main() {

    int count;
    GLFWmonitor** monitors = glfwGetMonitors(&count); 
    std::cout << count << std::endl;
    return 0;
}
#包括
#包括
int main(){
整数计数;
GLFWmonitor**monitors=glfwGetMonitors(&count);

std::cout我猜您需要在执行任何其他操作之前调用
glfwInit()

从glfw文档中:

int glfwInit(无效)

此函数初始化GLFW库。在大多数GLFW函数之前 可以使用,GLFW必须在程序终止之前初始化 应终止GLFW以释放分配的任何资源 在初始化期间或之后

如果此函数失败,它将在返回前调用glfwTerminate 如果成功,则应在程序退出之前调用glfwTerminate

初始化成功后对此函数的其他调用,但 在终止之前将成功,但不会做任何事情

返回 如果成功,则为GL_TRUE;如果发生错误,则为GL_FALSE