【问题标题】:GLFW Window Creation Fails After glfwWindowHint() callsglfwWindowHint() 调用后 GLFW 窗口创建失败
【发布时间】:2014-09-18 03:46:08
【问题描述】:

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

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 错误 65543。 glfwCreateWindow() 正在返回 NULL;

【问题讨论】:

  • 您的程序是如何崩溃的?它是否在glfw 电话之一中,如果是,是哪一个?你能从崩溃中得到一个堆栈转储吗?
  • 您的笔记本电脑是否支持 OpenGL 4.1 或更高版本?您不使用the GLFW debug callback的任何原因?
  • 如果您在板载卡上运行,它可能不支持 GL4.1
  • 因为窗口为空而崩溃。此外,它也不适用于 OpenGL 3.3。这个版本使用 4.1,因为它在我的桌面上运行。

标签: c++ opengl glfw


【解决方案1】:

如果它向控制台打印错误 65543,则相当于 0x00010007,它在 glfw3.h 中定义为 GLFW_VERSION_UNAVAILABLE。

/*! @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

【讨论】:

    猜你喜欢
    • 2021-05-15
    • 2017-01-05
    • 2019-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-12
    • 2014-06-03
    • 2012-07-22
    相关资源
    最近更新 更多