2 u013516421 u013516421 于 2014.10.13 12:49 提问

OpenGL 坐标点大小,视点问题(无法显示三维图形)

本人大三初学Opengl,尝试着写了一下显示三维空间里的三个多边形的代码:

#include
void init()
{glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(2.0f,0.0f,4.0f,2.0f,0.0f,0.0f,2.0f,4.0f,0.0f);
}
void CGTest()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0f,0.0f,0.0f);

glBegin(GL_QUADS);
glVertex3f(1.5f,0.0f,2.5f);
glVertex3f(2.5f,0.0f,2.5f);
glVertex3f(2.5f,0.5f,2.5f);
glVertex3f(1.5f,0.5f,2.5f);
glEnd();

glBegin(GL_QUADS);
glVertex3f(1.5f,0.5f,2.0f);
glVertex3f(2.5f,0.5f,2.0f);
glVertex3f(2.5f,0.5f,2.5f);
glVertex3f(1.5f,0.5f,2.5f);
glEnd();

glBegin(GL_QUADS);
glVertex3f(2.5f,0.5f,2.5f);
glVertex3f(2.5f,0.5f,2.0f);
glVertex3f(2.5f,0.0f,2.0f);
glVertex3f(2.5f,0.0f,2.5f);
glEnd();

glFlush();
}
void main(int argc,char** argv)
{glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(50,100);
glutInitWindowSize(400,400);
glutCreateWindow("An Example OpenGL Program");
init();
glutDisplayFunc(CGTest);
glutMainLoop();
}

但是生成后没有显示任何黑色的多边形,是跟坐标点的位置有关么?还是说LookAt函数的参数不对呢?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!