[英]GLFW Window Creation Fails After glfwWindowHint() calls
我正在尝试使用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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.