15,447
社区成员




#include<iostream>
#include<gl/glew.h>
#define GLUT_DISABLE_ATEXIT_HACK
#include<gl/glut.h>
#include<gl/freeglut_ext.h>
#include<gl/freeglut.h>
#pragma comment(lib, "glut32.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "freeglut_static.lib")
#pragma comment(lib, "freeglut.lib")
#pragma comment(lib, "glew32.lib")
using namespace std;
GLuint VAOs[1];
GLuint Buffers[1];
void init()
{
glGenVertexArrays(0, VAOs);
glBindVertexArray(VAOs[0]);
GLfloat vertices[6][2] = {
{-0.90, -0.90},
{ 0.85, -0.90},
{-0.90, 0.85},
{ 0.90, -0.85},
{ 0.90, 0.90},
{-0.85, 0.90},
};
glGenBuffers(1, Buffers);
glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_STATIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
glBindVertexArray(0);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBindVertexArray(VAOs[0]);
glDrawArrays(GL_TRIANGLES, 0, 6);
glFlush();
glBindVertexArray(0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(512,512);
glutInitContextVersion(4,3);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutCreateWindow(argv[0]);
if(glewInit()){
cerr<<"Unable to initialize GLEW..."<<endl;
exit(EXIT_FAILURE);
}
init();
glutDisplayFunc(display);
glutMainLoop();
}
#define GLUT_DISABLE_ATEXIT_HACK
#pragma comment(lib, "glut32.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "freeglut_static.lib")
#pragma comment(lib, "freeglut.lib")
#pragma comment(lib, "glew32.lib")
1>Source.obj : error LNK2019: 无法解析的外部符号 __imp__glutInitContextVersion@8,该符号在函数 _main 中被引用
1>Source.obj : error LNK2019: 无法解析的外部符号 __imp__glutInitContextProfile@4,该符号在函数 _main 中被引用
1>E:\Project\VS\tem\Debug\tem.exe : fatal error LNK1120: 2 个无法解析的外部命令