Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.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++ glfwWindowHint()调用后,GLFW窗口创建失败_C++_Opengl_Glfw - Fatal编程技术网

C++ glfwWindowHint()调用后,GLFW窗口创建失败

C++ glfwWindowHint()调用后,GLFW窗口创建失败,c++,opengl,glfw,C++,Opengl,Glfw,我正在尝试使用GLFW3创建一个窗口。当我在我的桌面上这样做时,效果很好。在我的笔记本电脑上,它无法创建窗口,程序崩溃。删除glfwWindowHint调用可以防止崩溃,但我的代码无法工作,因为我得到了错误的openGL版本。以下是窗口代码: Window::Window(int width, int height, std::string title, bool full) { glfwInit(); glfwWindowHint(GLFW_OPENGL_FORWARD_COM

我正在尝试使用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

如果它将错误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

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