计算机图形学/OpenGL/c++高手指点。我在vc++平台的win32控制台上编写如下代码,出现问题

#include"stdafx.h"#include"gl\glut.h"voiddisplay();voidInitialize();intmain(intargc,c... #include "stdafx.h"
#include "gl\glut.h"

void display();
void Initialize();

int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow("hello");
Initialize();
glutDisplayFunc(display);
glutMainLoop();

return 0;
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25,0.25,0.0);
glVertex3f(0.75,0.25,0.0);
glVertex3f(0.75,0.75,0.0);
glVertex3f(0.25,0.75,0.0);
glEnd();
glFlush();
}

void Initialize(){
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);

}
错误:
Linking...
pp.obj : error LNK2001: unresolved external symbol _glutMainLoop@0
pp.obj : error LNK2001: unresolved external symbol _glutDisplayFunc@4
pp.obj : error LNK2001: unresolved external symbol _glutCreateWindow@4
pp.obj : error LNK2001: unresolved external symbol _glutInitWindowPosition@8
pp.obj : error LNK2001: unresolved external symbol _glutInitWindowSize@8
pp.obj : error LNK2001: unresolved external symbol _glutInitDisplayMode@4
pp.obj : error LNK2001: unresolved external symbol _glutInit@8
Debug/pp.exe : fatal error LNK1120: 7 unresolved externals
执行 link.exe 时出错.

pp.exe - 1 error(s), 0 warning(s)
展开
 我来答
敛正雅7f
2011-12-08 · TA获得超过2031个赞
知道大有可为答主
回答量:1553
采纳率:0%
帮助的人:1750万
展开全部
没有加入gl的lib库

Properties->Configuration Properties->Linker-Input->Additional Dependencies
加入你的lib库

或者在程序前面加上
#pragma comment(lib, “glut32.lib”);
追问
请教个问题,我初学,在vc6.0单文档里写的,可是出现不了背景,是怎么回事,那些视点投影视口都设置了,我就想初始化一下背景,怎么就出不来呢?
glClearColor(1.0,0.0,0.0,0.0);
glViewport(0.0,0.0,200,200);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
追答
你上网找个例子比较下吧。。具体是什么情况得具体分析。。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式