帮忙看看这个错误

zhulei1978 2019-06-25 08:37:02
#include <stdlib.h>
#include <GL/glut.h>

GLfloat vetices[][3]={{-1.0,-1.0,1.0},{-1.0,1.0,1.0},
{1.0,1.0,1.0},{1.0,-1.0,1.0},{-1.0,-1.0,-1.0},
{-1.0,1.0,-1.0},{1.0,1.0,-1.0},{1.0,-1.0,-1.0}};

GLfloat colors[][3]={{1.0,0.0,0.0},
{0.0,1.0,1.0}, {1.0,1.0,0.0},{0.0,1.0,0.0},
{0.0,0.0,1.0}, {1.0,0.0,1.0},
{0.0,0.0,0.0},{1.0,1.0,1.0}};

void polygon(int a,int b,int c,int d)
{
glBegin(GL_POLYGON);
glColor3fv(colors[a]);
glTextCoord2f(0.0,0.0);
glVertext3fv(vetices[a]);
glColor3fv(colors[b]);
glTextCoord2f(0.0,1.0);
glVertext3fv(vetices[b]);
glColor3fv(colors[c]);
glTextCoord2f(1.0,1.0);
glVertext3fv(vetices[c]);
glColor3fv(colors[d]);
glTextCoord2f(1.0,0.0);
glVertext3fv(vetices[d]);
glEnd();
}

void colorcube()
{
polygon(0,3,2,1);
polygon(2,3,7,6);
polygon(3,0,4,7);
polygon(1,2,6,5);
polygon(4,5,6,7);
polygon(5,4,0,1);
}

static GLfloat theta[]={0.0,0.0,0.0};
static GLint axis=2;

void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(theta[0],1.0,0.0,0.0);
glRotatef(theta[1],0.0,1.0,0.0);
glRotatef(theta[2],0.0,0.0,1.0);

colorcube();

glutSwapBuffers();
}

void spinCube()
{
theta[axis]+=2.0;
if(theta[axis]>360.0) theta[axis]-=360.0;
glutPostRedisplay();
}

void mouse(int btn,int state,int x,int y)
{
if(btn==GLUT_LEFT_BUTTON&state==GLUT_DOWN)
axis=0;
if(btn==GLUT_MIDDLE_BUTTON&state==GLUT_DOWN)
axis=1;
if(btn==GLUT_RIGHT_BUTTON&state==GLUT_DOWN)
axis=2;
}

void myReshape(int w,int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-2.0,2.0,-2.0*(GLfloat)h/(GLfloat)
w,2.0*(GLfloat)h/(GLfloat)w,
-10.0,10.0);
else
glOrtho(-2.0*(GLfloat)w/(GLfloat)h,
2.0*(GLfloat)w/(GLfloat)h,-2.0,2.0,
-10.0,10.0);
glMatrixMode(GL_MODELVIEW);
}

int main(int argc,char** argv)
{
GLubyte image[64][64][3];
int i,j,r,c;
for(i=0;i<64;i++)
{
for(j=0;j<64;j++)
{
c=((((i&0x8)==0)^((j&0x8))==0))*255;
image[i][j][0]=(GLubyte)c;
image[i][j][1]=(GLubyte)c;
image[i][j][2]=(GLubyte)c;
}
}
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(500,500);
glutCreateWindow("colorcube");
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
glutIdleFunc(spinCube);
glutMouseFunc(mouse);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);

glTextImage2D(GL_TEXTURE_2D,0,GL_RGB,64,64,0,GL_RGB,
GL_UNSIGNED_BYTE,image);

glTextParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTextParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTextParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTextParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glutMainLoop();
}

编译可以通过,但是链接出现这个错误:
unresolved external symbol _glVertext3fv
unresolved external symbol _glTextCoord2f
unresolved external symbol _glTextParameterf
unresolved external symbol _glTextImage2D

这个错误应该如何解决
...全文
87 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhulei1978 2019-06-26
  • 打赏
  • 举报
回复
哦,谢谢
zgl7903 2019-06-25
  • 打赏
  • 举报
回复
把相关的库添加进去

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧