失败的glewInit:缺少GL版本

时间:2018-04-06 11:34:35

标签: c++ opengl glfw glew

我开始在课程上学习OpenGL。下载glew-2.1.0(64)和glfw-3.2.1(64)。就像连接的所有内容和IDE都没有发誓但初始化在命令行中产生以下输出:

  

错误初始化GLEW:缺少GL版

#include <iostream>
#define GLEW_STATIC
#include <GL/glew.h>
// GLFW
#include <GLFW/glfw3.h>
const char* APP_TITLE = "Introduction in modern openGL";

const int gWindowWidth = 800;
const int gWindowHeight = 600;

int main()
{
    if (!glfwInit())
    {
        std::cerr << "Failed in initialization GLFW" << std::endl;
        return -1;
    }
    glfwWindowHint(GLFW_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 
    GLFWwindow* pWindow = glfwCreateWindow(gWindowWidth, gWindowHeight, APP_TITLE, NULL, NULL);
    if (pWindow)
    {
        std::cerr << "Failed in create Windows" << std::endl;
        glfwTerminate();
        return -1;
    }
    glfwMakeContextCurrent(pWindow);

    glewExperimental = GL_TRUE;
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {

        std::cerr << "Error initialization GLEW: " << glewGetErrorString(err) << std::endl;
        glfwTerminate();
        return -1;
    }

    while (!glfwWindowShouldClose(pWindow))
    {
        glfwPollEvents();

        glfwSwapBuffers(pWindow);

    }
    glfwTerminate();
    return 0;
}

有什么问题?我在互联网上搜索过,但是有类型问题的解决方案:

  

添加glfwMakeContextCurrent(game_window);在glewInit()

之前

1 个答案:

答案 0 :(得分:1)

非常愚蠢的错误

我写了

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);  
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

我应该

$('.widget').find('tbody')
  .append($('<tr>')
    .append($('<td>')
    )
    .append($('<td>')
      .text('Median Values')
    )
    .append($('<td>')
      .text(5)
    )
    .append($('<td>')
      .text(6)
    )
    .append($('<td>')
      .text(7)
    )
    .append($('<td>')
      .text(8)
    )
    .append($('<td>')
      .text(4.2)
    )
  );