如何在GLFW 3中创建OpenGL 1.2上下文

时间:2014-07-13 14:01:17

标签: c++ opengl window glfw openglcontext

我想创建OpenGL 1.2上下文,但是我收到此错误:“无法打开GLFW窗口”。 当我创建3.3或4.3上下文时,没有问题。如何创建1.2上下文?

glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

const GLFWvidmode * mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
WindowWidth = mode->width;
WindowHeight = mode->height;
midWindowWidth = WindowWidth / 2;
midWindowHeight = WindowHeight / 2;



window = glfwCreateWindow(WindowWidth, WindowHeight, "Quadcopter Project", glfwGetPrimaryMonitor(), NULL);
if( window == NULL )
{
    fprintf( stderr, "Failed to open GLFW window. \n" );
    glfwTerminate();
    return -1;
}

1 个答案:

答案 0 :(得分:3)

OpenGL中没有配置文件< 3.2。您无法创建1.2核心配置文件,因为没有这样的东西。

你们也不能直接强制驱动程序创建1.2上下文。请求特定上下文版本的功能在3.0中引入。基本上,3.0之前的所有内容都只是一些遗留背景。您可以要求1.2,但它可能会为您提供更高的(兼容性配置文件)上下文,具体取决于您尝试此操作的平台和驱动程序。