VC6里面一个error LNK2001: unresolved external问题

#include <windows.h>
#include <GL/glew.h>
#include <GL/glut.h>
#define BUFFER_OFFSET(offset) ((GLvoid *) NULL + offset)
#define XStart -0.8
#define XEnd 0.8
#define YStart -0.8
#define YEnd 0.8
#define NumXPoints 11
#define NumYPoints 11
#define NumPoints (NumXPoints*NumYPoints)
#define NumPointsPerStrip (2*NumXPoints)
#define NumStrips (NumYPoints-1)
#define RestartIndex 0xffff

GLfloat color[6][3]={
	{1.0,1.0,1.0},{1.0,0.0,0.0},{1.0,1.0,0.0},
	{0.0,1.0,0.0},{0.0,1.0,1.0},{0.0,0.0,1.0}
};

int colorIndex =0;

void setVertex()
{
	int i,j,n;
	GLfloat * vertices;
	GLfloat x,y,dx,dy,*tmp;
	//glBindBuffer(GL_ARRAY_BUFFER,0);
	vertices = (GLfloat *)glMapBuffer(GL_ARRAY_BUFFER,GL_WRITE_ONLY);
	
	if(vertices==NULL){
		exit(EXIT_FAILURE);
	}
	else{
		dx = (XEnd-XStart)/(NumXPoints-1);
		dy = (YEnd-YStart)/(NumYPoints-1);
		tmp = vertices;
		n=0;
		for(j=0;j<NumYPoints;++j)
		{
			y=YStart + j*dy;
			
			for (i=0;i<NumXPoints;i++)
			{
				x = XStart+i*dx;
				*tmp++ = color[(colorIndex+i+j)%6][0];
				*tmp++ = color[(colorIndex+i+j)%6][1];
				*tmp++ = color[(colorIndex+i+j)%6][2];
				*tmp++ = x;
				*tmp++ = y;
				*tmp++ = 0.0;
			}
		}
		glUnmapBuffer(GL_ARRAY_BUFFER);
		//glVertexPointer(2,GL_FLOAT,0,BUFFER_OFFSET(0));
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_COLOR_ARRAY);
		glInterleavedArrays(GL_C3F_V3F, 0, 0);
		
	}
}

void setIndices()
{
	int i,j;
	GLushort *  indices;
	GLushort *index,bottomRow,topRow;
	//glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
	indices = (unsigned short *)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER,GL_WRITE_ONLY);
	if(indices==NULL)
	{
		exit(EXIT_FAILURE);
	}
	else{
		index = indices;
		for(j=0;j<NumStrips;j++){
			bottomRow = j*NumYPoints;
			topRow= bottomRow+NumYPoints;
			for(i=0;i<NumXPoints;i++){
				*index++=topRow+i;
				*index++=bottomRow+i;
			}
			*index++=RestartIndex;
		}
		glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
	}
}
void init()
{
	GLuint vbo,ebo;
	glGenBuffers(1,&vbo);
	glBindBuffer(GL_ARRAY_BUFFER,vbo);
	glBufferData(GL_ARRAY_BUFFER,6*NumPoints*sizeof(GLfloat),NULL,GL_STATIC_DRAW);
//	setVertex();
	glGenBuffers(1,&ebo);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,ebo);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER,NumStrips*(NumPointsPerStrip+1)*sizeof(GLushort),NULL,GL_STATIC_DRAW);
//	setIndices();	
	glPrimitiveRestartIndex(RestartIndex);
	glEnable(GL_PRIMITIVE_RESTART);
}

void display()
{
	setVertex();
	setIndices();
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glColor3f(1,1,1);
	glDrawElements(GL_TRIANGLE_STRIP,NumStrips*(NumPointsPerStrip+1),GL_UNSIGNED_SHORT,0);
	glutSwapBuffers();
}

void mouse(int button,int state,int x,int y)
{
	switch(button){
	case GLUT_LEFT_BUTTON:
		if(state==GLUT_DOWN)
		{
			colorIndex++;
			if(colorIndex==6)
				colorIndex = 0;
			glutPostRedisplay();
		}
		break;
	case 27:
		{
			exit(0);
			break;
		}
	default:
		break;
	}
}

int main(int argc, char ** argv)
{
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
	glutInitWindowSize(250,250);
	glutInitWindowPosition(100,100);
	glutCreateWindow(argv[0]);
	glewInit();
	init();
	glutDisplayFunc(display);
	glutMouseFunc(mouse);
	glutMainLoop();
	return 0;
}

编译之后出现如下错误:


-------------------Configuration: primrestart - Win32 Debug--------------------
Linking...
primrestart.obj : error LNK2001: unresolved external symbol __imp____glewUnmapBuffer
primrestart.obj : error LNK2001: unresolved external symbol __imp____glewMapBuffer
primrestart.obj : error LNK2001: unresolved external symbol __imp____glewPrimitiveRestartIndex
primrestart.obj : error LNK2001: unresolved external symbol __imp____glewBufferData
primrestart.obj : error LNK2001: unresolved external symbol __imp____glewBindBuffer
primrestart.obj : error LNK2001: unresolved external symbol __imp____glewGenBuffers
primrestart.obj : error LNK2001: unresolved external symbol __imp__glewInit
Debug/primrestart.exe : fatal error LNK1120: 7 unresolved externals
Error executing link.exe.

primrestart.exe - 8 error(s), 0 warning(s)


牛人请指点。我换到VC2008也是一样的错误,谢谢高手指点

转载于:https://my.oschina.net/liujinofhome/blog/35272

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值