我正在尝试制作一个场景,我正在看着XY平面,Z朝向和远离摄像机视图。我希望看到的物体距离我脸前的物体不同,所以我想我应该使用gluPerspective。我的屏幕上应该有一些轴来自原点,但是,我根本看不到任何东西。我让它与一堆翻译工作,但我想确保我理解如何正确操作这个,因为这是所有猜测和检查之前。
void resizeWindow(GLint newWidth, GLint newHeight)
{
glViewport(0, 0, newWidth, newHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f, (GLfloat)newWidth / (GLfloat)newHeight, 0.1f, 100.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
glPushMatrix();
glColor4ub(0, 120, 20, 255);
glBegin(GL_LINE_STRIP);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(3.0f, 0.0f, 0.0f);
glVertex3f(2.85f, 0.10f, 0.0f);
glVertex3f(2.85f, -0.10f, 0.0f);
glVertex3f(3.0f, 0.0f, 0.0f);
glVertex3f(2.85f, 0.0f, 0.10f);
glVertex3f(2.85f, 0.0f, -0.10f);
glVertex3f(3.0f, 0.0f, 0.0f);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 3.0f, 0.0f);
glVertex3f(0.0f, 2.85f, 0.10f);
glVertex3f(0.0f, 2.85f, -0.10f);
glVertex3f(0.0f, 3.0f, 0.0f);
glVertex3f(0.10f, 2.85f, 0.0f);
glVertex3f(-0.10f, 2.85f, 0.0f);
glVertex3f(0.0f, 3.0f, 0.0f);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 3.0f);
glVertex3f(0.10f, 0.0f, 2.85f);
glVertex3f(-0.10f, 0.0f, 2.85f);
glVertex3f(0.0f, 0.0f, 3.0f);
glVertex3f(0.0f, 0.10f, 2.85f);
glVertex3f(0.0f, -0.10f, 2.85f);
glVertex3f(0.0f, 0.0f, 3.0f);
glEnd();
答案 0 :(得分:0)
没有尝试运行代码,但是快速浏览一下: