首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在调用glfwWindowHint()之后GLFW窗口创建失败

在调用glfwWindowHint()之后GLFW窗口创建失败
EN

Stack Overflow用户
提问于 2014-09-18 11:46:08
回答 1查看 1.6K关注 0票数 0

我正在尝试使用GLFW3创建一个窗口。当我在我的桌面上做这件事时,它工作得很好。在我的笔记本电脑上,它无法创建一个窗口,程序崩溃。删除glfwWindowHint()调用可以防止崩溃,但是我的代码不能工作,因为我得到了错误的openGL版本。下面是窗口代码:

代码语言:javascript
复制
Window::Window(int width, int height, std::string title, bool full)
{
    glfwInit();
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    m_width = width;
    m_height = height;
    if (full)
    {
        m_window = glfwCreateWindow(width, height, title.c_str(), glfwGetPrimaryMonitor(), nullptr);
    }
    else
    {
        m_window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr);
    }
    glfwMakeContextCurrent(m_window);

    glewExperimental = GL_TRUE;
    glewInit();
    glEnable(GL_DEPTH_TEST);
    glViewport(0, 0, width, height);

}

这是否与我的台式机使用NVidia显卡,而我的笔记本电脑使用集成显卡有关?

更新:它在调用glfwSwapBuffers()时崩溃,并且我已经将glfw error 65543输出到控制台。glfwCreateWindow()返回NULL;

EN

回答 1

Stack Overflow用户

发布于 2016-06-11 05:30:23

如果它向控制台输出错误65543,则等同于0x00010007,在glfw3.h中定义为GLFW_VERSION_UNAVAILABLE。

代码语言:javascript
复制
/*! @brief The requested OpenGL or OpenGL ES version is not available.
 *
 *  The requested OpenGL or OpenGL ES version (including any requested context
 *  or framebuffer hints) is not available on this machine.
 *
 *  @par Analysis
 *  The machine does not support your requirements.  If your application is
 *  sufficiently flexible, downgrade your requirements and try again.
 *  Otherwise, inform the user that their machine does not match your
 *  requirements.
 *
 *  @par
 *  Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
 *  comes out before the 4.x series gets that far, also fail with this error and
 *  not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
 *  will exist.
 */
#define GLFW_VERSION_UNAVAILABLE    0x00010007
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25903855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档