【发布时间】:2018-04-06 11:34:34
【问题描述】:
我在课程中开始学习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() 之前
【问题讨论】: