【发布时间】:2017-02-03 21:56:40
【问题描述】:
由于以下错误消息(我在 Windows 上),我无法打开 OpenGL 窗口:
GLFW Error Code 65543: WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable.
我的问题很可能是驱动程序问题。我尝试更新它们(使用英特尔驱动程序更新实用程序),但没有成功(而且我的驱动程序似乎已经是最新的)。我使用内置的 Intel HD Graphics 3000。我还安装了一个 OpenGL 查看器,它告诉我我的 OpenGL 版本是 3.1)。
另外,我试过this solution。
整个 C++ 代码非常庞大,所以我不会全部复制,但这里是有趣的部分:
if( !glfwInit() )
{
std::cerr<<"Failed to initialize GLFW\n"<<std::endl;
return -1;
}
glfwSetErrorCallback(glfwErrorCallback);
// Create the OpenGL window
glfwWindowHint(GLFW_DEPTH_BITS, 16);
glfwWindowHint(GLFW_SAMPLES, 4);
//Those stop GLFW from initializing successfully?
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open OpenGL fullscreen window
gGLFWWindow = glfwCreateWindow(gWidth,gHeight,"GLFW OpenGL Window",nullptr,nullptr);
if(!gGLFWWindow)
{
std::cerr<<"Failed to open GLFW window\n"<<std::endl;
glfwTerminate();
return -1;
}
// Disable VSync (we want to get as high FPS as possible!)
glfwMakeContextCurrent(gGLFWWindow);
glfwSwapInterval( 1 );
// Setting this is necessary for core profile (tested with MSVC 2013 x64, Windows 7)
glewExperimental = GL_TRUE;
// GLEW wraps all OpenGL functions and extensions
GLenum err = glewInit();
if(err != GLEW_OK)
{
std::cerr<<"Failed to initialize GLEW"<<std::endl;
std::cerr<<(char*)glewGetErrorString(err)<<std::endl;
glfwTerminate();
return -1;
}
glGetError(); //GLEW might cause an 'invalid enum' error, safely ignore it?
// Print OpenGL context information to console
ogl::printContextInformation();
// Perform our initialization (OpenGL states, shader, camera, geometry)
if(!init())
return -1;
在这一行失败了:
gGLFWWindow = glfwCreateWindow(gWidth,gHeight,"GLFW OpenGL Window",nullptr,nullptr);
有人知道我可以做些什么来解决这个问题吗?
【问题讨论】:
-
如果您只有 OpenGL 3.1,为什么要请求 Core 3.3 上下文?
-
因为我不理解所有这些代码(它是给我的,我必须从中工作),但你实际上是对的。我评论了这些行,它成功了,谢谢!