加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 09:51:14 所属栏目:百科 来源:网络整理
导读:这是我的简单代码. #include iostream#include GLFW/glfw3.hint main() { int count; GLFWmonitor** monitors = glfwGetMonitors(count); std::cout count std::endl; return 0;} 由于某种原因,它一直告诉我有零监视器.我假设0意味着确实有1.但我有两台其他
这是我的简单代码.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读