尝试使用GLFW3创建OpenGL上下文时出现GLXBadConfig错误

时间:2018-01-22 15:44:53

标签: c++ ubuntu opengl glfw drivers

在我破坏操作系统之前,我正在处理的代码无效。我知道我的硬件能够运行这个程序,但我的操作系统一定有问题。

#include <iostream>
#include <chrono>
#include <cmath>

#define GLM_FORCE_RADIANS
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/quaternion.hpp>

#define WIDTH 1024
#define HEIGHT 1024

#include "input.hpp"
#include "shaderloader.hpp"
#include "objfile.hpp"
#include "camera.hpp"
#include "gldebug.hpp"

GLFWwindow* mainwin;

void error_cb(int i, const char * error){
    std::cout << error << std::endl;
}

int main(){
    glfwSetErrorCallback(error_cb);

    glfwInit();

    //glfwWindowHint(GLFW_OPENGL_PROFILE, 0);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
    mainwin = glfwCreateWindow(WIDTH, HEIGHT, "OPENGL", NULL, NULL);


    if(mainwin == nullptr){ // Executes
        cout << "Error: couldn't initialize window" << endl;
        return 0;
    }

    ...
}

节目输出:

GLX: Failed to create context: GLXBadFBConfig
Error: couldn't initialize window

输出“lspci | grep'VGA'”:

00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)

glxinfo的部分输出:

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Sandybridge Mobile 
OpenGL core profile version string: 3.1 (Core Profile) Mesa 10.1.3
OpenGL core profile shading language version string: 1.40
OpenGL core profile context flags: (none)
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.1.3
OpenGL shading language version string: 1.30

这个程序中的着色器是用“#version 150 core”编写的,所以我认为我需要做一些提升GLSL版本的东西。

0 个答案:

没有答案