Opengl 关于GL 3.2以下GLFW行为的问题

Opengl 关于GL 3.2以下GLFW行为的问题,opengl,glfw,Opengl,Glfw,在开始学习opengl之后,我有以下源代码: #include <stdio.h> #include <stdlib.h> #include <GL/glew.h> #include <GL/glfw.h> #include <glm/glm.hpp> using namespace glm; int main(void){ if(!glfwInit()) { fprintf( stderr, "Fa

在开始学习opengl之后,我有以下源代码:

#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw.h>
#include <glm/glm.hpp>

using namespace glm;

int
main(void){
    if(!glfwInit())
    {
        fprintf( stderr, "Failed to initialize GLFW\n" );
        return -1;
    }

    glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x antialiasing
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // We want OpenGL 3.1
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL

    // Open a window and create its OpenGL context
    if(!glfwOpenWindow(1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW))
    {
        int a = glfwOpenWindow(1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW);
          fprintf( stderr, "Failed to open GLFW window\n" );
          glfwTerminate();
          return 1;
    }

}

如果这是原因(看起来是),那么这到底意味着什么?为什么它会阻止创建窗口?

请阅读源代码中的注释消息。它说:

上下文配置文件仅为OpenGL 3.2版及以上版本定义

OpenGL 3.1中不存在a的概念。因此,当您要求3.1版时,您不能这样做:

glfwOpenWindowHint(GLFW_OPENGL_配置文件、GLFW_OPENGL_核心_配置文件)

你要求的东西根本不存在,所以GLFW不让你这么做


如果你想要一个核心档案,那么要求GL 3.2或更高版本。如果你要求的是较低的GL版本,那么就不要再要求核心配置文件了。

是否回答了你的问题?因此基本上GFLW有一个更新,而现在3.2以下的ogl不起作用了?好吧,我不明白为什么教程有这个(以及为什么它显然对制作教程的人有效)@JV:它只是有一个bug。向作者报告。
if( wndconfig.glProfile &&
    ( wndconfig.glMajor < 3 || ( wndconfig.glMajor == 3 && wndconfig.glMinor < 2 ) ) )
{
    // Context profiles are only defined for OpenGL version 3.2 and above
    return GL_FALSE;
}