我正在尝试使用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 error 65543输出到控制台。glfwCreateWindow()返回NULL;
发布于 2016-06-11 05:30:23
如果它向控制台输出错误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 0x00010007https://stackoverflow.com/questions/25903855
复制相似问题