*#include<GL\glew.h>
#include<GLFW\glfw3.h>
#include<iostream>
using namespace std;
void init(GLFWwindow* window) {}
void display(GLFWwindow* window, double currentTime)
{
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
}
int main(void)
{
if (!glfwInit()) { exit(EXIT_FAILURE);}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
GLFWwindow* window = glfwCreateWindow(600, 600, "Chapter2 - program1", NULL, NULL);
glfwMakeContextCurrent(window);
if (glewInit() != GLEW_OK) { exit(EXIT_FAILURE); }
glfwSwapInterval(1);
init(window);
while (!glfwWindowShouldClose(window))
{
display(window, glfwGetTime());
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
}
已经配置了glfw、glew环境,运行报错:
解决办法:
一、利用预处理命令#pragma comment(lib,"xxx.lib")
#pragma comment(lib,"glew32.lib")
二、配置项目属性
链接器->输入->附加依赖项 加入对应的库文件,即glew32.lib
注意:glew的lib文件有glew32.lib和glew32s.lib两种,如果出现默认库与其他库冲突的问题可以考虑是这两个文件的问题